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

Temp disable lights when high energy prices

pi пре 2 година
родитељ
комит
c92f2bb329

+ 5 - 0
input_booleans.yaml

@@ -13,6 +13,11 @@ auto_lights_off:
   initial: false
   icon: mdi:weather-sunny
 
+auto_work_day_lights_on:
+  name: Auto Workday Lights On
+  initial: false
+  icon: mdi:weather-cloudy-clock
+
 bedroom_door:
   name: Bedroom door state
   icon: mdi:door

+ 5 - 2
pyscript/airpurifyer.py

@@ -1,18 +1,21 @@
 import asyncio
 from aioairctrl import CoAPClient
 
+# can set aqil (0,100) or uil (0,1) to control the brightness of the display
+# None command works perfectly
+
 
 
 def airpurifyer_to_night_mode():
     log.info(f"********* airpurifyer_to_night_mode ******************")
     client = CoAPClient.create(host="192.168.1.167")
-    client.set_control_value("aqil","0")
+    client.set_control_value("uil","0")
     client.set_control_value("mode","P")
 
 def airpurifyer_to_day_mode():
     log.info(f"********* airpurifyer_to_day_mode ******************")
     client = CoAPClient.create(host="192.168.1.167")
-    client.set_control_value("aqil","100")
+    client.set_control_value("uil","1")
     client.set_control_value("mode","A")
 
 

+ 1 - 1
pyscript/bedroom.py

@@ -13,7 +13,7 @@ def bedroom_door_raw_sensor(entity_id, new_state, old_state):
     #log.info(f"monitor_bedroom_door_event: entity {entity_id} changed from {old_state} to {new_state}")
     log.info(f"********* BEDROOM RAW SENSOR: "+binary_sensor.bedroom_door_raw_sensor+" ***********")
     input_boolean.bedroom_door = binary_sensor.bedroom_door_raw_sensor
-    pyscript.handle_bedroom_light()
+    #pyscript.handle_bedroom_light()   # Temp disable when high energy prices
 
 
 

+ 4 - 3
pyscript/home_automations.py

@@ -18,7 +18,8 @@ def automate_home_auto_lights_off():
 # Activate morning lights when Thomas gets up
 @time_trigger("once(06:18:00)")
 def morning_lights_thomas():
-    if binary_sensor.workday_sensor == 'on':
+    if binary_sensor.workday_sensor == 'on' and input_boolean.auto_work_day_lights_on == 'on':
         if switch.eng_heat_a == 'on' or switch.eng_heat_b == 'on':
-            log.info(f"********* THOMAS MORNING ON ***********")
-            pyscript.state_goto_morning()
+            if sensor.lux_outside_the_garage != 'unknown' and int(sensor.lux_outside_the_garage) < 3:
+                log.info(f"********* THOMAS MORNING ON ***********")
+                pyscript.state_goto_morning()

+ 9 - 9
pyscript/state_goto.py

@@ -27,17 +27,17 @@ def state_goto_all_on():
     task.unique('state_goto_py')
     cs = getCurrentState()
     log.info(f"********* ALL ON *********** State: " + str(cs) )
-    light.turn_on(entity_id='light.tradfri_bulb')
-    switch.turn_on(entity_id='switch.matsal')
+    light.turn_on(entity_id='light.tradfri_bulb')   # Stora flyglampan
+    #switch.turn_on(entity_id='switch.matsal')
     for x in range(2):
         switch.turn_on(entity_id='switch.group_button_all')
         task.sleep(0.5)
-        light.turn_on(entity_id='light.liv_room_table_lamp',brightness='1')
-        task.sleep(0.5)
+        #light.turn_on(entity_id='light.liv_room_table_lamp',brightness='1') # Temp disable when high energy prices
+        #task.sleep(0.5)
         light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
         task.sleep(0.5)
 
-    pyscript.handle_bedroom_light()
+    #pyscript.handle_bedroom_light()   # Temp disable when high energy prices
 
 
 @service
@@ -113,13 +113,13 @@ def state_goto_all_off():
     cs = getCurrentState()
     log.info(f"********* ALL OFF *********** State: " + str(cs) )
     light.turn_off(entity_id='light.tradfri_bulb')
-    switch.turn_off(entity_id='switch.matsal')
-    switch.turn_off(entity_id='switch.tradfri_outlet')  # Sovrum OFF
+    #switch.turn_off(entity_id='switch.matsal')  # Temp disable when high energy prices
+    #switch.turn_off(entity_id='switch.tradfri_outlet')  # Sovrum OFF  # Temp disable when high energy prices
     for x in range(2):
         switch.turn_off(entity_id='switch.group_button_all')
         task.sleep(0.5)
-        light.turn_off(entity_id='light.liv_room_table_lamp')
-        task.sleep(0.5)
+        #light.turn_off(entity_id='light.liv_room_table_lamp')  # Temp disable when high energy prices
+        #task.sleep(0.5)
         light.turn_off(entity_id='light.liv_room_corner_lamp')
         task.sleep(0.5)
     input_boolean.movie_mode = 'off'

+ 4 - 2
pyscript/wall_buttons.py

@@ -56,10 +56,12 @@ def hallway_wall_button(entity_id=None, state=None):
         pyscript.state_goto_all_on()
     
     if( entity_id == 'switch.mode_panel_2' ):   # Window
-        pyscript.state_goto_window()
+        #pyscript.state_goto_window()
+        log.info(f"This mode has been disabled.")
     
     if( entity_id == 'switch.mode_panel_3' ):   # Morning
-        pyscript.state_goto_morning()
+        log.info(f"This mode has been disabled.")
+        #pyscript.state_goto_morning()
     
     if( entity_id == 'switch.mode_panel_4' ):   # All OFF
         pyscript.state_goto_all_off()