Tree restructure and feature additions
parent
5349ca78cf
commit
0adda23933
565
wallmote.py
565
wallmote.py
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import hassapi as hass
|
import hassapi as hass
|
||||||
|
import inspect
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -9,16 +10,16 @@ from threading import Timer
|
||||||
"""
|
"""
|
||||||
1: States
|
1: States
|
||||||
1: Lights
|
1: Lights
|
||||||
1: Kitchen Lights
|
1: Kitchen Lights (Toggle)
|
||||||
1: Off
|
1: Off
|
||||||
2: 10%
|
2: 10%
|
||||||
3: 55%
|
3: 55%
|
||||||
4: 100%
|
4: 100%
|
||||||
2: Main Room Lights
|
2: Main Room Lights (Toggle)
|
||||||
[...]
|
[...]
|
||||||
3: Living Room Lights
|
3: Living Room Lights (Toggle)
|
||||||
[...]
|
[...]
|
||||||
4: Bedroom Lights
|
4: Bedroom Lights (Toggle)
|
||||||
[...]
|
[...]
|
||||||
2: A/C
|
2: A/C
|
||||||
2: Main Room AC
|
2: Main Room AC
|
||||||
|
@ -55,206 +56,447 @@ from threading import Timer
|
||||||
[...]
|
[...]
|
||||||
4: Bedroom Fan
|
4: Bedroom Fan
|
||||||
[...]
|
[...]
|
||||||
2: Miscellaneous
|
2: Music
|
||||||
1: Effects
|
1: Join/unjoin speakers
|
||||||
1: Clear light RGB strip notifications
|
1. Unjoin speakers
|
||||||
2: Music
|
# Select master
|
||||||
1: Join/unjoin speakers
|
3. Living Room Sonos
|
||||||
1. Unjoin speakers
|
4. Bedroom Sonos
|
||||||
# Select master
|
2: Play Music
|
||||||
3. Living Room Sonos
|
3: Play on Living Room Sonos
|
||||||
4. Bedroom Sonos
|
1: Spotify: Liked Songs
|
||||||
2: Play Music
|
2: Spotify: Getting Things Done
|
||||||
3: Play on Living Room Sonos
|
4: Play on Bedroom Sonos
|
||||||
1: Spotify: Liked Songs
|
1: Spotify: Liked Songs
|
||||||
2: Spotify: Getting Things Done
|
2: Spotify: Chill Sleep
|
||||||
4: Play on Bedroom Sonos
|
3: Media Controls
|
||||||
1: Spotify: Liked Songs
|
3: Living Room Sonos
|
||||||
2: Spotify: Chill Sleep
|
1. Pause
|
||||||
3: Media Controls
|
2. Play
|
||||||
3: Living Room Sonos
|
3. Previous
|
||||||
1. Play
|
4. Next
|
||||||
2. Pause
|
4: Bedroom Sonos
|
||||||
3. Previous
|
[...]
|
||||||
4. Next
|
4. Options:
|
||||||
4: Bedroom Sonos
|
3: Living Room Sonos
|
||||||
[...]
|
2: Crossfade
|
||||||
4. Volume: TODO
|
1: Off
|
||||||
3: Living Room Sonos
|
2: On
|
||||||
4: Bedroom Sonos
|
3: Shuffle
|
||||||
3: Reserved
|
1: Off
|
||||||
4: Configuration
|
2: On
|
||||||
|
4: Repeat
|
||||||
|
1: Off
|
||||||
|
2: On
|
||||||
|
4: Bedroom Sonos
|
||||||
|
[...]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tree = {
|
tree = {
|
||||||
1: { # States
|
1: { # State
|
||||||
1: { # Lights
|
1: { # Lights
|
||||||
1: { # Kitchen
|
1: { # Kitchen
|
||||||
1: { "function": lambda hass: set_brightness(hass,"light.kitchen_lights",0) },
|
"function": lambda hass: hass.call_service("light/toggle",entity_id="light.kitchen_lights"),
|
||||||
2: { "function": lambda hass: set_brightness(hass,"light.kitchen_lights",10) },
|
"description": "Kitchen Lights: Toggle",
|
||||||
3: { "function": lambda hass: set_brightness(hass,"light.kitchen_lights",55) },
|
1: {
|
||||||
4: { "function": lambda hass: set_brightness(hass,"light.kitchen_lights",100) }
|
"function": lambda hass: set_brightness(hass,"light.kitchen_lights",0),
|
||||||
|
"description": "Kitchen Lights: 0%"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.kitchen_lights",10),
|
||||||
|
"description": "Kitchen Lights: 10%"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.kitchen_lights",55),
|
||||||
|
"description": "Kitchen Lights: 55%"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.kitchen_lights",100),
|
||||||
|
"description": "Kitchen Lights: 100%"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
2: { # Main Room
|
2: { # Main Room
|
||||||
1: { "function": lambda hass: set_brightness(hass,"light.mainroom_lights",0) },
|
"function": lambda hass: hass.call_service("light/toggle",entity_id="light.mainroom_lights"),
|
||||||
2: { "function": lambda hass: set_brightness(hass,"light.mainroom_lights",10) },
|
"description": "Main Room Lights: Toggle",
|
||||||
3: { "function": lambda hass: set_brightness(hass,"light.mainroom_lights",55) },
|
1: {
|
||||||
4: { "function": lambda hass: set_brightness(hass,"light.mainroom_lights",100) }
|
"function": lambda hass: set_brightness(hass,"light.mainroom_lights",0),
|
||||||
|
"description": "Main Room Lights: 0%"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.mainroom_lights",10),
|
||||||
|
"description": "Main Room Lights: 10%"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.mainroom_lights",55),
|
||||||
|
"description": "Main Room Lights: 55%"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.mainroom_lights",100),
|
||||||
|
"description": "Main Room Lights: 100%"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
3: { # Living Room
|
3: { # Living Room
|
||||||
1: { "function": lambda hass: set_brightness(hass,"light.livingroom_lights",0) },
|
"function": lambda hass: hass.call_service("light/toggle",entity_id="light.livingroom_lights"),
|
||||||
2: { "function": lambda hass: set_brightness(hass,"light.livingroom_lights",10) },
|
"description": "Living Room Lights: Toggle",
|
||||||
3: { "function": lambda hass: set_brightness(hass,"light.livingroom_lights",55) },
|
1: {
|
||||||
4: { "function": lambda hass: set_brightness(hass,"light.livingroom_lights",100) }
|
"function": lambda hass: set_brightness(hass,"light.livingroom_lights",0),
|
||||||
|
"description": "Living Room Lights: 0%"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.livingroom_lights",10),
|
||||||
|
"description": "Living Room Lights: 10%"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.livingroom_lights",55),
|
||||||
|
"description": "Living Room Lights: 55%"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.livingroom_lights",100),
|
||||||
|
"description": "Living Room Lights: 100%"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
4: { # Bedroom
|
4: { # Bedroom
|
||||||
1: { "function": lambda hass: set_brightness(hass,"light.bedroom_lights",0) },
|
"function": lambda hass: hass.call_service("light/toggle",entity_id="light.bedroom_lights"),
|
||||||
2: { "function": lambda hass: set_brightness(hass,"light.bedroom_lights",10) },
|
"description": "Bedroom Lights: Toggle",
|
||||||
3: { "function": lambda hass: set_brightness(hass,"light.bedroom_lights",55) },
|
1: {
|
||||||
4: { "function": lambda hass: set_brightness(hass,"light.bedroom_lights",100) }
|
"function": lambda hass: set_brightness(hass,"light.bedroom_lights",0),
|
||||||
|
"description": "Bedroom Lights: 0%"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.bedroom_lights",10),
|
||||||
|
"description": "Bedroom Lights: 10%"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.bedroom_lights",55),
|
||||||
|
"description": "Bedroom Lights: 55%"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: set_brightness(hass,"light.bedroom_lights",100),
|
||||||
|
"description": "Bedroom Lights: 100%"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
2: { # A/C
|
2: { # A/C
|
||||||
2: { # Main Room
|
2: { # Main Room
|
||||||
1: { # Power
|
1: { # Power
|
||||||
1: { "function": lambda hass: hass.turn_on("climate.mainroom_ac") },
|
1: {
|
||||||
2: { "function": lambda hass: hass.turn_on("climate.mainroom_ac") },
|
"function": lambda hass: hass.turn_on("climate.mainroom_ac"),
|
||||||
3: { "function": lambda hass: hass.turn_off("climate.mainroom_ac") },
|
"description": "Main Room A/C Power: On"
|
||||||
4: { "function": lambda hass: hass.turn_off("climate.mainroom_ac") },
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: hass.turn_on("climate.mainroom_ac"),
|
||||||
|
"description": "Main Room A/C Power: On"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: hass.turn_off("climate.mainroom_ac"),
|
||||||
|
"description": "Main Room A/C Power: Off"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: hass.turn_off("climate.mainroom_ac"),
|
||||||
|
"description": "Main Room A/C Power: Off"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
2: { # Mode
|
2: { # Mode
|
||||||
1: { "function": lambda hass: gree_set_mode(hass,"mainroom_ac","cool") },
|
1: {
|
||||||
2: { "function": lambda hass: gree_set_mode(hass,"mainroom_ac","heat") },
|
"function": lambda hass: gree_set_mode(hass,"mainroom_ac","cool"),
|
||||||
3: { "function": lambda hass: gree_set_mode(hass,"mainroom_ac","fan_only") }
|
"description": "Main Room A/C Mode: Cool"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: gree_set_mode(hass,"mainroom_ac","heat"),
|
||||||
|
"description": "Main Room A/C Mode: Heat"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: gree_set_mode(hass,"mainroom_ac","fan_only"),
|
||||||
|
"description": "Main Room A/C Mode: Fan"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
3: { # Fan Level
|
3: { # Fan Level
|
||||||
1: { "function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","auto") },
|
1: {
|
||||||
2: { "function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","quiet") },
|
"function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","auto"),
|
||||||
3: { "function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","medium") },
|
"description": "Main Room A/C Fan Level: Auto"
|
||||||
4: { "function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","high") }
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","quiet"),
|
||||||
|
"description": "Main Room A/C Fan Level: Quiet"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","medium"),
|
||||||
|
"description": "Main Room A/C Fan Level: Medium"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"mainroom_ac","high"),
|
||||||
|
"description": "Main Room A/C Fan Level: High"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
4: { # Temperature
|
4: { # Temperature
|
||||||
1: { "function": lambda hass: set_temperature(hass,"mainroom_ac",72) },
|
1: {
|
||||||
2: { "function": lambda hass: set_temperature(hass,"mainroom_ac",74) },
|
"function": lambda hass: set_temperature(hass,"mainroom_ac",72),
|
||||||
3: { "function": lambda hass: set_temperature(hass,"mainroom_ac",76) },
|
"description": "Main Room A/C Temperature: 72"
|
||||||
4: { "function": lambda hass: set_temperature(hass,"mainroom_ac",78) }
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"mainroom_ac",74),
|
||||||
|
"description": "Main Room A/C Temperature: 74"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"mainroom_ac",76),
|
||||||
|
"description": "Main Room A/C Temperature: 76"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"mainroom_ac",78),
|
||||||
|
"description": "Main Room A/C Temperature: 78"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
3: { # Living Room
|
3: { # Living Room
|
||||||
1: { # Power
|
1: { # Power
|
||||||
1: { "function": lambda hass: hass.turn_on("climate.livingroom_ac") },
|
1: {
|
||||||
2: { "function": lambda hass: hass.turn_on("climate.livingroom_ac") },
|
"function": lambda hass: hass.turn_on("climate.livingroom_ac"),
|
||||||
3: { "function": lambda hass: hass.turn_off("climate.livingroom_ac") },
|
"description": "Living Room A/C Power: On"
|
||||||
4: { "function": lambda hass: hass.turn_off("climate.livingroom_ac") },
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: hass.turn_on("climate.livingroom_ac"),
|
||||||
|
"description": "Living Room A/C Power: On"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: hass.turn_off("climate.livingroom_ac"),
|
||||||
|
"description": "Living Room A/C Power: Off"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: hass.turn_off("climate.livingroom_ac"),
|
||||||
|
"description": "Living Room A/C Power: Off"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
2: { # Mode
|
2: { # Mode
|
||||||
1: { "function": lambda hass: gree_set_mode(hass,"livingroom_ac","cool") },
|
1: {
|
||||||
2: { "function": lambda hass: gree_set_mode(hass,"livingroom_ac","heat") },
|
"function": lambda hass: gree_set_mode(hass,"livingroom_ac","cool"),
|
||||||
3: { "function": lambda hass: gree_set_mode(hass,"livingroom_ac","fan_only") }
|
"description": "Living Room A/C Mode: Cool"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: gree_set_mode(hass,"livingroom_ac","heat"),
|
||||||
|
"description": "Living Room A/C Mode: Heat"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: gree_set_mode(hass,"livingroom_ac","fan_only"),
|
||||||
|
"description": "Living Room A/C Mode: Fan"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
3: { # Fan Level
|
3: { # Fan Level
|
||||||
1: { "function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","auto") },
|
1: {
|
||||||
2: { "function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","quiet") },
|
"function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","auto"),
|
||||||
3: { "function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","medium") },
|
"description": "Living Room A/C Fan Level: Auto"
|
||||||
4: { "function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","high") }
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","quiet"),
|
||||||
|
"description": "Living Room A/C Fan Level: Quiet"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","medium"),
|
||||||
|
"description": "Living Room A/C Fan Level: Medium"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"livingroom_ac","high"),
|
||||||
|
"description": "Living Room A/C Fan Level: High"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
4: { # Temperature
|
4: { # Temperature
|
||||||
1: { "function": lambda hass: set_temperature(hass,"livingroom_ac",72) },
|
1: {
|
||||||
2: { "function": lambda hass: set_temperature(hass,"livingroom_ac",74) },
|
"function": lambda hass: set_temperature(hass,"livingroom_ac",72),
|
||||||
3: { "function": lambda hass: set_temperature(hass,"livingroom_ac",76) },
|
"description": "Living Room A/C Temperature: 72"
|
||||||
4: { "function": lambda hass: set_temperature(hass,"livingroom_ac",78) }
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"livingroom_ac",74),
|
||||||
|
"description": "Living Room A/C Temperature: 74"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"livingroom_ac",76),
|
||||||
|
"description": "Living Room A/C Temperature: 76"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"livingroom_ac",78),
|
||||||
|
"description": "Living Room A/C Temperature: 78"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
4: { # Bedroom
|
4: { # Bedroom
|
||||||
1: { # Power
|
1: { # Power
|
||||||
1: { "function": lambda hass: hass.turn_on("climate.bedroom_ac") },
|
1: {
|
||||||
2: { "function": lambda hass: hass.turn_on("climate.bedroom_ac") },
|
"function": lambda hass: hass.turn_on("climate.bedroom_ac"),
|
||||||
3: { "function": lambda hass: hass.turn_off("climate.bedroom_ac") },
|
"description": "Bedroom A/C Power: On"
|
||||||
4: { "function": lambda hass: hass.turn_off("climate.bedroom_ac") },
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: hass.turn_on("climate.bedroom_ac"),
|
||||||
|
"description": "Bedroom A/C Power: On"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: hass.turn_off("climate.bedroom_ac"),
|
||||||
|
"description": "Bedroom A/C Power: Off"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: hass.turn_off("climate.bedroom_ac"),
|
||||||
|
"description": "Bedroom A/C Power: Off"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
2: { # Mode
|
2: { # Mode
|
||||||
1: { "function": lambda hass: gree_set_mode(hass,"bedroom_ac","cool") },
|
1: {
|
||||||
2: { "function": lambda hass: gree_set_mode(hass,"bedroom_ac","heat") },
|
"function": lambda hass: gree_set_mode(hass,"bedroom_ac","cool"),
|
||||||
3: { "function": lambda hass: gree_set_mode(hass,"bedroom_ac","fan_only") }
|
"description": "Bedroom A/C Mode: Cool"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: gree_set_mode(hass,"bedroom_ac","heat"),
|
||||||
|
"description": "Bedroom A/C Mode: Heat"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: gree_set_mode(hass,"bedroom_ac","fan_only"),
|
||||||
|
"description": "Bedroom A/C Mode: Fan"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
3: { # Fan Level
|
3: { # Fan Level
|
||||||
1: { "function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","auto") },
|
1: {
|
||||||
2: { "function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","quiet") },
|
"function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","auto"),
|
||||||
3: { "function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","medium") },
|
"description": "Bedroom A/C Fan Level: Auto"
|
||||||
4: { "function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","high") }
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","quiet"),
|
||||||
|
"description": "Bedroom A/C Fan Level: Quiet"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","medium"),
|
||||||
|
"description": "Bedroom A/C Fan Level: Medium"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: gree_set_fan_level(hass,"bedroom_ac","high"),
|
||||||
|
"description": "Bedroom A/C Fan Level: High"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
4: { # Temperature
|
4: { # Temperature
|
||||||
1: { "function": lambda hass: set_temperature(hass,"bedroom_ac",72) },
|
1: {
|
||||||
2: { "function": lambda hass: set_temperature(hass,"bedroom_ac",74) },
|
"function": lambda hass: set_temperature(hass,"bedroom_ac",72),
|
||||||
3: { "function": lambda hass: set_temperature(hass,"bedroom_ac",76) },
|
"description": "Bedroom A/C Temperature: 72"
|
||||||
4: { "function": lambda hass: set_temperature(hass,"bedroom_ac",78) }
|
},
|
||||||
|
2: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"bedroom_ac",74),
|
||||||
|
"description": "Bedroom A/C Temperature: 74"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"bedroom_ac",76),
|
||||||
|
"description": "Bedroom A/C Temperature: 76"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
"function": lambda hass: set_temperature(hass,"bedroom_ac",78),
|
||||||
|
"description": "Bedroom A/C Temperature: 78"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
3: { # Fans
|
3: { # Fans
|
||||||
1: { # Kitchen
|
1: { # Kitchen
|
||||||
1: { "function": lambda hass: hass.set_value("input_number.kitchen_fan",0) },
|
1: {"function": lambda hass: hass.set_value("input_number.kitchen_fan",0)},
|
||||||
2: { "function": lambda hass: hass.set_value("input_number.kitchen_fan",1) },
|
2: {"function": lambda hass: hass.set_value("input_number.kitchen_fan",1)},
|
||||||
3: { "function": lambda hass: hass.set_value("input_number.kitchen_fan",2) },
|
3: {"function": lambda hass: hass.set_value("input_number.kitchen_fan",2)},
|
||||||
4: { "function": lambda hass: hass.set_value("input_number.kitchen_fan",3) }
|
4: {"function": lambda hass: hass.set_value("input_number.kitchen_fan",3)}
|
||||||
},
|
},
|
||||||
3: { # Living Room
|
3: { # Living Room
|
||||||
1: { "function": lambda hass: hass.set_value("input_number.livingroom_fan",0) },
|
1: {"function": lambda hass: hass.set_value("input_number.livingroom_fan",0)},
|
||||||
2: { "function": lambda hass: hass.set_value("input_number.livingroom_fan",1) },
|
2: {"function": lambda hass: hass.set_value("input_number.livingroom_fan",1)},
|
||||||
3: { "function": lambda hass: hass.set_value("input_number.livingroom_fan",2) },
|
3: {"function": lambda hass: hass.set_value("input_number.livingroom_fan",2)},
|
||||||
4: { "function": lambda hass: hass.set_value("input_number.livingroom_fan",3) }
|
4: {"function": lambda hass: hass.set_value("input_number.livingroom_fan",3)}
|
||||||
},
|
},
|
||||||
4: { # Bedroom
|
4: { # Bedroom
|
||||||
1: { "function": lambda hass: hass.set_value("input_number.bedroom_fan",0) },
|
1: {"function": lambda hass: hass.set_value("input_number.bedroom_fan",0)},
|
||||||
2: { "function": lambda hass: hass.set_value("input_number.bedroom_fan",1) },
|
2: {"function": lambda hass: hass.set_value("input_number.bedroom_fan",1)},
|
||||||
3: { "function": lambda hass: hass.set_value("input_number.bedroom_fan",2) },
|
3: {"function": lambda hass: hass.set_value("input_number.bedroom_fan",2)},
|
||||||
4: { "function": lambda hass: hass.set_value("input_number.bedroom_fan",3) }
|
4: {"function": lambda hass: hass.set_value("input_number.bedroom_fan",3)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
2: { # Miscellaneous
|
2: { # Music
|
||||||
1: { # Effects
|
1: { # Join/unjoin
|
||||||
1: { "service": "script/clear_lightswitch_leds" }
|
1: {"function": lambda hass: hass.call_service("sonos/unjoin",
|
||||||
|
entity_id=["media_player.livingroom_sonos","media_player.bedroom_sonos"])},
|
||||||
|
3: {"function": lambda hass: hass.call_service("sonos/join",
|
||||||
|
master="media_player.livingroom_sonos",entity_id="media_player.bedroom_sonos")},
|
||||||
|
4: {"function": lambda hass: hass.call_service("sonos/join",
|
||||||
|
master="media_player.livingroom_sonos",entity_id="media_player.bedroom_sonos")},
|
||||||
},
|
},
|
||||||
2: { # Music
|
2: { # Play Music
|
||||||
1: { # Join/unjoin
|
3: { # Living Room Sonos
|
||||||
1: { "function": lambda hass: hass.call_service("sonos/unjoin",
|
1: {"function": lambda hass: select_source(hass,"media_player.livingroom_sonos","Songs")},
|
||||||
entity_id=["media_player.livingroom_sonos","media_player.bedroom_sonos"]) },
|
2: {"function": lambda hass: select_source(hass,"media_player.livingroom_sonos","Getting Things Done")}
|
||||||
3: { "function": lambda hass: hass.call_service("sonos/join",
|
|
||||||
master="media_player.livingroom_sonos",entity_id="media_player.bedroom_sonos")},
|
|
||||||
4: { "function": lambda hass: hass.call_service("sonos/join",
|
|
||||||
master="media_player.livingroom_sonos",entity_id="media_player.bedroom_sonos")},
|
|
||||||
},
|
},
|
||||||
2: { # Play Music
|
4: { # Bedroom Sonos
|
||||||
3: { # Living Room Sonos
|
1: {"function": lambda hass: select_source(hass,"media_player.bedroom_sonos","Songs")},
|
||||||
1: { "function": lambda hass: select_source(hass,"media_player.livingroom_sonos","Songs") },
|
2: {"function": lambda hass: select_source(hass,"media_player.bedroom_sonos","Chill sleep")}
|
||||||
2: { "function": lambda hass: select_source(hass,"media_player.livingroom_sonos","Getting Things Done") }
|
}
|
||||||
|
},
|
||||||
|
3: { # Media Controls
|
||||||
|
3: { # Living Room Sonos
|
||||||
|
1: {"function": lambda hass: hass.call_service("media_player/media_pause",
|
||||||
|
entity_id="media_player.livingroom_sonos")},
|
||||||
|
2: {"function": lambda hass: hass.call_service("media_player/media_play",
|
||||||
|
entity_id="media_player.livingroom_sonos")},
|
||||||
|
3: {"function": lambda hass: hass.call_service("media_player/media_previous_track",
|
||||||
|
entity_id="media_player.livingroom_sonos")},
|
||||||
|
4: {"function": lambda hass: hass.call_service("media_player/media_next_track",
|
||||||
|
entity_id="media_player.livingroom_sonos")}
|
||||||
|
},
|
||||||
|
4: { # Bedroom Sonos
|
||||||
|
1: {"function": lambda hass: hass.call_service("media_player/media_pause",
|
||||||
|
entity_id="media_player.bedroom_sonos")},
|
||||||
|
2: {"function": lambda hass: hass.call_service("media_player/media_play",
|
||||||
|
entity_id="media_player.bedroom_sonos")},
|
||||||
|
3: {"function": lambda hass: hass.call_service("media_player/media_previous_track",
|
||||||
|
entity_id="media_player.bedroom_sonos")},
|
||||||
|
4: {"function": lambda hass: hass.call_service("media_player/media_next_track",
|
||||||
|
entity_id="media_player.bedroom_sonos")}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
4: { # Options
|
||||||
|
3: { # Living Room Sonos
|
||||||
|
2: { # Crossfade
|
||||||
|
1: {"function": lambda hass: hass.turn_off("switch.livingroom_sonos_crossfade"),
|
||||||
|
"description": "Living Room Sonos: Crossfade: Off"},
|
||||||
|
2: {"function": lambda hass: hass.turn_on("switch.livingroom_sonos_crossfade"),
|
||||||
|
"description": "Living Room Sonos: Crossfade: On"}
|
||||||
},
|
},
|
||||||
4: { # Bedroom Sonos
|
3: { # Shuffle
|
||||||
1: { "function": lambda hass: select_source(hass,"media_player.bedroom_sonos","Songs") },
|
1: {"function": lambda hass: hass.call_service("media_player/shuffle_set",
|
||||||
2: { "function": lambda hass: select_source(hass,"media_player.bedroom_sonos","Chill sleep") }
|
entity_id="media_player.livingroom_sonos",shuffle=False),
|
||||||
|
"description": "Living Room Sonos: Shuffle: Off"},
|
||||||
|
2: {"function": lambda hass: hass.call_service("media_player/shuffle_set",
|
||||||
|
entity_id="media_player.livingroom_sonos",shuffle=True),
|
||||||
|
"description": "Living Room Sonos: Shuffle: On"},
|
||||||
|
},
|
||||||
|
4: { # Repeat
|
||||||
|
1: {"function": lambda hass: hass.call_service("media_player/repeat_set",
|
||||||
|
entity_id="media_player.livingroom_sonos",repeat="off"),
|
||||||
|
"description": "Living Room Sonos: Repeat: Off"},
|
||||||
|
2: {"function": lambda hass: hass.call_service("media_player/repeat_set",
|
||||||
|
entity_id="media_player.livingroom_sonos",repeat="all"),
|
||||||
|
"description": "Living Room Sonos: Repeat: On"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
3: { # Media Controls
|
4: { # Bedroom Sonos
|
||||||
3: { # Living Room Sonos
|
2: { # Crossfade
|
||||||
1: { "function": lambda hass: hass.call_service("media_player/media_pause",
|
1: {"function": lambda hass: hass.turn_off("switch.bedroom_sonos_crossfade"),
|
||||||
entity_id="media_player.livingroom_sonos")},
|
"description": "Bedroom Sonos: Crossfade: Off"},
|
||||||
2: { "function": lambda hass: hass.call_service("media_player/media_play",
|
2: {"function": lambda hass: hass.turn_on("switch.bedroom_sonos_crossfade"),
|
||||||
entity_id="media_player.livingroom_sonos")},
|
"description": "Bedroom Sonos: Crossfade: On"}
|
||||||
3: { "function": lambda hass: hass.call_service("media_player/media_previous_track",
|
|
||||||
entity_id="media_player.livingroom_sonos")},
|
|
||||||
4: { "function": lambda hass: hass.call_service("media_player/media_next_track",
|
|
||||||
entity_id="media_player.livingroom_sonos")}
|
|
||||||
},
|
},
|
||||||
4: { # Bedroom Sonos
|
3: { # Shuffle
|
||||||
1: { "function": lambda hass: hass.call_service("media_player/media_pause",
|
1: {"function": lambda hass: hass.call_service("media_player/shuffle_set",
|
||||||
entity_id="media_player.bedroom_sonos")},
|
entity_id="media_player.bedroom_sonos",shuffle=False),
|
||||||
2: { "function": lambda hass: hass.call_service("media_player/media_play",
|
"description": "Bedroom Sonos: Shuffle: Off"},
|
||||||
entity_id="media_player.bedroom_sonos")},
|
2: {"function": lambda hass: hass.call_service("media_player/shuffle_set",
|
||||||
3: { "function": lambda hass: hass.call_service("media_player/media_previous_track",
|
entity_id="media_player.bedroom_sonos",shuffle=True),
|
||||||
entity_id="media_player.bedroom_sonos")},
|
"description": "Bedroom Sonos: Shuffle: On"},
|
||||||
4: { "function": lambda hass: hass.call_service("media_player/media_next_track",
|
},
|
||||||
entity_id="media_player.bedroom_sonos")}
|
4: { # Repeat
|
||||||
|
1: {"function": lambda hass: hass.call_service("media_player/repeat_set",
|
||||||
|
entity_id="media_player.bedroom_sonos",repeat="off"),
|
||||||
|
"description": "Bedroom Sonos: Repeat: Off"},
|
||||||
|
2: {"function": lambda hass: hass.call_service("media_player/repeat_set",
|
||||||
|
entity_id="media_player.bedroom_sonos",repeat="all"),
|
||||||
|
"description": "Bedroom Sonos: Repeat: On"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,21 +532,19 @@ def select_source(hass, device, source):
|
||||||
# Sequence Logic #
|
# Sequence Logic #
|
||||||
##################
|
##################
|
||||||
|
|
||||||
# Long press cancels any existing sequence and begins a new one. The first element in a
|
# Short presses will be recorded into a sequence array. Long presses are reserved for
|
||||||
# sequence is always a long press, and all others are always short presses.
|
# actions directly in hass for now; use KeyReleased event to capture them. A sequence
|
||||||
# While a sequence is being entered, normal actions from short presses in hass are
|
# can be ended either immediately by recognizing a full sequence or by TIMEOUT seconds
|
||||||
# disabled. A sequence can be ended either immediately by recognizing a full sequence
|
# passing. (The former is NYI but the code is capable as is.)
|
||||||
# or by TIMEOUT seconds passing.
|
|
||||||
|
|
||||||
# - self.currentSequence contains an array of keys representing a sequence that is
|
# - self.currentSequence contains an array of keys representing a sequence that is
|
||||||
# actively being entered.
|
# actively being entered.
|
||||||
# - self.tot contains a timer for the process_sequence function, ending sequence entry.
|
# - self.tot contains a timer for the process_sequence function, ending sequence entry.
|
||||||
|
|
||||||
TIMEOUT=2
|
TIMEOUT=1
|
||||||
|
|
||||||
class WallmotePlumbing(hass.Hass):
|
class WallmotePlumbing(hass.Hass):
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self.turn_on("automation.wallmote");
|
|
||||||
self.currentSequence = [];
|
self.currentSequence = [];
|
||||||
self.listen_event(self.onevent, "zwave_js_value_notification");
|
self.listen_event(self.onevent, "zwave_js_value_notification");
|
||||||
|
|
||||||
|
@ -314,22 +554,12 @@ class WallmotePlumbing(hass.Hass):
|
||||||
key = int(event.get('property_key'));
|
key = int(event.get('property_key'));
|
||||||
# We don't get a KeyPressed event at all for long presses
|
# We don't get a KeyPressed event at all for long presses
|
||||||
evt = event.get('value');
|
evt = event.get('value');
|
||||||
if (evt == "KeyPressed"):
|
if (evt == "KeyPressed"): self.shortpress(key);
|
||||||
self.shortpress(key);
|
|
||||||
elif (evt == "KeyReleased"):
|
|
||||||
self.longpress(key);
|
|
||||||
|
|
||||||
def shortpress(self, key):
|
def shortpress(self, key):
|
||||||
# Single presses are handled in hass; sequences must start with a long press
|
|
||||||
if (len(self.currentSequence) == 0): return;
|
|
||||||
self.currentSequence.append(key);
|
self.currentSequence.append(key);
|
||||||
self.reset_tot();
|
self.reset_tot();
|
||||||
|
|
||||||
def longpress(self, key):
|
|
||||||
self.turn_off("automation.wallmote");
|
|
||||||
self.currentSequence = [key];
|
|
||||||
self.reset_tot();
|
|
||||||
|
|
||||||
def reset_tot(self):
|
def reset_tot(self):
|
||||||
if (hasattr(self,"tot")): self.tot.cancel();
|
if (hasattr(self,"tot")): self.tot.cancel();
|
||||||
self.tot = Timer(TIMEOUT,self.process_sequence);
|
self.tot = Timer(TIMEOUT,self.process_sequence);
|
||||||
|
@ -337,9 +567,6 @@ class WallmotePlumbing(hass.Hass):
|
||||||
|
|
||||||
def process_sequence(self):
|
def process_sequence(self):
|
||||||
self.tot.cancel(); # So process_sequence can be called directly
|
self.tot.cancel(); # So process_sequence can be called directly
|
||||||
self.turn_on("automation.wallmote");
|
|
||||||
# Clear self.currentSequence so future shortpresses are not
|
|
||||||
# treated as part of a sequence
|
|
||||||
sequence = self.currentSequence;
|
sequence = self.currentSequence;
|
||||||
self.currentSequence = [];
|
self.currentSequence = [];
|
||||||
self.log(sequence);
|
self.log(sequence);
|
||||||
|
@ -350,7 +577,13 @@ class WallmotePlumbing(hass.Hass):
|
||||||
# Deeper into the rabbit hole
|
# Deeper into the rabbit hole
|
||||||
category = sequence.pop(0);
|
category = sequence.pop(0);
|
||||||
if (category in tree): self.run_action(sequence,tree[category]);
|
if (category in tree): self.run_action(sequence,tree[category]);
|
||||||
|
else: self.log("No match");
|
||||||
else:
|
else:
|
||||||
# Perform an action from here
|
# Perform an action from here and log the description
|
||||||
if ("function" in tree): tree["function"](self);
|
if ("function" in tree): tree["function"](self);
|
||||||
elif ("service" in tree): self.call_service(tree["service"]);
|
elif ("service" in tree): self.call_service(tree["service"]);
|
||||||
|
else:
|
||||||
|
self.log("No match");
|
||||||
|
return;
|
||||||
|
if ("description" in tree): self.log(tree["description"]);
|
||||||
|
else: self.log(inspect.getsource(tree["function"]).strip());
|
||||||
|
|
Loading…
Reference in New Issue