home_automations.py 950 B

12345678910111213141516171819202122
  1. # This state is set every midnight by the ext_lights_control-script
  2. state.persist('pyscript.home_auto_lights_off_has_been_night','false')
  3. @state_trigger("int(sensor.lux_outside_the_garage) > int(float(input_number.auto_light_off_lux_value))", state_hold_false=0)
  4. def automate_home_auto_lights_off():
  5. log.info(f"********* AUTO LIGHTS OFF *********** Lux: " + str(sensor.lux_outside_the_garage) )
  6. if( pyscript.home_auto_lights_off_has_been_night == 'true' ):
  7. pyscript.home_auto_lights_off_has_been_night = 'false'
  8. if input_boolean.auto_lights_off == 'on':
  9. pyscript.state_goto_all_off();
  10. # Activate morning lights when Thomas gets up
  11. @time_trigger("once(06:18:00)")
  12. def morning_lights_thomas():
  13. log.info(f"********* THOMAS MORNING ON ***********")
  14. if binary_sensor.workday_sensor == 'on':
  15. if switch.eng_heat_a == 'on' or switch.eng_heat_b == 'on':
  16. pyscript.state_goto_morning();