bedroom.py 622 B

12345678910111213141516171819
  1. @state_trigger("binary_sensor.bedroom_door")
  2. def bedroom_door_sensor():
  3. log.info(f"********* BEDROOM DOOR: "+binary_sensor.bedroom_door+" ***********")
  4. handle_bedroom_light()
  5. @service
  6. @task_unique("handle_bedroom_light")
  7. def handle_bedroom_light():
  8. log.info(f"********* BEDROOM LIGHT CONTROL ***********" + light.main_button_4 + " - "+ binary_sensor.bedroom_door)
  9. task.sleep(1)
  10. if light.main_button_4 == 'on' and binary_sensor.bedroom_door == 'on':
  11. # If OPEN
  12. switch.turn_on(entity_id='switch.tradfri_outlet')
  13. else:
  14. switch.turn_off(entity_id='switch.tradfri_outlet')