Przeglądaj źródła

Added auto lights off + Button panel in kitchen

pi 4 lat temu
rodzic
commit
f0a9fdcb25

+ 1 - 0
pyscript/ext_lights_control.py

@@ -6,6 +6,7 @@ state.persist('pyscript.ext_light_has_been_night','false')
 @time_trigger("once(00:30:00)")
 def ext_light_has_been_night():
     pyscript.ext_light_has_been_night = 'true'
+    pyscript.home_auto_lights_off_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)")

+ 11 - 0
pyscript/home_automations.py

@@ -0,0 +1,11 @@
+
+# This state is set every midnight by the ext_lights_control-script
+state.persist('pyscript.home_auto_lights_off_has_been_night','false')
+
+
+@state_trigger("int(sensor.lux_outside_the_garage) > 1000", state_hold_false=0)
+def automate_home_auto_lights_off():
+    if( pyscript.home_auto_lights_off_has_been_night == 'true' ):
+        pyscript.home_auto_lights_off_has_been_night = 'false'
+        
+        pyscript.state_goto_all_off();

+ 13 - 6
pyscript/wall_buttons.py

@@ -15,14 +15,21 @@ trigger file.wall_buttons.hallway_wall_button got event trigger, running action
 AttributeError: 'dict' object has no attribute 'context'
 """
 
-@event_trigger( "button_pressed" , "entity_id == 'switch.hall_switch'")
-def hallway_wall_button():
+@event_trigger( "button_pressed" )
+def hallway_wall_button(entity_id=None):
 
-    log.info(f"****************  got EVENT_CALL_SERVICE with kwargs=")
+    log.info(f"****************  got EVENT_CALL_SERVICE with {entity_id}")
 
-    if( switch.group_button_all == 'on'):
+    if( entity_id == 'switch.hall_switch' ):
+        if( switch.group_button_all == 'on'):
+            pyscript.state_goto_all_off();
+        else:
+            pyscript.state_goto_all_on();
+    
+    if( entity_id == 'switch.mode_panel_1' ):
+            pyscript.state_goto_all_on();
+    
+    if( entity_id == 'switch.mode_panel_4' ):
         pyscript.state_goto_all_off();
-    else:
-        pyscript.state_goto_all_on();
 
     

+ 13 - 0
switches.yaml

@@ -26,4 +26,17 @@
 
     newkaku_00066542_1:
       name: Hall switch
+      fire_event: True
+    
+    newkaku_00001234_1:
+      name: Mode panel 1
+      fire_event: True
+    newkaku_00001234_2:
+      name: Mode panel 2
+      fire_event: True
+    newkaku_00001234_3:
+      name: Mode panel 3
+      fire_event: True
+    newkaku_00001234_4:
+      name: Mode panel 4
       fire_event: True