devdi: Change to non tmp topics for all existing devices

This commit is contained in:
Dirk Alders 2024-08-20 11:47:08 +02:00
parent fc1f86ab5a
commit 4cdab5a4e3
2 changed files with 6 additions and 44 deletions

View File

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

View File

@ -135,53 +135,13 @@ FUN_DCK = 19
class topic_by_props(UserString):
def __init__(self, stg, loc, roo, fun):
if stg in [STG_ZFE, STG_ZFW, STG_ZGW]:
# TODO: Temporary to fit to current implementation
topic = '/'.join([
self.__stg_repr__(stg),
self.__roo_repr__(roo),
self.__fun_repr__(fun)
])
else:
topic = '/'.join([
self.__stg_repr__(stg),
self.__loc_repr__(loc),
self.__roo_repr__(roo),
self.__fun_repr__(fun)
])
UserString.__init__(self, self.__tmp_old_topics__(stg, loc, roo, fun) or topic)
def __tmp_old_topics__(self, stg, loc, roo, fun):
# TODO: Temporary to fit to current implementation
if stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_RCA:
return "my_apps/gfw/dirk/remote/RAS5"
elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASS:
return "my_apps/gfw/dirk/hifi/spotify"
elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASM:
return "my_apps/gfw/dirk/hifi/mpd"
elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASB:
return "my_apps/gfw/dirk/hifi/btaudio"
elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_DIN and fun == FUN_FLL:
return "zigbee/ffe/diningroom/powerplug_floorlamp"
elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_FLL:
return "zigbee/ffe/livingroom/floorlamp"
elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_XTR:
return "zigbee/ffe/livingroom/powerplug_xmas-tree"
elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_XST:
return "zigbee/ffe/livingroom/powerplug_xmas-star"
elif stg == STG_SHE and loc == LOC_STW and roo == ROO_STF and fun == FUN_MAL:
return "shellies/stw/stairway/main_light"
elif stg == STG_ZFE and loc == LOC_STW and roo == ROO_STF and fun == FUN_MSE:
return "zigbee/ffe/stairway/motion_sensor_ff"
elif stg == STG_ZGW and loc == LOC_STW and roo == ROO_STG and fun == FUN_MSE:
return "zigbee/gfw/stairway/motion_sensor_gf"
UserString.__init__(self, '/'.join([self.__stg_repr__(stg), self.__loc_repr__(loc), self.__roo_repr__(roo), self.__fun_repr__(fun)]))
def __stg_repr__(self, stg):
return {
STG_ZGW: 'zigbee/gfw', # TODO: -> zigbee_gfw
STG_ZFW: 'zigbee/ffw', # TODO: -> zigbee_ffw
STG_ZFE: 'zigbee/ffe', # TODO: -> zigbee_ffe
STG_ZGW: 'zigbee_gfw',
STG_ZFW: 'zigbee_ffw',
STG_ZFE: 'zigbee_ffe',
STG_SHE: 'shellies',
STG_MYA: 'my_apps',
}.get(stg)