123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- from homeassistant.const import EVENT_STATE_CHANGED
- # 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(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')
|