Преглед на файлове

Added pssibility to disable all_off functionality of output devices. Disabled all_off for ffe.sleep.wardrobe_light

master
Dirk Alders преди 3 месеца
родител
ревизия
c9bf036591
променени са 6 файла, в които са добавени 30 реда и са изтрити 13 реда
  1. 16
    0
      devices/base.py
  2. 3
    3
      devices/mydevices.py
  3. 4
    4
      devices/shelly.py
  4. 3
    3
      devices/silvercrest.py
  5. 3
    3
      devices/tradfri.py
  6. 1
    0
      function/first_floor_east.py

+ 16
- 0
devices/base.py Целия файл

@@ -116,3 +116,19 @@ class base(mqtt_base):
116 116
                     self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC] if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
117 117
         else:
118 118
             self.logger.error("Unknown tx toptic. Set TX_TOPIC of class to a known value")
119
+
120
+
121
+class base_output(base):
122
+    def __init__(self, mqtt_client, topic):
123
+        super().__init__(mqtt_client, topic)
124
+        self.__all_off_enabled__ = True
125
+
126
+    def disable_all_off(self, state=True):
127
+        self.__all_off_enabled__ = not state
128
+
129
+    def all_off(self):
130
+        if self.__all_off_enabled__:
131
+            try:
132
+                self.__all_off__()
133
+            except (AttributeError, TypeError) as e:
134
+                self.logger.warning("Method all_off was used, but __all_off__ method wasn't callable: %s", repr(e))

+ 3
- 3
devices/mydevices.py Целия файл

@@ -1,11 +1,11 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4
-from devices.base import base
4
+from devices.base import base, base_output
5 5
 import logging
6 6
 
7 7
 
8
-class powerplug(base):
8
+class powerplug(base_output):
9 9
     """ Communication (MQTT)
10 10
 
11 11
         my_powerplug
@@ -115,7 +115,7 @@ class powerplug(base):
115 115
     def set_output_all_mcb(self, device, key, data):
116 116
         self.set_output_all(data)
117 117
 
118
-    def all_off(self):
118
+    def __all_off__(self):
119 119
         self.set_output_all(False)
120 120
 
121 121
 

+ 4
- 4
devices/shelly.py Целия файл

@@ -1,12 +1,12 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4
-from devices.base import base
4
+from devices.base import base_output
5 5
 import logging
6 6
 import task
7 7
 
8 8
 
9
-class shelly(base):
9
+class shelly(base_output):
10 10
     """ Communication (MQTT)
11 11
 
12 12
         shelly
@@ -52,7 +52,7 @@ class shelly(base):
52 52
     KEY_FIRMWARE_VERSION = "fw_ver"
53 53
     #
54 54
     TX_TOPIC = "command"
55
-    TX_TYPE = base.TX_VALUE
55
+    TX_TYPE = base_output.TX_VALUE
56 56
     TX_FILTER_DATA_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1]
57 57
     #
58 58
     RX_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_INPUT_0, KEY_INPUT_1, KEY_LONGPUSH_0, KEY_LONGPUSH_1, KEY_OVERTEMPERATURE, KEY_TEMPERATURE,
@@ -161,7 +161,7 @@ class shelly(base):
161 161
         self.toggle_output_1_mcb(device, key, data)
162 162
         self.delayed_flash_task.run()
163 163
 
164
-    def all_off(self):
164
+    def __all_off__(self):
165 165
         if self.flash_active:
166 166
             self.all_off_requested = True
167 167
         else:

+ 3
- 3
devices/silvercrest.py Целия файл

@@ -1,11 +1,11 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4
-from devices.base import base
4
+from devices.base import base, base_output
5 5
 import logging
6 6
 
7 7
 
8
-class silvercrest_powerplug(base):
8
+class silvercrest_powerplug(base_output):
9 9
     """ Communication (MQTT)
10 10
 
11 11
         silvercrest_powerplug {
@@ -58,7 +58,7 @@ class silvercrest_powerplug(base):
58 58
     def toggle_output_0_mcb(self, device, key, data):
59 59
         self.set_output_0(not self.output_0)
60 60
 
61
-    def all_off(self):
61
+    def __all_off__(self):
62 62
         if self.output_0:
63 63
             self.set_output_0(False)
64 64
 

+ 3
- 3
devices/tradfri.py Целия файл

@@ -1,11 +1,11 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4
-from devices.base import base
4
+from devices.base import base, base_output
5 5
 import logging
6 6
 
7 7
 
8
-class tradfri_light(base):
8
+class tradfri_light(base_output):
9 9
     """ Communication (MQTT)
10 10
 
11 11
         tradfri_light {
@@ -124,7 +124,7 @@ class tradfri_light(base):
124 124
     def set_color_temp_mcb(self, device, key, data):
125 125
         self.set_color_temp(data)
126 126
 
127
-    def all_off(self):
127
+    def __all_off__(self):
128 128
         if self.output_0:
129 129
             self.set_output_0(False)
130 130
 

+ 1
- 0
function/first_floor_east.py Целия файл

@@ -193,6 +193,7 @@ class first_floor_east_sleep(room):
193 193
         self.button_tradfri = pd.get(props.STG_ZFE, loc, roo, props.FUN_INP)
194 194
         # wardrobe light
195 195
         self.wardrobe_light = pd.get(props.STG_ZFE, loc, roo, props.FUN_WLI)
196
+        self.wardrobe_light.disable_all_off()   # Always on - Off by light sensor
196 197
 
197 198
         super().__init__(mqtt_client, pd, vd)
198 199
 

Loading…
Отказ
Запис