bedroom.py 674 B

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