|
@@ -31,6 +31,7 @@ def state_goto_all_on():
|
|
|
light.turn_on(entity_id='light.hall_inner')
|
|
|
light.turn_on(entity_id='light.hall_door')
|
|
|
#switch.turn_on(entity_id='switch.matsal')
|
|
|
+ switch.turn_on(entity_id='switch.koksfonster')
|
|
|
for x in range(2):
|
|
|
switch.turn_on(entity_id='switch.group_button_all')
|
|
|
task.sleep(0.5)
|
|
@@ -39,7 +40,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()
|
|
|
+ kitchen_worklights_button_trigger()
|
|
|
#pyscript.handle_bedroom_light() # Temp disable when high energy prices
|
|
|
|
|
|
|
|
@@ -49,7 +50,8 @@ def state_goto_window():
|
|
|
cs = getCurrentState()
|
|
|
log.info(f"********* WINDOW *********** State: " + str(cs) )
|
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
|
- switch.turn_off(entity_id='switch.matsal')
|
|
|
+ #switch.turn_off(entity_id='switch.matsal')
|
|
|
+ switch.turn_on(entity_id='switch.koksfonster')
|
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
|
light.turn_off(entity_id='light.hall_door')
|
|
|
|
|
@@ -76,7 +78,7 @@ def state_goto_window():
|
|
|
light.turn_on(entity_id=' light.main_button_4')
|
|
|
task.sleep(0.5)
|
|
|
|
|
|
- handle_kitchen_worklights()
|
|
|
+ kitchen_worklights_button_trigger()
|
|
|
#pyscript.handle_bedroom_light()
|
|
|
|
|
|
@service
|
|
@@ -85,7 +87,8 @@ def state_goto_morning():
|
|
|
cs = getCurrentState()
|
|
|
log.info(f"********* MORNING *********** State: " + str(cs) )
|
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
|
- switch.turn_off(entity_id='switch.matsal')
|
|
|
+ #switch.turn_off(entity_id='switch.matsal')
|
|
|
+ switch.turn_on(entity_id='switch.koksfonster')
|
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
|
light.turn_on(entity_id='light.hall_door')
|
|
|
|
|
@@ -115,7 +118,7 @@ def state_goto_morning():
|
|
|
light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
|
|
|
task.sleep(0.5)
|
|
|
|
|
|
- handle_kitchen_worklights()
|
|
|
+ kitchen_worklights_button_trigger()
|
|
|
#pyscript.handle_bedroom_light()
|
|
|
|
|
|
@service
|
|
@@ -127,6 +130,7 @@ def state_goto_all_off():
|
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
|
light.turn_off(entity_id='light.hall_door')
|
|
|
|
|
|
+ switch.turn_off(entity_id='switch.koksfonster')
|
|
|
#switch.turn_off(entity_id='switch.matsal') # Temp disable when high energy prices
|
|
|
#switch.turn_off(entity_id='switch.tradfri_outlet') # Sovrum OFF # Temp disable when high energy prices
|
|
|
for x in range(2):
|
|
@@ -137,22 +141,48 @@ 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()
|
|
|
+ kitchen_worklights_button_trigger()
|
|
|
|
|
|
+# Reacts to when the Kitchen Worklights button is changed
|
|
|
+# This could be from HA UI or from web-interface
|
|
|
@state_trigger("input_boolean.kitchen_worklights")
|
|
|
def kitchen_worklights_button_trigger():
|
|
|
log.info(f"Kitchen worklight changed. State: {input_boolean.kitchen_worklights}")
|
|
|
+ if( input_boolean.kitchen_worklights=='on' or light.hall_door == 'on' ):
|
|
|
+ log.info("Kitchen LED: Sec switch ON")
|
|
|
+ if( switch.kok_led_sec_switch == 'on' ):
|
|
|
+ log.info("K LED Sec Switch already On, go directly to PWW-Control")
|
|
|
+ handle_kitchen_worklights()
|
|
|
+ else:
|
|
|
+ switch.turn_on(entity_id='switch.kok_led_sec_switch')
|
|
|
+ else:
|
|
|
+ log.info("Kitchen LED: Sec switch OFF")
|
|
|
+ switch.turn_off(entity_id='switch.kok_led_sec_switch')
|
|
|
+
|
|
|
+# Triggers when the IKEA Switch changes state. Goes On or Off
|
|
|
+@event_trigger(EVENT_STATE_CHANGED, "entity_id=='switch.kok_led_sec_switch'")
|
|
|
+def kitchen_worklights_security_switch_trigger(entity_id, new_state, old_state):
|
|
|
+ log.info(f"kitchen_worklights_security_switch_trigger() {switch.kok_led_sec_switch}")
|
|
|
+ if( switch.kok_led_sec_switch=='on' ):
|
|
|
+ log.info("Kitchen LED: Control PWM Wait...")
|
|
|
+ task.sleep(0.5)
|
|
|
+ log.info("Kitchen LED: Go....")
|
|
|
handle_kitchen_worklights()
|
|
|
|
|
|
+# Controls the PWM of the kitchen workbench LED-Strips
|
|
|
+# Does not control the IKEA Switch that turns everything On/Off
|
|
|
def handle_kitchen_worklights():
|
|
|
- log.info("handle_kitchen_worklights")
|
|
|
+ log.info(f"handle_kitchen_worklights WL:{input_boolean.kitchen_worklights} HALL:{light.hall_door}")
|
|
|
if( input_boolean.kitchen_worklights == 'on' ):
|
|
|
+ log.info("K LED Full mode...")
|
|
|
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' ):
|
|
|
+ log.info("K LED Soft mode...")
|
|
|
light.turn_off(entity_id='light.kitchen_worktop_4k')
|
|
|
light.turn_on(entity_id='light.kitchen_worktop_27k',brightness='12')
|
|
|
else:
|
|
|
+ log.info("K LED Off mode...")
|
|
|
light.turn_off(entity_id='light.kitchen_worktop_4k')
|
|
|
light.turn_off(entity_id='light.kitchen_worktop_27k')
|
|
|
|