ext_light_control.py 1.0 KB

12345678910111213141516171819202122
  1. state.persist('pyscript.ext_light_on_done','off')
  2. state.persist('pyscript.ext_light_off_done','off')
  3. @time_trigger("once(00:15:00)")
  4. def reset_ext_light_done_states():
  5. log.info(f"Reset the ext light done state variables.")
  6. pyscript.ext_light_on_done = 'off'
  7. pyscript.ext_light_off_done = 'off'
  8. @state_trigger( "int(sensor.lux_outside_the_garage) < 100 and int(sensor.lux_outside_the_garage.old) >= 100")
  9. def automate_exterior_lights_on_in_evening():
  10. if pyscript.ext_light_on_done == 'off' and input_boolean.exterior_lights_wanted_state == 'off':
  11. input_boolean.exterior_lights_wanted_state = 'on'
  12. pyscript.ext_light_on_done = 'on'
  13. @state_trigger( "int(sensor.lux_outside_the_garage) > 50 and int(sensor.lux_outside_the_garage.old) <= 50")
  14. def automate_exterior_lights_off_in_morning():
  15. if pyscript.ext_light_off_done == 'off' and input_boolean.exterior_lights_wanted_state == 'on':
  16. input_boolean.exterior_lights_wanted_state = 'off'
  17. pyscript.ext_light_off_done = 'on'