Przeglądaj źródła

Working with main hall button.

pi 4 lat temu
rodzic
commit
8a17dd7f9e
5 zmienionych plików z 85 dodań i 0 usunięć
  1. 6 0
      configuration.yaml
  2. 5 0
      lights.yaml
  3. 17 0
      pyscript/state_goto.py
  4. 28 0
      pyscript/wall_buttons.py
  5. 29 0
      switches.yaml

+ 6 - 0
configuration.yaml

@@ -25,12 +25,18 @@ rflink:
   host: 127.0.0.1
   port: 12345
   wait_for_ack: false
+  ignore_devices:
+    - newkaku_000001_01
+
+
+
 
 
 # Text to speech
 tts:
   - platform: google_translate
 
+switch: !include switches.yaml
 input_boolean: !include input_booleans.yaml
 sensor: !include sensors.yaml
 light: !include lights.yaml

+ 5 - 0
lights.yaml

@@ -13,17 +13,22 @@
     
     newkaku_006d7076_1:
       name: Main Button 1
+      type: switchable
       aliases:
         - newkaku_006d7076_0
     newkaku_006d7076_2:
       name: Main Button 2
+      type: switchable
       aliases:
         - newkaku_006d7076_0
     newkaku_006d7076_3:
       name: Main Button 3
+      type: switchable
       aliases:
         - newkaku_006d7076_0
     newkaku_006d7076_4:
       name: Main Button 4
+      type: switchable
       aliases:
         - newkaku_006d7076_0
+

+ 17 - 0
pyscript/state_goto.py

@@ -0,0 +1,17 @@
+
+@service
+def state_goto_all_on():
+
+    log.info(f"********* ALL ON ***********")
+
+    switch.turn_on(entity_id='switch.group_button_all')
+    light.turn_on(entity_id='light.tradfri_bulb')
+
+
+@service
+def state_goto_all_off():
+
+    log.info(f"********* ALL OFF ***********")
+
+    switch.turn_off(entity_id='switch.group_button_all')
+    light.turn_off(entity_id='light.tradfri_bulb')

+ 28 - 0
pyscript/wall_buttons.py

@@ -0,0 +1,28 @@
+"""
+trigger file.wall_buttons.hallway_wall_button got event trigger, running action 
+(kwargs = {
+'trigger_type': 'event', 
+'event_type': 'button_pressed',
+ 'context': Context(user_id=None, 
+    parent_id=None, 
+    id='67d442d5b0b4c1f3308417722801f709'), 
+'entity_id': 'switch.hall_switch', 
+'state': 'on'
+})
+
+        kalle = kwargs.context.get("entity_id", None)
+                ^
+AttributeError: 'dict' object has no attribute 'context'
+"""
+
+@event_trigger( "button_pressed" , "entity_id == 'switch.hall_switch'")
+def hallway_wall_button():
+
+    log.info(f"****************  got EVENT_CALL_SERVICE with kwargs=")
+
+    if( switch.group_button_all == 'on'):
+        pyscript.state_goto_all_off();
+    else:
+        pyscript.state_goto_all_on();
+
+    

+ 29 - 0
switches.yaml

@@ -0,0 +1,29 @@
+
+- platform: rflink
+  devices:
+    newkaku_006d7076_0:
+      name: Group Button ALL
+
+    newkaku_00A8DF22_1:
+      name: Eng heat A
+    newkaku_00A8DF21_1:
+      name: Eng heat A REPERATER
+
+    newkaku_00A8DF22_3:
+      name: Eng heat B
+    newkaku_00A8DF21_3:
+      name: Eng heat B REPERATER
+
+    newkaku_00A8DF22_2:
+      name: Christmas Ext Lights
+    newkaku_00A8DF21_2:
+      name: Christmas Ext Lights REPEATER
+    
+    newkaku_013242B6_1:
+      name: Ch coop
+    newkaku_013242B5_1:
+      name: Ch coop REPEATER
+
+    newkaku_00066542_1:
+      name: Hall switch
+      fire_event: True