Browse Source

Adaption to support currently used topics

master
Dirk Alders 1 year ago
parent
commit
6d41c39ee3
2 changed files with 173 additions and 87 deletions
  1. 159
    79
      __init__.py
  2. 14
    8
      props.py

+ 159
- 79
__init__.py View File

3
 # -*- coding: utf-8 -*-
3
 # -*- coding: utf-8 -*-
4
 #
4
 #
5
 from devdi import props
5
 from devdi import props
6
+from devices import group
6
 import logging
7
 import logging
7
 import sys
8
 import sys
8
 
9
 
20
 
21
 
21
     def __init__(self, mqtt_client):
22
     def __init__(self, mqtt_client):
22
         dict.__init__(self)
23
         dict.__init__(self)
23
-        #######
24
-        # GFW #
25
-        #######
24
+        self.__init_gfw__(mqtt_client)
25
+        self.__init_ffw__(mqtt_client)
26
+        self.__init_ffe__(mqtt_client)
27
+        self.__init_stw__(mqtt_client)
28
+    
29
+    def __init_gfw__(self, mqtt_client):
26
         loc = props.LOC_GFW
30
         loc = props.LOC_GFW
27
 
31
 
28
         # MARION
32
         # MARION
29
         roo = props.ROO_MAR
33
         roo = props.ROO_MAR
30
         #
34
         #
31
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
32
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
35
+        # Temporary to fit to current implementation ###################################################
36
+        TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY = "shellies/gfw/marion/main_light"
37
+        TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE = "zigbee/gfw/marion/heating_valve"
38
+        # 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
33
 
41
 
34
         # FLOOR
42
         # FLOOR
35
         roo = props.ROO_FLO
43
         roo = props.ROO_FLO
36
         #
44
         #
37
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
38
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, props.DTY_LLI_SBT, 1)         # Tradfri Main Light
39
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, props.DTY_LLI_SBT, 2)         # Tradfri Main Light
45
+        # Temporary to fit to current implementation ###################################################
46
+        TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY = "shellies/gfw/floor/main_light"
47
+        TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE = "zigbee/gfw/floor/main_light_%d"
48
+        # 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
40
 
51
 
41
         # DIRK
52
         # DIRK
42
         roo = props.ROO_DIR
53
         roo = props.ROO_DIR
43
         #
54
         #
44
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
45
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT)            # Tradfri Main Light
46
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_CTR, props.DTY_TIN_5xx)            # Tradfri Input Device 5 Buttons
47
-        self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_MPP, props.DTY_MPP_4xx)            # My 4 port Powerplug
48
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_DEL, props.DTY_TLI_SBT)         ,  # Tradfri Desklight
49
-        self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_RCA, props.DTY_MRE_xxx)            # Remote Control IR Amplifier
50
-        self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_ASS, props.DTY_MAS_xxx)            # Audio status Spotify
51
-        self.add(mqtt_client, props.STG_MYA, loc, roo, props.FUN_ASM, props.DTY_MAS_xxx)            # Audio status MPD
52
-        self.add(mqtt_client, props.STG_ZGW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
53
-
54
-
55
-        #######
56
-        # FFW #
57
-        #######
55
+        # Temporary to fit to current implementation ###################################################
56
+        TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY = "shellies/gfw/dirk/main_light"
57
+        TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE = "zigbee/gfw/dirk/main_light"
58
+        TOPIC_GFW_DIRK_INPUT_DEVICE = "zigbee/gfw/dirk/input_device"
59
+        TOPIC_GFW_DIRK_POWERPLUG = "my_apps/gfw/dirk/powerplug"
60
+        TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE = "zigbee/gfw/dirk/desk_light"
61
+        TOPIC_GFW_DIRK_AMPLIFIER_REMOTE = "my_apps/gfw/dirk/remote/RAS5"
62
+        TOPIC_GFW_DIRK_SPOTIFY = "my_apps/gfw/dirk/hifi/spotify"
63
+        TOPIC_GFW_DIRK_MPD = "my_apps/gfw/dirk/hifi/mpd"
64
+        TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE = "zigbee/gfw/dirk/heating_valve"
65
+        # 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
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
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
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
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
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
75
+
76
+    def __init_ffw__(self, mqtt_client):
58
         loc = props.LOC_FFW
77
         loc = props.LOC_FFW
59
         # JULIAN
78
         # JULIAN
60
         roo = props.ROO_JUL
79
         roo = props.ROO_JUL
61
         #
80
         #
62
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
63
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT)            # Tradfri Main Light
64
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
81
+        # Temporary to fit to current implementation ###################################################
82
+        TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY = "shellies/ffw/julian/main_light"
83
+        TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/julian/main_light"
84
+        TOPIC_FFW_JULIAN_HEATING_VALVE_ZIGBEE = "zigbee/ffw/julian/heating_valve"
85
+        # 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
65
 
89
 
66
         # BATH
90
         # BATH
67
         roo = props.ROO_BAT
91
         roo = props.ROO_BAT
68
         #
92
         #
69
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
93
+        # Temporary to fit to current implementation
94
+        # Temporary to fit to current implementation ###################################################
95
+        TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE = "zigbee/ffw/bath/heating_valve"
96
+        # 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
70
 
98
 
71
         # LIVINGROOM
99
         # LIVINGROOM
72
         roo = props.ROO_LIV
100
         roo = props.ROO_LIV
73
         #
101
         #
74
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
75
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT)            # Tradfri Main Light
102
+        # Temporary to fit to current implementation ###################################################
103
+        TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY = "shellies/ffw/livingroom/main_light"
104
+        TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/livingroom/main_light"
105
+        # 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
76
 
108
 
77
         # SLEEP
109
         # SLEEP
78
         roo = props.ROO_SLP
110
         roo = props.ROO_SLP
79
         #
111
         #
80
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
81
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MAL, props.DTY_TLI_SBx)            # Tradfri Main Light
82
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
112
+        # Temporary to fit to current implementation ###################################################
113
+        TOPIC_FFW_SLEEP_MAIN_LIGHT_SHELLY = "shellies/ffw/sleep/main_light"
114
+        TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE = "zigbee/ffw/sleep/main_light"
115
+        TOPIC_FFW_SLEEP_HEATING_VALVE_ZIGBEE = "zigbee/ffw/sleep/heating_valve"
116
+        # 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
83
 
120
 
84
-        #######
85
-        # FFE #
86
-        #######
121
+    def __init_ffe__(self, mqtt_client):
87
         loc = props.LOC_FFE
122
         loc = props.LOC_FFE
88
         # FLOOR
123
         # FLOOR
89
         roo = props.ROO_FLO
124
         roo = props.ROO_FLO
90
         #
125
         #
91
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
126
+        # Temporary to fit to current implementation ###################################################
127
+        TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY = "shellies/ffe/floor/main_light"
128
+        # 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
92
 
130
 
93
         # KITCHEN
131
         # KITCHEN
94
         roo = props.ROO_KIT
132
         roo = props.ROO_KIT
95
         #
133
         #
96
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
97
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_CIR, props.DTY_SHY_SW1)            # Shelly Main Light
98
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
134
+        # Temporary to fit to current implementation ###################################################
135
+        TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY = "shellies/ffe/kitchen/main_light"
136
+        TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY = "shellies/ffe/kitchen/circulation_pump"
137
+        TOPIC_FFE_KITCHEN_HEATING_VALVE_ZIGBEE = "zigbee/ffe/kitchen/heating_valve"
138
+        # 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
99
 
142
 
100
         # DININGROOM
143
         # DININGROOM
101
         roo = props.ROO_DIN
144
         roo = props.ROO_DIN
102
         #
145
         #
103
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
104
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_FLL, props.DTY_SPP_SW1)            # Powerplug Floor Light
105
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_GAR, props.DTY_SPP_SW1)            # Powerplug Garland
106
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
146
+        # Temporary to fit to current implementation ###################################################
147
+        TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY = "shellies/ffe/diningroom/main_light"
148
+        TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG = "zigbee/ffe/diningroom/powerplug_floorlamp"
149
+        TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG = "zigbee/ffe/diningroom/garland"
150
+        TOPIC_FFE_DININGROOM_HEATING_VALVE_ZIGBEE = "zigbee/ffe/diningroom/heating_valve"
151
+        # 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
107
 
156
 
108
         # SLEEP
157
         # SLEEP
109
         roo = props.ROO_SLP
158
         roo = props.ROO_SLP
110
         #
159
         #
111
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
112
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT)            # Tradfri Main Light
113
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_CTR, props.DTY_TIN_5xx)            # Tradfri Input Device 5 Buttons
114
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_BLD, props.DTY_TLI_SBx)            # Tradfri Bed Light Dirk
115
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_BLM, props.DTY_SPP_SW1)            # Powerplug Bed Light Marion
116
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
160
+        # Temporary to fit to current implementation ###################################################
161
+        TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY = "shellies/ffe/sleep/main_light"
162
+        TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE = "zigbee/ffe/sleep/main_light"
163
+        TOPIC_FFE_SLEEP_INPUT_DEVICE = "zigbee/ffe/sleep/input_device"
164
+        TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE = "zigbee/ffe/sleep/bed_light_di"
165
+        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"
167
+        # 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
117
 
174
 
118
         # LIVINGROOM
175
         # LIVINGROOM
119
         roo = props.ROO_LIV
176
         roo = props.ROO_LIV
120
         #
177
         #
121
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
122
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MAL, props.DTY_TLI_SBT)            # Tradfri Main Light
123
-        for i in range(1, 7):
124
-            self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_FLL, props.DTY_TLI_SBT, i)     # Tradfri Main Light
125
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_XTR, props.DTY_SPP_SW1)            # Tradfri Main Light
126
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_XST, props.DTY_SPP_SW1)            # Tradfri Main Light
127
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_HEA, props.DTY_BVL_xxx)            # Brennenstuhl Heatingvalve
128
-
129
-        #######
130
-        # STW #
131
-        #######
178
+        # Temporary to fit to current implementation ###################################################
179
+        TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY = "shellies/ffe/livingroom/main_light"
180
+        TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE = "zigbee/ffe/livingroom/main_light"
181
+        TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE = "zigbee/ffe/livingroom/floorlamp_%d"
182
+        TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG = "zigbee/ffe/livingroom/powerplug_xmas-tree"
183
+        TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG = "zigbee/ffe/livingroom/powerplug_xmas-star"
184
+        TOPIC_FFE_LIVINGROOM_HEATING_VALVE_ZIGBEE = "zigbee/ffe/livingroom/heating_valve"
185
+        # 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
192
+
193
+    def __init_stw__(self, mqtt_client):
132
         loc = props.LOC_STW
194
         loc = props.LOC_STW
133
         # FLOOR
195
         # FLOOR
134
-        roo = props.ROO_STW
135
         #
196
         #
136
-        self.add(mqtt_client, props.STG_SHE, loc, roo, props.FUN_MAL, props.DTY_SHY_SW1)            # Shelly Main Light
137
-        self.add(mqtt_client, props.STG_ZFW, loc, roo, props.FUN_MSE, props.DTY_SMS_xxx, 1)         # Motion Sensor Ground Floor
138
-        self.add(mqtt_client, props.STG_ZFE, loc, roo, props.FUN_MSE, props.DTY_SMS_xxx, 2)         # Motion Sensor Ground Floor
197
+        # Temporary to fit to current implementation ###################################################
198
+        TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY = "shellies/stw/stairway/main_light"
199
+        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"
201
+        # 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
139
 
205
 
140
-    def add(self, mqtt_client, stg, loc, roo, fun, dty, num=None):
206
+    def add(self, mqtt_client, stg, loc, roo, fun, dty, num=None, ot=None):
141
         """Method to initilise a device
207
         """Method to initilise a device
142
 
208
 
143
         Args:
209
         Args:
148
             dty (numeric): Device type (see DTP_* in props)
214
             dty (numeric): Device type (see DTP_* in props)
149
             num (numeric): Device number in case of multiple devices
215
             num (numeric): Device number in case of multiple devices
150
         """
216
         """
151
-        topic = self.__topic__(stg, loc, roo, fun, num)
152
-        dev_class = props.dty_repr(dty)
153
-        if dev_class is None:
154
-            logger.warning('Device type %d is not yet implemented. Topic %s will not be supported.', dty, topic)
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)
227
+
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
155
         else:
235
         else:
156
-            self[topic] = dev_class(mqtt_client, topic)
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)
157
 
241
 
158
-    def get(self, stg, loc, roo, fun, num=None):
242
+    def get(self, stg, loc, roo, fun):
159
         """Method to get a device
243
         """Method to get a device
160
 
244
 
161
         Args:
245
         Args:
165
             fun (numeric): Function (see FUN_* in props)
249
             fun (numeric): Function (see FUN_* in props)
166
             num (numeric): Device number in case of multiple devices
250
             num (numeric): Device number in case of multiple devices
167
         """
251
         """
168
-        return self[self.__topic__(stg, loc, roo, fun, num)]
252
+        topic = self.__topic__(stg, loc, roo, fun)
253
+        return self[topic]
169
 
254
 
170
-    def __topic__(self, stg, loc, roo, fun, num):
171
-        if num is None:
172
-            postfix = ""
173
-        else:
174
-            postfix = "_%d" % num
175
-        #
255
+    def __topic__(self, stg, loc, roo, fun):
176
         if stg in [props.STG_ZFE, props.STG_ZFW, props.STG_ZGW]:
256
         if stg in [props.STG_ZFE, props.STG_ZFW, props.STG_ZGW]:
177
             # Temporary to fit to current implementation
257
             # Temporary to fit to current implementation
178
             return '/'.join([
258
             return '/'.join([
179
                 props.stg_repr(stg),
259
                 props.stg_repr(stg),
180
                 props.roo_repr(roo),
260
                 props.roo_repr(roo),
181
                 props.fun_repr(fun)
261
                 props.fun_repr(fun)
182
-            ]) + postfix
262
+            ])
183
         else:
263
         else:
184
             return '/'.join([
264
             return '/'.join([
185
                 props.stg_repr(stg),
265
                 props.stg_repr(stg),
186
                 props.loc_repr(loc),
266
                 props.loc_repr(loc),
187
                 props.roo_repr(roo),
267
                 props.roo_repr(roo),
188
                 props.fun_repr(fun)
268
                 props.fun_repr(fun)
189
-            ]) + postfix
269
+            ])

+ 14
- 8
props.py View File

79
 """ First floor west """
79
 """ First floor west """
80
 LOC_FFE = 5
80
 LOC_FFE = 5
81
 """ First floor east """
81
 """ First floor east """
82
+LOC_STW = 6
83
+""" Stairways """
82
 def loc_repr(loc):
84
 def loc_repr(loc):
83
     return {
85
     return {
84
         LOC_GFW: 'gfw',
86
         LOC_GFW: 'gfw',
86
         LOC_STW: 'stw',
88
         LOC_STW: 'stw',
87
         LOC_FFW: 'ffw',
89
         LOC_FFW: 'ffw',
88
         LOC_FFE: 'ffe',
90
         LOC_FFE: 'ffe',
91
+        LOC_STW: 'stw',
89
     }.get(loc)
92
     }.get(loc)
90
 
93
 
91
 #
94
 #
109
 """ Marion """
112
 """ Marion """
110
 ROO_JUL = 9
113
 ROO_JUL = 9
111
 """ Julian """
114
 """ Julian """
112
-ROO_STW = 10
113
-""" Stairway """
115
+ROO_STG = 10
116
+""" ground floor """
117
+ROO_STF = 11
118
+""" first floor """
114
 def roo_repr(roo):
119
 def roo_repr(roo):
115
     return {
120
     return {
116
         ROO_DIN: 'diningroom',
121
         ROO_DIN: 'diningroom',
122
         ROO_DIR: 'dirk',
127
         ROO_DIR: 'dirk',
123
         ROO_MAR: 'marion',
128
         ROO_MAR: 'marion',
124
         ROO_JUL: 'julian',
129
         ROO_JUL: 'julian',
125
-        ROO_STW: 'stairway',
130
+        ROO_STG: 'groundfloor',
131
+        ROO_STF: 'firstfloor'
126
     }.get(roo)
132
     }.get(roo)
127
 
133
 
128
 #
134
 #
142
 """ Heating """
148
 """ Heating """
143
 FUN_MPP = 7
149
 FUN_MPP = 7
144
 """ Multiple Powerplugs """
150
 """ Multiple Powerplugs """
145
-FUN_CTR = 8
146
-""" Control """
151
+FUN_INP = 8
152
+""" Input Device """
147
 FUN_CIR = 9
153
 FUN_CIR = 9
148
 """ Circulation Pump """
154
 """ Circulation Pump """
149
 FUN_GAR = 10
155
 FUN_GAR = 10
167
     return {
173
     return {
168
         FUN_MAL: 'main_light',
174
         FUN_MAL: 'main_light',
169
         FUN_DEL: 'desk_light',
175
         FUN_DEL: 'desk_light',
170
-        FUN_FLL: 'floorlamp',     # TODO: -> floor_light
176
+        FUN_FLL: 'floor_light',
171
         FUN_BLD: 'bed_light_di',
177
         FUN_BLD: 'bed_light_di',
172
         FUN_BLM: 'bed_light_ma',
178
         FUN_BLM: 'bed_light_ma',
173
-        FUN_HEA: 'heating_valve',   # TODO: -> heating
179
+        FUN_HEA: 'heating_valve',
174
         FUN_MPP: 'powerplug',
180
         FUN_MPP: 'powerplug',
175
-        FUN_CTR: 'input_device',
181
+        FUN_INP: 'input_device',
176
         FUN_CIR: 'circulation_pump',
182
         FUN_CIR: 'circulation_pump',
177
         FUN_GAR: 'garland',
183
         FUN_GAR: 'garland',
178
         FUN_XTR: 'xmas-tree',
184
         FUN_XTR: 'xmas-tree',

Loading…
Cancel
Save