123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- from collections import UserString
-
- #
- # Device TYpe definitions
- #
- DTY_SHY_SW1 = 1
- """ Shelly """
- DTY_TLI_Sxx = 2
- """ Tradfri Light (Switching only) """
- DTY_TLI_SBx = 3
- """ Tradfri Light (Switching and Brightnes) """
- DTY_TLI_SBT = 4
- """ Tradfri Light (Switching, Brightnes and Colortemperature) """
- DTY_TIN_5xx = 5
- """ Tradfri Input Device (5 Buttons) """
- DTY_LLI_SBT = 6
- """ Livarno Light (Switching, Brightnes and Colortemperature) """
- DTY_BVL_xxx = 7
- """ Brennenstuhl Heatingvalve """
- DTY_SPP_SW1 = 8
- """ Silvercrest Powerplug """
- DTY_SMS_xxx = 9
- """ Silvercrest Motion Sensor """
- DTY_MPP_4xx = 10
- """ My Powerplug (4 plugs) """
- DTY_MAS_xxx = 11
- """ My Audio status (MPD) """
- DTY_MRE_xxx = 12
- """ My Remote control """
-
-
- #
- # Source Transmission Group
- #
- STG_ZGW = 1
- """ Zigbee ground floor west """
- STG_ZFW = 2
- """ Zigbee first floor west """
- STG_ZFE = 3
- """ Zigbee first floor east """
- STG_SHE = 4
- """ Shellies """
- STG_MYA = 5
- """ My Applications """
-
-
- #
- # LOCation
- #
- LOC_GFW = 1
- """ Grounf floor west """
- LOC_GFE = 2
- """ Ground floor east """
- LOC_STW = 3
- """ Stairway """
- LOC_FFW = 4
- """ First floor west """
- LOC_FFE = 5
- """ First floor east """
- LOC_STW = 6
- """ Stairways """
- LOC_GAR = 7
-
-
- #
- # ROOms
- #
- ROO_DIN = 1
- """ Diningroom """
- ROO_KIT = 2
- """ Kitchen """
- ROO_LIV = 3
- """ Livingroom """
- ROO_FLO = 4
- """ Floor """
- ROO_SLP = 5
- """ Sleep """
- ROO_BAT = 6
- """ Bath """
- ROO_DIR = 7
- """ Dirk """
- ROO_MAR = 8
- """ Marion """
- ROO_JUL = 9
- """ Julian """
- ROO_STG = 10
- """ ground floor """
- ROO_STF = 11
- """ first floor """
- ROO_GAR = 12
- """ garden """
-
-
- #
- # FUNctions
- #
- FUN_MAL = 1
- """ Main Light """
- FUN_DEL = 2
- """ Desk Light """
- FUN_FLL = 3
- """ Floor Light """
- FUN_BLD = 4
- """ Bed Light Dirk """
- FUN_BLM = 5
- """ Bed Light Marion """
- FUN_HEA = 6
- """ Heating """
- FUN_MPP = 7
- """ Multiple Powerplugs """
- FUN_INP = 8
- """ Input Device """
- FUN_CIR = 9
- """ Circulation Pump """
- FUN_GAR = 10
- """ Garland """
- FUN_XTR = 11
- """ X-Mas Tree """
- FUN_XST = 12
- """ X-Mas Star """
- FUN_MSE = 13
- """ Motion Sensor """
- FUN_RCA = 14
- """ Remote Control Amplifier """
- FUN_RCC = 15
- """ Remote Control CD-Player """
- FUN_ASS = 16
- """ Audio status spotify """
- FUN_ASM = 17
- """ Audio status mpd """
-
-
- 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_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"
-
- 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_SHE: 'shellies',
- STG_MYA: 'my_apps',
- }.get(stg)
-
- def __loc_repr__(self, loc):
- return {
- LOC_GFW: 'gfw',
- LOC_GFE: 'gfe',
- LOC_STW: 'stw',
- LOC_FFW: 'ffw',
- LOC_FFE: 'ffe',
- LOC_STW: 'stw',
- LOC_GAR: 'gar',
- }.get(loc)
-
- def __roo_repr__(self, roo):
- return {
- ROO_DIN: 'diningroom',
- ROO_KIT: 'kitchen',
- ROO_LIV: 'livingroom',
- ROO_FLO: 'floor',
- ROO_SLP: 'sleep',
- ROO_BAT: 'bath',
- ROO_DIR: 'dirk',
- ROO_MAR: 'marion',
- ROO_JUL: 'julian',
- ROO_STG: 'groundfloor',
- ROO_STF: 'firstfloor',
- ROO_GAR: 'garden',
- }.get(roo)
-
- def __fun_repr__(self, fun):
- return {
- FUN_MAL: 'main_light',
- FUN_DEL: 'desk_light',
- FUN_FLL: 'floor_light',
- FUN_BLD: 'bed_light_di',
- FUN_BLM: 'bed_light_ma',
- FUN_HEA: 'heating_valve',
- FUN_MPP: 'powerplug',
- FUN_INP: 'input_device',
- FUN_CIR: 'circulation_pump',
- FUN_GAR: 'garland',
- FUN_XTR: 'xmas-tree',
- FUN_XST: 'xmas-star',
- FUN_MSE: 'motion_sensor',
- FUN_RCA: 'remote_ctrl_amp',
- FUN_RCC: 'remote_ctrl_cd',
- FUN_ASS: 'audio_status_spotify',
- FUN_ASM: 'audio_status_mpd',
- }.get(fun)
|