|
@@ -1,4 +1,4 @@
|
|
|
-
|
|
|
+from homeassistant.const import EVENT_STATE_CHANGED
|
|
|
|
|
|
def getCurrentState():
|
|
|
if( light.main_button_1 == 'on' and # All ON
|
|
@@ -39,6 +39,7 @@ def state_goto_all_on():
|
|
|
light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
|
|
|
task.sleep(0.5)
|
|
|
|
|
|
+ handle_kitchen_worklights()
|
|
|
#pyscript.handle_bedroom_light() # Temp disable when high energy prices
|
|
|
|
|
|
|
|
@@ -75,7 +76,8 @@ def state_goto_window():
|
|
|
light.turn_on(entity_id=' light.main_button_4')
|
|
|
task.sleep(0.5)
|
|
|
|
|
|
- pyscript.handle_bedroom_light()
|
|
|
+ handle_kitchen_worklights()
|
|
|
+ #pyscript.handle_bedroom_light()
|
|
|
|
|
|
@service
|
|
|
def state_goto_morning():
|
|
@@ -113,7 +115,8 @@ def state_goto_morning():
|
|
|
light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
|
|
|
task.sleep(0.5)
|
|
|
|
|
|
- pyscript.handle_bedroom_light()
|
|
|
+ handle_kitchen_worklights()
|
|
|
+ #pyscript.handle_bedroom_light()
|
|
|
|
|
|
@service
|
|
|
def state_goto_all_off():
|
|
@@ -134,6 +137,26 @@ def state_goto_all_off():
|
|
|
light.turn_off(entity_id='light.liv_room_corner_lamp')
|
|
|
task.sleep(0.5)
|
|
|
input_boolean.movie_mode = 'off'
|
|
|
+ handle_kitchen_worklights()
|
|
|
+
|
|
|
+@state_trigger("input_boolean.kitchen_worklights")
|
|
|
+def kitchen_worklights_button_trigger():
|
|
|
+ log.info(f"Kitchen worklight changed. State: {input_boolean.kitchen_worklights}")
|
|
|
+ handle_kitchen_worklights()
|
|
|
+
|
|
|
+def handle_kitchen_worklights():
|
|
|
+ log.info("handle_kitchen_worklights")
|
|
|
+ if( input_boolean.kitchen_worklights == 'on' ):
|
|
|
+ light.turn_on(entity_id='light.kitchen_worktop_4k',brightness='63')
|
|
|
+ light.turn_on(entity_id='light.kitchen_worktop_27k',brightness='127')
|
|
|
+ elif( light.hall_door == 'on' ):
|
|
|
+ light.turn_off(entity_id='light.kitchen_worktop_4k')
|
|
|
+ light.turn_on(entity_id='light.kitchen_worktop_27k',brightness='12')
|
|
|
+ else:
|
|
|
+ light.turn_off(entity_id='light.kitchen_worktop_4k')
|
|
|
+ light.turn_off(entity_id='light.kitchen_worktop_27k')
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
@state_trigger("input_boolean.movie_mode")
|
|
@@ -157,5 +180,12 @@ def movie_mode_button_trigger():
|
|
|
task.sleep(0.5)
|
|
|
|
|
|
|
|
|
+@event_trigger(EVENT_STATE_CHANGED, "entity_id=='input_button.av'")
|
|
|
+def on_ui_button_all_off_clicken(entity_id, new_state, old_state):
|
|
|
+ pyscript.state_goto_all_off()
|
|
|
+
|
|
|
+@event_trigger(EVENT_STATE_CHANGED, "entity_id=='input_button.allt_pa'")
|
|
|
+def on_ui_button_all_on_clicken(entity_id, new_state, old_state):
|
|
|
+ pyscript.state_goto_all_on()
|
|
|
|
|
|
|