Browse Source

Split for physical and videv devices

master
Dirk Alders 1 year ago
parent
commit
773d0a6679
1 changed files with 180 additions and 105 deletions
  1. 180
    105
      __init__.py

+ 180
- 105
__init__.py View File

14
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
14
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
15
 
15
 
16
 
16
 
17
-class devices(dict):
17
+class base(dict):
18
+    def __init__(self, mqtt_client):
19
+        super().__init__(self)
20
+
21
+    def add(self, mqtt_client, stg, loc, roo, fun, dty, num=None, ot=None):
22
+        """Method to initilise a device
23
+
24
+        Args:
25
+            stg (numeric): Source transmittion group (see SIS_* in props)
26
+            loc (numeric): Location (see LOC_* in props)
27
+            roo (numeric): Room (see ROO_* in props)
28
+            fun (numeric): Function (see FUN_* in props)
29
+            dty (numeric): Device type (see DTP_* in props)
30
+            num (numeric): Device number in case of multiple devices
31
+        """
32
+        def get_device(dty, mqtt_client, topic, ot):
33
+            # Temporary to fit to current implementation
34
+            if ot != topic:
35
+                logger.error("Topic change for %s: Using this one: %s", topic, ot)
36
+                topic = ot
37
+            dev_class = props.dty_repr(dty)
38
+            if dev_class is None:
39
+                logger.warning('Device type %d is not yet implemented. Topic %s will not be supported.', dty, topic)
40
+            else:
41
+                return dev_class(mqtt_client, topic)
42
+
43
+        topic = self.__topic__(stg, loc, roo, fun)
44
+        if num is None:
45
+            this_device = get_device(dty, mqtt_client, topic, ot)
46
+            if this_device is None:
47
+                logger.warning('Device type %d is not yet implemented. Topic %s will not be supported.', dty, topic)
48
+            else:
49
+                self[topic] = this_device
50
+        else:
51
+            dg = []
52
+            for i in num:
53
+                device_topic = self.__topic__(stg, loc, roo, fun) + '_%d' % i
54
+                dg.append(get_device(dty, mqtt_client, device_topic, ot=ot % i))
55
+            self[topic] = group(*dg)
56
+
57
+    def get(self, stg, loc, roo, fun):
58
+        """Method to get a device
59
+
60
+        Args:
61
+            stg (numeric): Source transmittion group (see SIS_* in props)
62
+            loc (numeric): Location (see LOC_* in props)
63
+            roo (numeric): Room (see ROO_* in props)
64
+            fun (numeric): Function (see FUN_* in props)
65
+            num (numeric): Device number in case of multiple devices
66
+        """
67
+        topic = self.__topic__(stg, loc, roo, fun)
68
+        return self[topic]
69
+
70
+    def __topic__(self, stg, loc, roo, fun):
71
+        if stg in [props.STG_ZFE, props.STG_ZFW, props.STG_ZGW]:
72
+            # Temporary to fit to current implementation
73
+            return '/'.join([
74
+                props.stg_repr(stg),
75
+                props.roo_repr(roo),
76
+                props.fun_repr(fun)
77
+            ])
78
+        else:
79
+            return '/'.join([
80
+                props.stg_repr(stg),
81
+                props.loc_repr(loc),
82
+                props.roo_repr(roo),
83
+                props.fun_repr(fun)
84
+            ])
85
+
86
+
87
+class physical_devices(base):
18
     """
88
     """
19
-    Class to select a device and hold the device information
89
+    Class to create and store physical smarthome devices
20
     """
90
     """
21
 
91
 
22
     def __init__(self, mqtt_client):
92
     def __init__(self, mqtt_client):
23
-        dict.__init__(self)
93
+        super().__init__(self)
24
         self.__init_gfw__(mqtt_client)
94
         self.__init_gfw__(mqtt_client)
25
         self.__init_ffw__(mqtt_client)
95
         self.__init_ffw__(mqtt_client)
26
         self.__init_ffe__(mqtt_client)
96
         self.__init_ffe__(mqtt_client)
27
         self.__init_stw__(mqtt_client)
97
         self.__init_stw__(mqtt_client)
28
-    
98
+
29
     def __init_gfw__(self, mqtt_client):
99
     def __init_gfw__(self, mqtt_client):
30
         loc = props.LOC_GFW
100
         loc = props.LOC_GFW
31
 
101
 
36
         TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY = "shellies/gfw/marion/main_light"
106
         TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY = "shellies/gfw/marion/main_light"
37
         TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE = "zigbee/gfw/marion/heating_valve"
107
         TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE = "zigbee/gfw/marion/heating_valve"
38
         # Temporary to fit to current implementation ###################################################
108
         # Temporary to fit to current implementation ###################################################
39
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY)            # Shelly Main Light
40
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
109
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
110
+                 ot=TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY)            # Shelly Main Light
111
+        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
112
+                 ot=TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
41
 
113
 
42
         # FLOOR
114
         # FLOOR
43
         roo = props.ROO_FLO
115
         roo = props.ROO_FLO
46
         TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY = "shellies/gfw/floor/main_light"
118
         TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY = "shellies/gfw/floor/main_light"
47
         TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE = "zigbee/gfw/floor/main_light_%d"
119
         TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE = "zigbee/gfw/floor/main_light_%d"
48
         # Temporary to fit to current implementation ###################################################
120
         # Temporary to fit to current implementation ###################################################
49
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY)            # Shelly Main Light
50
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, props.DTY_LLI_SBT, range(1,3), ot=TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE)         # Tradfri Main Light
121
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
122
+                 ot=TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY)            # Shelly Main Light
123
+        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, props.DTY_LLI_SBT,
124
+                 range(1, 3), ot=TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE)         # Tradfri Main Light
51
 
125
 
52
         # DIRK
126
         # DIRK
53
         roo = props.ROO_DIR
127
         roo = props.ROO_DIR
63
         TOPIC_GFW_DIRK_MPD = "my_apps/gfw/dirk/hifi/mpd"
137
         TOPIC_GFW_DIRK_MPD = "my_apps/gfw/dirk/hifi/mpd"
64
         TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE = "zigbee/gfw/dirk/heating_valve"
138
         TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE = "zigbee/gfw/dirk/heating_valve"
65
         # Temporary to fit to current implementation ###################################################
139
         # Temporary to fit to current implementation ###################################################
66
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY)            # Shelly Main Light
67
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT, ot=TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
68
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_INP, props.DTY_TIN_5xx, ot=TOPIC_GFW_DIRK_INPUT_DEVICE)            # Tradfri Input Device 5 Buttons
140
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
141
+                 ot=TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY)            # Shelly Main Light
142
+        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT,
143
+                 ot=TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
144
+        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_INP, props.DTY_TIN_5xx,
145
+                 ot=TOPIC_GFW_DIRK_INPUT_DEVICE)            # Tradfri Input Device 5 Buttons
69
         self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_MPP, props.DTY_MPP_4xx, ot=TOPIC_GFW_DIRK_POWERPLUG)            # My 4 port Powerplug
146
         self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_MPP, props.DTY_MPP_4xx, ot=TOPIC_GFW_DIRK_POWERPLUG)            # My 4 port Powerplug
70
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_DEL, props.DTY_TLI_SBT, ot=TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE)         ,  # Tradfri Desklight
71
-        self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_RCA, props.DTY_MRE_xxx, ot=TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)            # Remote Control IR Amplifier
147
+        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_DEL, props.DTY_TLI_SBT, ot=TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE),  # Tradfri Desklight
148
+        self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_RCA, props.DTY_MRE_xxx,
149
+                 ot=TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)            # Remote Control IR Amplifier
72
         self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_ASS, props.DTY_MAS_xxx, ot=TOPIC_GFW_DIRK_SPOTIFY)            # Audio status Spotify
150
         self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_ASS, props.DTY_MAS_xxx, ot=TOPIC_GFW_DIRK_SPOTIFY)            # Audio status Spotify
73
         self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_ASM, props.DTY_MAS_xxx, ot=TOPIC_GFW_DIRK_MPD)            # Audio status MPD
151
         self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_ASM, props.DTY_MAS_xxx, ot=TOPIC_GFW_DIRK_MPD)            # Audio status MPD
74
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
152
+        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
153
+                 ot=TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
75
 
154
 
76
     def __init_ffw__(self, mqtt_client):
155
     def __init_ffw__(self, mqtt_client):
77
         loc = props.LOC_FFW
156
         loc = props.LOC_FFW
83
         TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/julian/main_light"
162
         TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/julian/main_light"
84
         TOPIC_FFW_JULIAN_HEATING_VALVE_ZIGBEE = "zigbee/ffw/julian/heating_valve"
163
         TOPIC_FFW_JULIAN_HEATING_VALVE_ZIGBEE = "zigbee/ffw/julian/heating_valve"
85
         # Temporary to fit to current implementation ###################################################
164
         # Temporary to fit to current implementation ###################################################
86
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY)            # Shelly Main Light
87
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT, ot=TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
88
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_FFW_JULIAN_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
165
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
166
+                 ot=TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY)            # Shelly Main Light
167
+        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT,
168
+                 ot=TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
169
+        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
170
+                 ot=TOPIC_FFW_JULIAN_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
89
 
171
 
90
         # BATH
172
         # BATH
91
         roo = props.ROO_BAT
173
         roo = props.ROO_BAT
94
         # Temporary to fit to current implementation ###################################################
176
         # Temporary to fit to current implementation ###################################################
95
         TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE = "zigbee/ffw/bath/heating_valve"
177
         TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE = "zigbee/ffw/bath/heating_valve"
96
         # Temporary to fit to current implementation ###################################################
178
         # Temporary to fit to current implementation ###################################################
97
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
179
+        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
180
+                 ot=TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
98
 
181
 
99
         # LIVINGROOM
182
         # LIVINGROOM
100
         roo = props.ROO_LIV
183
         roo = props.ROO_LIV
103
         TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY = "shellies/ffw/livingroom/main_light"
186
         TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY = "shellies/ffw/livingroom/main_light"
104
         TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/livingroom/main_light"
187
         TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/livingroom/main_light"
105
         # Temporary to fit to current implementation ###################################################
188
         # Temporary to fit to current implementation ###################################################
106
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY)            # Shelly Main Light
107
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT, ot=TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
189
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
190
+                 ot=TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY)            # Shelly Main Light
191
+        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT,
192
+                 ot=TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
108
 
193
 
109
         # SLEEP
194
         # SLEEP
110
         roo = props.ROO_SLP
195
         roo = props.ROO_SLP
114
         TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/sleep/main_light"
199
         TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/sleep/main_light"
115
         TOPIC_FFW_SLEEP_HEATING_VALVE_ZIGBEE = "zigbee/ffw/sleep/heating_valve"
200
         TOPIC_FFW_SLEEP_HEATING_VALVE_ZIGBEE = "zigbee/ffw/sleep/heating_valve"
116
         # Temporary to fit to current implementation ###################################################
201
         # Temporary to fit to current implementation ###################################################
117
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFW_SLEEP_MAIN_LIGHT_SHELLY)            # Shelly Main Light
118
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBx, ot=TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
119
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_FFW_SLEEP_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
202
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
203
+                 ot=TOPIC_FFW_SLEEP_MAIN_LIGHT_SHELLY)            # Shelly Main Light
204
+        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBx,
205
+                 ot=TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
206
+        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
207
+                 ot=TOPIC_FFW_SLEEP_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
120
 
208
 
121
     def __init_ffe__(self, mqtt_client):
209
     def __init_ffe__(self, mqtt_client):
122
         loc = props.LOC_FFE
210
         loc = props.LOC_FFE
126
         # Temporary to fit to current implementation ###################################################
214
         # Temporary to fit to current implementation ###################################################
127
         TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY = "shellies/ffe/floor/main_light"
215
         TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY = "shellies/ffe/floor/main_light"
128
         # Temporary to fit to current implementation ###################################################
216
         # Temporary to fit to current implementation ###################################################
129
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY)            # Shelly Main Light
217
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
218
+                 ot=TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY)            # Shelly Main Light
130
 
219
 
131
         # KITCHEN
220
         # KITCHEN
132
         roo = props.ROO_KIT
221
         roo = props.ROO_KIT
136
         TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY = "shellies/ffe/kitchen/circulation_pump"
225
         TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY = "shellies/ffe/kitchen/circulation_pump"
137
         TOPIC_FFE_KITCHEN_HEATING_VALVE_ZIGBEE = "zigbee/ffe/kitchen/heating_valve"
226
         TOPIC_FFE_KITCHEN_HEATING_VALVE_ZIGBEE = "zigbee/ffe/kitchen/heating_valve"
138
         # Temporary to fit to current implementation ###################################################
227
         # Temporary to fit to current implementation ###################################################
139
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY)            # Shelly Main Light
140
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_CIR, props.DTY_SHY_SW1, ot=TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY)            # Shelly Main Light
141
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_FFE_KITCHEN_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
228
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
229
+                 ot=TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY)            # Shelly Main Light
230
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_CIR, props.DTY_SHY_SW1,
231
+                 ot=TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY)            # Shelly Main Light
232
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
233
+                 ot=TOPIC_FFE_KITCHEN_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
142
 
234
 
143
         # DININGROOM
235
         # DININGROOM
144
         roo = props.ROO_DIN
236
         roo = props.ROO_DIN
149
         TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG = "zigbee/ffe/diningroom/garland"
241
         TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG = "zigbee/ffe/diningroom/garland"
150
         TOPIC_FFE_DININGROOM_HEATING_VALVE_ZIGBEE = "zigbee/ffe/diningroom/heating_valve"
242
         TOPIC_FFE_DININGROOM_HEATING_VALVE_ZIGBEE = "zigbee/ffe/diningroom/heating_valve"
151
         # Temporary to fit to current implementation ###################################################
243
         # Temporary to fit to current implementation ###################################################
152
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY)            # Shelly Main Light
153
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_FLL, props.DTY_SPP_SW1, ot=TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)            # Powerplug Floor Light
154
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_GAR, props.DTY_SPP_SW1, ot=TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)            # Powerplug Garland
155
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_FFE_DININGROOM_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
244
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
245
+                 ot=TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY)            # Shelly Main Light
246
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_FLL, props.DTY_SPP_SW1,
247
+                 ot=TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)            # Powerplug Floor Light
248
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_GAR, props.DTY_SPP_SW1,
249
+                 ot=TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)            # Powerplug Garland
250
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
251
+                 ot=TOPIC_FFE_DININGROOM_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
156
 
252
 
157
         # SLEEP
253
         # SLEEP
158
         roo = props.ROO_SLP
254
         roo = props.ROO_SLP
165
         TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG = "zigbee/ffe/sleep/bed_light_ma"
261
         TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG = "zigbee/ffe/sleep/bed_light_ma"
166
         TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE = "zigbee/ffe/sleep/heating_valve"
262
         TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE = "zigbee/ffe/sleep/heating_valve"
167
         # Temporary to fit to current implementation ###################################################
263
         # Temporary to fit to current implementation ###################################################
168
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY)            # Shelly Main Light
169
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT, ot=TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
170
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_INP, props.DTY_TIN_5xx, ot=TOPIC_FFE_SLEEP_INPUT_DEVICE)            # Tradfri Input Device 5 Buttons
171
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_BLD, props.DTY_TLI_SBx, ot=TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE)            # Tradfri Bed Light Dirk
172
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_BLM, props.DTY_SPP_SW1, ot=TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG)            # Powerplug Bed Light Marion
173
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
264
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
265
+                 ot=TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY)            # Shelly Main Light
266
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT,
267
+                 ot=TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE)            # Tradfri Main Light
268
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_INP, props.DTY_TIN_5xx,
269
+                 ot=TOPIC_FFE_SLEEP_INPUT_DEVICE)            # Tradfri Input Device 5 Buttons
270
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_BLD, props.DTY_TLI_SBx,
271
+                 ot=TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE)            # Tradfri Bed Light Dirk
272
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_BLM, props.DTY_SPP_SW1,
273
+                 ot=TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG)            # Powerplug Bed Light Marion
274
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
275
+                 ot=TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE)            # Brennenstuhl Heatingvalve
174
 
276
 
175
         # LIVINGROOM
277
         # LIVINGROOM
176
         roo = props.ROO_LIV
278
         roo = props.ROO_LIV
183
         TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG = "zigbee/ffe/livingroom/powerplug_xmas-star"
285
         TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG = "zigbee/ffe/livingroom/powerplug_xmas-star"
184
         TOPIC_FFE_LIVINGROOM_HEATING_VALVE_ZIGBEE = "zigbee/ffe/livingroom/heating_valve"
286
         TOPIC_FFE_LIVINGROOM_HEATING_VALVE_ZIGBEE = "zigbee/ffe/livingroom/heating_valve"
185
         # Temporary to fit to current implementation ###################################################
287
         # Temporary to fit to current implementation ###################################################
186
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY)                 # Shelly Main Light
187
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT, ot=TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE)                 # Tradfri Main Light
188
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_FLL, props.DTY_TLI_SBT, range(1, 7), ot=TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE)    # Tradfri Main Light
189
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_XTR, props.DTY_SPP_SW1, ot=TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)               # Tradfri Main Light
190
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_XST, props.DTY_SPP_SW1, ot=TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)               # Tradfri Main Light
191
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx, ot=TOPIC_FFE_LIVINGROOM_HEATING_VALVE_ZIGBEE)              # Brennenstuhl Heatingvalve
288
+        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1,
289
+                 ot=TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY)                 # Shelly Main Light
290
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT,
291
+                 ot=TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE)                 # Tradfri Main Light
292
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_FLL, props.DTY_TLI_SBT,
293
+                 range(1, 7), ot=TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE)    # Tradfri Main Light
294
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_XTR, props.DTY_SPP_SW1,
295
+                 ot=TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)               # Tradfri Main Light
296
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_XST, props.DTY_SPP_SW1,
297
+                 ot=TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)               # Tradfri Main Light
298
+        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx,
299
+                 ot=TOPIC_FFE_LIVINGROOM_HEATING_VALVE_ZIGBEE)              # Brennenstuhl Heatingvalve
192
 
300
 
193
     def __init_stw__(self, mqtt_client):
301
     def __init_stw__(self, mqtt_client):
194
         loc = props.LOC_STW
302
         loc = props.LOC_STW
199
         TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF = "zigbee/ffe/stairway/motion_sensor_ff"
307
         TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF = "zigbee/ffe/stairway/motion_sensor_ff"
200
         TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF = "zigbee/gfw/stairway/motion_sensor_gf"
308
         TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF = "zigbee/gfw/stairway/motion_sensor_gf"
201
         # Temporary to fit to current implementation ###################################################
309
         # Temporary to fit to current implementation ###################################################
202
-        self.add(mqtt_client, props.STG_SHE, loc, props.ROO_STF, props.FUN_MAL, props.DTY_SHY_SW1, ot=TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY)            # Shelly Main Light
203
-        self.add(mqtt_client, props.STG_ZFE, loc, props.ROO_STF, props.FUN_MSE, props.DTY_SMS_xxx, ot=TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF)    # Motion Sensor First Floor
204
-        self.add(mqtt_client, props.STG_ZGW, loc, props.ROO_STG, props.FUN_MSE, props.DTY_SMS_xxx, ot=TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF)            # Motion Sensor Ground Floor
310
+        self.add(mqtt_client, props.STG_SHE, loc, props.ROO_STF, props.FUN_MAL, props.DTY_SHY_SW1,
311
+                 ot=TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY)            # Shelly Main Light
312
+        self.add(mqtt_client, props.STG_ZFE, loc, props.ROO_STF, props.FUN_MSE, props.DTY_SMS_xxx,
313
+                 ot=TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF)    # Motion Sensor First Floor
314
+        self.add(mqtt_client, props.STG_ZGW, loc, props.ROO_STG, props.FUN_MSE, props.DTY_SMS_xxx,
315
+                 ot=TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF)            # Motion Sensor Ground Floor
205
 
316
 
206
-    def add(self, mqtt_client, stg, loc, roo, fun, dty, num=None, ot=None):
207
-        """Method to initilise a device
208
 
317
 
209
-        Args:
210
-            stg (numeric): Source transmittion group (see SIS_* in props)
211
-            loc (numeric): Location (see LOC_* in props)
212
-            roo (numeric): Room (see ROO_* in props)
213
-            fun (numeric): Function (see FUN_* in props)
214
-            dty (numeric): Device type (see DTP_* in props)
215
-            num (numeric): Device number in case of multiple devices
216
-        """
217
-        def get_device(dty, mqtt_client, topic, ot):
218
-            # Temporary to fit to current implementation
219
-            if ot != topic:
220
-                logger.error("Topic change for %s: Using this one: %s", topic, ot)
221
-                topic = ot
222
-            dev_class = props.dty_repr(dty)
223
-            if dev_class is None:
224
-                logger.warning('Device type %d is not yet implemented. Topic %s will not be supported.', dty, topic)
225
-            else:
226
-                return dev_class(mqtt_client, topic)
318
+class videv_devices(base):
319
+    """
320
+    Class to create and store videv smarthome devices
321
+    """
227
 
322
 
228
-        topic = self.__topic__(stg, loc, roo, fun)
229
-        if num is None:
230
-            this_device = get_device(dty, mqtt_client, topic, ot)
231
-            if this_device is None:
232
-                logger.warning('Device type %d is not yet implemented. Topic %s will not be supported.', dty, topic)
233
-            else:
234
-                self[topic] = this_device
235
-        else:
236
-            dg = []
237
-            for i in num:
238
-                device_topic = self.__topic__(stg, loc, roo, fun) + '_%d' % i
239
-                dg.append(get_device(dty, mqtt_client, device_topic, ot=ot % i))
240
-            self[topic] = group(*dg)
323
+    def __init__(self, mqtt_client):
324
+        super().__init__(self)
325
+        self.__init_gfw__(mqtt_client)
326
+        self.__init_ffw__(mqtt_client)
327
+        self.__init_ffe__(mqtt_client)
328
+        self.__init_stw__(mqtt_client)
241
 
329
 
242
-    def get(self, stg, loc, roo, fun):
243
-        """Method to get a device
330
+    def __init_gfw__(self, mqtt_client):
331
+        loc = props.LOC_GFW
332
+        # TODO: Add devices
244
 
333
 
245
-        Args:
246
-            stg (numeric): Source transmittion group (see SIS_* in props)
247
-            loc (numeric): Location (see LOC_* in props)
248
-            roo (numeric): Room (see ROO_* in props)
249
-            fun (numeric): Function (see FUN_* in props)
250
-            num (numeric): Device number in case of multiple devices
251
-        """
252
-        topic = self.__topic__(stg, loc, roo, fun)
253
-        return self[topic]
334
+    def __init_ffw__(self, mqtt_client):
335
+        loc = props.LOC_FFW
336
+        # TODO: Add devices
254
 
337
 
255
-    def __topic__(self, stg, loc, roo, fun):
256
-        if stg in [props.STG_ZFE, props.STG_ZFW, props.STG_ZGW]:
257
-            # Temporary to fit to current implementation
258
-            return '/'.join([
259
-                props.stg_repr(stg),
260
-                props.roo_repr(roo),
261
-                props.fun_repr(fun)
262
-            ])
263
-        else:
264
-            return '/'.join([
265
-                props.stg_repr(stg),
266
-                props.loc_repr(loc),
267
-                props.roo_repr(roo),
268
-                props.fun_repr(fun)
269
-            ])
338
+    def __init_ffe__(self, mqtt_client):
339
+        loc = props.LOC_FFE
340
+        # TODO: Add devices
341
+
342
+    def __init_stw__(self, mqtt_client):
343
+        loc = props.LOC_STW
344
+        # TODO: Add devices

Loading…
Cancel
Save