home_automations.py 1.5 KB

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