12345678910111213141516171819202122 |
- @service
- def handle_bedroom_light():
- task.unique('handle_bedroom_light')
- log.info(f"********* BEDROOM LIGHT CONTROL **** Btn_4:" + light.main_button_4 + " Door:"+ binary_sensor.bedroom_door)
- task.sleep(1)
- if light.main_button_4 == 'on' and binary_sensor.bedroom_door == 'on':
- # If OPEN
- switch.turn_on(entity_id='switch.tradfri_outlet')
- else:
- switch.turn_off(entity_id='switch.tradfri_outlet')
- @state_trigger("binary_sensor.bedroom_door")
- def bedroom_door_sensor():
- task.unique('bedroom_door_sensor')
- log.info(f"********* BEDROOM DOOR: "+binary_sensor.bedroom_door+" ***********")
- pyscript.handle_bedroom_light()
|