Device definitions and intialisation
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

topic.py 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. from collections import UserString
  2. #
  3. # Device TYpe definitions
  4. #
  5. DTY_SHY_SW1 = 1
  6. """ Shelly """
  7. DTY_TLI_Sxx = 2
  8. """ Tradfri Light (Switching only) """
  9. DTY_TLI_SBx = 3
  10. """ Tradfri Light (Switching and Brightnes) """
  11. DTY_TLI_SBT = 4
  12. """ Tradfri Light (Switching, Brightnes and Colortemperature) """
  13. DTY_TIN_5xx = 5
  14. """ Tradfri Input Device (5 Buttons) """
  15. DTY_LLI_SBT = 6
  16. """ Livarno Light (Switching, Brightnes and Colortemperature) """
  17. DTY_BVL_xxx = 7
  18. """ Brennenstuhl Heatingvalve """
  19. DTY_SPP_SW1 = 8
  20. """ Silvercrest Powerplug """
  21. DTY_SMS_xxx = 9
  22. """ Silvercrest Motion Sensor """
  23. DTY_MPP_4xx = 10
  24. """ My Powerplug (4 plugs) """
  25. DTY_MAS_xxx = 11
  26. """ My Audio status (MPD) """
  27. DTY_MRE_xxx = 12
  28. """ My Remote control """
  29. #
  30. # Source Transmission Group
  31. #
  32. STG_ZGW = 1
  33. """ Zigbee ground floor west """
  34. STG_ZFW = 2
  35. """ Zigbee first floor west """
  36. STG_ZFE = 3
  37. """ Zigbee first floor east """
  38. STG_SHE = 4
  39. """ Shellies """
  40. STG_MYA = 5
  41. """ My Applications """
  42. #
  43. # LOCation
  44. #
  45. LOC_GFW = 1
  46. """ Grounf floor west """
  47. LOC_GFE = 2
  48. """ Ground floor east """
  49. LOC_STW = 3
  50. """ Stairway """
  51. LOC_FFW = 4
  52. """ First floor west """
  53. LOC_FFE = 5
  54. """ First floor east """
  55. LOC_STW = 6
  56. """ Stairways """
  57. LOC_GAR = 7
  58. #
  59. # ROOms
  60. #
  61. ROO_DIN = 1
  62. """ Diningroom """
  63. ROO_KIT = 2
  64. """ Kitchen """
  65. ROO_LIV = 3
  66. """ Livingroom """
  67. ROO_FLO = 4
  68. """ Floor """
  69. ROO_SLP = 5
  70. """ Sleep """
  71. ROO_BAT = 6
  72. """ Bath """
  73. ROO_DIR = 7
  74. """ Dirk """
  75. ROO_MAR = 8
  76. """ Marion """
  77. ROO_JUL = 9
  78. """ Julian """
  79. ROO_STG = 10
  80. """ ground floor """
  81. ROO_STF = 11
  82. """ first floor """
  83. ROO_GAR = 12
  84. """ garden """
  85. #
  86. # FUNctions
  87. #
  88. FUN_MAL = 1
  89. """ Main Light """
  90. FUN_DEL = 2
  91. """ Desk Light """
  92. FUN_FLL = 3
  93. """ Floor Light """
  94. FUN_BLD = 4
  95. """ Bed Light Dirk """
  96. FUN_BLM = 5
  97. """ Bed Light Marion """
  98. FUN_HEA = 6
  99. """ Heating """
  100. FUN_MPP = 7
  101. """ Multiple Powerplugs """
  102. FUN_INP = 8
  103. """ Input Device """
  104. FUN_CIR = 9
  105. """ Circulation Pump """
  106. FUN_GAR = 10
  107. """ Garland """
  108. FUN_XTR = 11
  109. """ X-Mas Tree """
  110. FUN_XST = 12
  111. """ X-Mas Star """
  112. FUN_MSE = 13
  113. """ Motion Sensor """
  114. FUN_RCA = 14
  115. """ Remote Control Amplifier """
  116. FUN_RCC = 15
  117. """ Remote Control CD-Player """
  118. FUN_ASS = 16
  119. """ Audio status spotify """
  120. FUN_ASM = 17
  121. """ Audio status mpd """
  122. class topic_by_props(UserString):
  123. def __init__(self, stg, loc, roo, fun):
  124. if stg in [STG_ZFE, STG_ZFW, STG_ZGW]:
  125. # TODO: Temporary to fit to current implementation
  126. topic = '/'.join([
  127. self.__stg_repr__(stg),
  128. self.__roo_repr__(roo),
  129. self.__fun_repr__(fun)
  130. ])
  131. else:
  132. topic = '/'.join([
  133. self.__stg_repr__(stg),
  134. self.__loc_repr__(loc),
  135. self.__roo_repr__(roo),
  136. self.__fun_repr__(fun)
  137. ])
  138. UserString.__init__(self, self.__tmp_old_topics__(stg, loc, roo, fun) or topic)
  139. def __tmp_old_topics__(self, stg, loc, roo, fun):
  140. # TODO: Temporary to fit to current implementation
  141. if stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_RCA:
  142. return "my_apps/gfw/dirk/remote/RAS5"
  143. elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASS:
  144. return "my_apps/gfw/dirk/hifi/spotify"
  145. elif stg == STG_MYA and loc == LOC_GFW and roo == ROO_DIR and fun == FUN_ASM:
  146. return "my_apps/gfw/dirk/hifi/mpd"
  147. elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_DIN and fun == FUN_FLL:
  148. return "zigbee/ffe/diningroom/powerplug_floorlamp"
  149. elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_FLL:
  150. return "zigbee/ffe/livingroom/floorlamp"
  151. elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_XTR:
  152. return "zigbee/ffe/livingroom/powerplug_xmas-tree"
  153. elif stg == STG_ZFE and loc == LOC_FFE and roo == ROO_LIV and fun == FUN_XST:
  154. return "zigbee/ffe/livingroom/powerplug_xmas-star"
  155. elif stg == STG_SHE and loc == LOC_STW and roo == ROO_STF and fun == FUN_MAL:
  156. return "shellies/stw/stairway/main_light"
  157. elif stg == STG_ZFE and loc == LOC_STW and roo == ROO_STF and fun == FUN_MSE:
  158. return "zigbee/ffe/stairway/motion_sensor_ff"
  159. elif stg == STG_ZGW and loc == LOC_STW and roo == ROO_STG and fun == FUN_MSE:
  160. return "zigbee/gfw/stairway/motion_sensor_gf"
  161. def __stg_repr__(self, stg):
  162. return {
  163. STG_ZGW: 'zigbee/gfw', # TODO: -> zigbee_gfw
  164. STG_ZFW: 'zigbee/ffw', # TODO: -> zigbee_ffw
  165. STG_ZFE: 'zigbee/ffe', # TODO: -> zigbee_ffe
  166. STG_SHE: 'shellies',
  167. STG_MYA: 'my_apps',
  168. }.get(stg)
  169. def __loc_repr__(self, loc):
  170. return {
  171. LOC_GFW: 'gfw',
  172. LOC_GFE: 'gfe',
  173. LOC_STW: 'stw',
  174. LOC_FFW: 'ffw',
  175. LOC_FFE: 'ffe',
  176. LOC_STW: 'stw',
  177. LOC_GAR: 'gar',
  178. }.get(loc)
  179. def __roo_repr__(self, roo):
  180. return {
  181. ROO_DIN: 'diningroom',
  182. ROO_KIT: 'kitchen',
  183. ROO_LIV: 'livingroom',
  184. ROO_FLO: 'floor',
  185. ROO_SLP: 'sleep',
  186. ROO_BAT: 'bath',
  187. ROO_DIR: 'dirk',
  188. ROO_MAR: 'marion',
  189. ROO_JUL: 'julian',
  190. ROO_STG: 'groundfloor',
  191. ROO_STF: 'firstfloor',
  192. ROO_GAR: 'garden',
  193. }.get(roo)
  194. def __fun_repr__(self, fun):
  195. return {
  196. FUN_MAL: 'main_light',
  197. FUN_DEL: 'desk_light',
  198. FUN_FLL: 'floor_light',
  199. FUN_BLD: 'bed_light_di',
  200. FUN_BLM: 'bed_light_ma',
  201. FUN_HEA: 'heating_valve',
  202. FUN_MPP: 'powerplug',
  203. FUN_INP: 'input_device',
  204. FUN_CIR: 'circulation_pump',
  205. FUN_GAR: 'garland',
  206. FUN_XTR: 'xmas-tree',
  207. FUN_XST: 'xmas-star',
  208. FUN_MSE: 'motion_sensor',
  209. FUN_RCA: 'remote_ctrl_amp',
  210. FUN_RCC: 'remote_ctrl_cd',
  211. FUN_ASS: 'audio_status_spotify',
  212. FUN_ASM: 'audio_status_mpd',
  213. }.get(fun)