فهرست منبع

Working with Iphone buttons.

pi 4 سال پیش
والد
کامیت
e9b1fd1527
5فایلهای تغییر یافته به همراه79 افزوده شده و 17 حذف شده
  1. 6 2
      configuration.yaml
  2. 8 1
      pyscript/home_automations.py
  3. 43 4
      pyscript/state_goto.py
  4. 18 6
      pyscript/wall_buttons.py
  5. 4 4
      switches.yaml

+ 6 - 2
configuration.yaml

@@ -28,8 +28,12 @@ rflink:
   ignore_devices:
     - newkaku_000001_01
 
-
-
+binary_sensor:
+   - platform: rflink
+     devices:
+       newkaku_02ddc7fa_4:
+        name: Bedroom door
+        device_class: door
 
 
 # Text to speech

+ 8 - 1
pyscript/home_automations.py

@@ -8,4 +8,11 @@ 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();
+        pyscript.state_goto_all_off();
+
+
+# Activate morning lights when Thomas gets up
+@time_trigger("once(06:20:00)")
+def morning_lights_thomas():
+    if switch.eng_heat_a == 'on' or switch.eng_heat_b == 'on':
+        pyscript.state_goto_morning();

+ 43 - 4
pyscript/state_goto.py

@@ -1,17 +1,56 @@
 
+"""
+def getCurrentState():
+    if( light.main_button_1 == 'on' && )    # All ON
+        light.main_button_2 == 'on' &&
+        light.main_button_3 == 'on' &&
+        light.main_button_4 == 'on' ):
+        return 1
+    elif( light.main_button_1 == 'off' && ) # Window
+        light.main_button_2 == 'off' &&
+        light.main_button_3 == 'off' &&
+        light.main_button_4 == 'on' ):
+        return 2
+    elif( light.main_button_1 == 'off' && ) # Morning
+        light.main_button_2 == 'on' &&
+        light.main_button_3 == 'off' &&
+        light.main_button_4 == 'on' ):
+        return 3
+    elif( light.main_button_1 == 'off' && ) # All OFF
+        light.main_button_2 == 'off' &&
+        light.main_button_3 == 'off' &&
+        light.main_button_4 == 'off' ):
+        return 4
+"""
+
 @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')
+    switch.turn_on(entity_id='switch.tradfri_outlet')   # Sovrum ON
 
+@service
+def state_goto_window():
+    log.info(f"********* WINDOW ***********")
+    switch.turn_off(entity_id='switch.group_button_all')
+    light.turn_on(entity_id=' light.main_button_4')
+    light.turn_off(entity_id='light.tradfri_bulb')
+    switch.turn_on(entity_id='switch.tradfri_outlet')   # Sovrum ON
 
 @service
-def state_goto_all_off():
+def state_goto_morning():
+    log.info(f"********* MORNING ***********")
+    switch.turn_off(entity_id='switch.group_button_all')
+    light.turn_on(entity_id=' light.main_button_2')
+    light.turn_on(entity_id=' light.main_button_4')
+    light.turn_off(entity_id='light.tradfri_bulb')
+    switch.turn_off(entity_id='switch.tradfri_outlet')  # Sovrum OFF
 
+@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')
+    switch.turn_off(entity_id='switch.tradfri_outlet')  # Sovrum OFF
+

+ 18 - 6
pyscript/wall_buttons.py

@@ -15,6 +15,12 @@ trigger file.wall_buttons.hallway_wall_button got event trigger, running action
 AttributeError: 'dict' object has no attribute 'context'
 """
 
+# Mode Panel:
+# 1: All ON
+# 2: Windows
+# 3: Morning-mode
+# 4: All OFF
+
 @event_trigger( "button_pressed" )
 def hallway_wall_button(entity_id=None):
 
@@ -22,14 +28,20 @@ def hallway_wall_button(entity_id=None):
 
     if( entity_id == 'switch.hall_switch' ):
         if( switch.group_button_all == 'on'):
-            pyscript.state_goto_all_off();
+            pyscript.state_goto_all_off()
         else:
-            pyscript.state_goto_all_on();
+            pyscript.state_goto_all_on()
+    
+    if( entity_id == 'switch.mode_panel_1' ):   # All ON
+        pyscript.state_goto_all_on()
+    
+    if( entity_id == 'switch.mode_panel_2' ):   # Window
+        pyscript.state_goto_window()
     
-    if( entity_id == 'switch.mode_panel_1' ):
-            pyscript.state_goto_all_on();
+    if( entity_id == 'switch.mode_panel_3' ):   # Morning
+        pyscript.state_goto_morning()
     
-    if( entity_id == 'switch.mode_panel_4' ):
-        pyscript.state_goto_all_off();
+    if( entity_id == 'switch.mode_panel_4' ):   # All OFF
+        pyscript.state_goto_all_off()
 
     

+ 4 - 4
switches.yaml

@@ -4,14 +4,14 @@
     newkaku_006d7076_0:
       name: Group Button ALL
 
-    newkaku_00A8DF22_1:
+    newkaku_00a8df22_1:
       name: Eng heat A
-    newkaku_00A8DF21_1:
+    newkaku_00a8df21_1:
       name: Eng heat A REPERATER
 
-    newkaku_00A8DF22_3:
+    newkaku_00a8df22_3:
       name: Eng heat B
-    newkaku_00A8DF21_3:
+    newkaku_00a8df21_3:
       name: Eng heat B REPERATER
 
     newkaku_00A8DF22_2: