Преглед изворни кода

Changed to new pyscript and some clear ups.

Thomas Chef пре 4 година
родитељ
комит
1bd357398d
2 измењених фајлова са 10 додато и 9 уклоњено
  1. 0 1
      configuration.yaml
  2. 10 8
      pyscript/ext_lights_control.py

+ 0 - 1
configuration.yaml

@@ -4,7 +4,6 @@ homeassistant:
 counter:
 logbook:
 notify:
-input_boolean:
 input_datetime:
 input_number:
 input_select:

+ 10 - 8
pyscript/ext_lights_control.py

@@ -5,23 +5,25 @@ state.persist('pyscript.ext_light_has_been_night','false')
 # Set that it has been midnight, and that it's ok to turn the light on
 @time_trigger("once(00:30:00)")
 def ext_light_has_been_night():
-	pyscript.ext_light_has_been_night = 'true'
+    pyscript.ext_light_has_been_night = 'true'
 
 # Set that it has been noon, and that it's ok to turn off the light
 @time_trigger("once(12:30:00)")
 def ext_light_has_been_day():
-	pyscript.ext_light_has_been_day = 'true'
+    pyscript.ext_light_has_been_day = 'true'
 
 
-@state_trigger("pyscript.ext_light_has_been_day == 'true' and int(sensor.lux_outside_the_garage) < 100")
+@state_trigger("int(sensor.lux_outside_the_garage) < 100", state_hold_false=0 )
 def automate_exterior_lights_on_in_evening():
-	pyscript.ext_light_has_been_day = 'false'
-	input_boolean.exterior_lights_wanted_state = 'on'
+    if( pyscript.ext_light_has_been_day == 'true' ):
+        pyscript.ext_light_has_been_day = 'false'
+        input_boolean.exterior_lights_wanted_state = 'on'
 
-@state_trigger("pyscript.ext_light_has_been_night == 'true' and int(sensor.lux_outside_the_garage) > 50")
+@state_trigger("int(sensor.lux_outside_the_garage) > 50", state_hold_false=0)
 def automate_exterior_lights_off_in_morning():
-	pyscript.ext_light_has_been_night = 'false'
-	input_boolean.exterior_lights_wanted_state = 'off'
+    if( pyscript.ext_light_has_been_night == 'true' ):
+        pyscript.ext_light_has_been_night = 'false'
+        input_boolean.exterior_lights_wanted_state = 'off'