Browse Source

devdi: Change to non tmp topics for all existing devices

master
Dirk Alders 4 months ago
parent
commit
4cdab5a4e3
2 changed files with 6 additions and 44 deletions
  1. 2
    0
      devices.py
  2. 4
    44
      topic.py

+ 2
- 0
devices.py View File

@@ -59,12 +59,14 @@ class base(dict):
59 59
                 logger.warning('Device type %d is not yet implemented. Topic %s will not be supported.', dty, topic)
60 60
             else:
61 61
                 self[topic] = this_device
62
+                logger.debug("Added a device type=%s, topic=%s", dty, topic)
62 63
         else:
63 64
             dg = []
64 65
             for i in range(1, num + 1):
65 66
                 device_topic = topic + '_%d' % i
66 67
                 dg.append(get_device(dty, mqtt_client, device_topic))
67 68
             self[topic] = devices.group(*dg)
69
+            logger.debug("Added a devicegroup type=%s, topic=%s", dty, topic + '_<num>')
68 70
 
69 71
     def get(self, stg, loc, roo, fun):
70 72
         """Method to get a device

+ 4
- 44
topic.py View File

@@ -135,53 +135,13 @@ FUN_DCK = 19
135 135
 
136 136
 class topic_by_props(UserString):
137 137
     def __init__(self, stg, loc, roo, fun):
138
-        if stg in [STG_ZFE, STG_ZFW, STG_ZGW]:
139
-            # TODO: Temporary to fit to current implementation
140
-            topic = '/'.join([
141
-                self.__stg_repr__(stg),
142
-                self.__roo_repr__(roo),
143
-                self.__fun_repr__(fun)
144
-            ])
145
-        else:
146
-            topic = '/'.join([
147
-                self.__stg_repr__(stg),
148
-                self.__loc_repr__(loc),
149
-                self.__roo_repr__(roo),
150
-                self.__fun_repr__(fun)
151
-            ])
152
-
153
-        UserString.__init__(self, self.__tmp_old_topics__(stg, loc, roo, fun) or topic)
154
-
155
-    def __tmp_old_topics__(self, stg, loc, roo, fun):
156
-        # TODO: Temporary to fit to current implementation
157
-        if stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_RCA:
158
-            return "my_apps/gfw/dirk/remote/RAS5"
159
-        elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASS:
160
-            return "my_apps/gfw/dirk/hifi/spotify"
161
-        elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASM:
162
-            return "my_apps/gfw/dirk/hifi/mpd"
163
-        elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASB:
164
-            return "my_apps/gfw/dirk/hifi/btaudio"
165
-        elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_DIN and fun == FUN_FLL:
166
-            return "zigbee/ffe/diningroom/powerplug_floorlamp"
167
-        elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_FLL:
168
-            return "zigbee/ffe/livingroom/floorlamp"
169
-        elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_XTR:
170
-            return "zigbee/ffe/livingroom/powerplug_xmas-tree"
171
-        elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_XST:
172
-            return "zigbee/ffe/livingroom/powerplug_xmas-star"
173
-        elif stg == STG_SHE and loc == LOC_STW and roo == ROO_STF and fun == FUN_MAL:
174
-            return "shellies/stw/stairway/main_light"
175
-        elif stg == STG_ZFE and loc == LOC_STW and roo == ROO_STF and fun == FUN_MSE:
176
-            return "zigbee/ffe/stairway/motion_sensor_ff"
177
-        elif stg == STG_ZGW and loc == LOC_STW and roo == ROO_STG and fun == FUN_MSE:
178
-            return "zigbee/gfw/stairway/motion_sensor_gf"
138
+        UserString.__init__(self, '/'.join([self.__stg_repr__(stg), self.__loc_repr__(loc), self.__roo_repr__(roo), self.__fun_repr__(fun)]))
179 139
 
180 140
     def __stg_repr__(self, stg):
181 141
         return {
182
-            STG_ZGW: 'zigbee/gfw',  # TODO: -> zigbee_gfw
183
-            STG_ZFW: 'zigbee/ffw',  # TODO: -> zigbee_ffw
184
-            STG_ZFE: 'zigbee/ffe',  # TODO: -> zigbee_ffe
142
+            STG_ZGW: 'zigbee_gfw',
143
+            STG_ZFW: 'zigbee_ffw',
144
+            STG_ZFE: 'zigbee_ffe',
185 145
             STG_SHE: 'shellies',
186 146
             STG_MYA: 'my_apps',
187 147
         }.get(stg)

Loading…
Cancel
Save