home_automations.py 1.2 KB

12345678910111213141516171819202122232425
  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("sensor.outside_lux != None and sensor.outside_lux != 'unknown' and int(sensor.outside_lux) > int(float(input_number.auto_light_off_lux_value))", state_hold_false=0)
  4. def automate_home_auto_lights_off():
  5. if( input_boolean.home_auto_lights_off_has_been_night == 'true' ):
  6. log.info(f"********* AUTO LIGHTS OFF *********** Lux: " + str(sensor.outside_lux) + " Limit:"+str(input_number.auto_light_off_lux_value))
  7. input_boolean.home_auto_lights_off_has_been_night = 'false'
  8. if input_boolean.auto_lights_off == 'on':
  9. input_select.light_mode = 'All off'
  10. # Activate morning lights when Thomas gets up
  11. @time_trigger("once(06:18:00)")
  12. def morning_lights_thomas():
  13. if binary_sensor.workday_sensor == 'on' and input_boolean.auto_work_day_lights_on == 'on':
  14. if switch.eng_heat_a == 'on' or switch.eng_heat_b == 'on':
  15. if sensor.outside_lux != 'unknown' and int(sensor.outside_lux) < 3:
  16. log.info(f"********* THOMAS MORNING ON ***********")
  17. input_select.light_mode = 'Morning'