|
@@ -16,9 +16,7 @@ Targets:
|
16
|
16
|
|
17
|
17
|
from base import mqtt_base
|
18
|
18
|
import devices
|
19
|
|
-import inspect
|
20
|
19
|
import json
|
21
|
|
-import logging
|
22
|
20
|
|
23
|
21
|
BASETOPIC = "videv"
|
24
|
22
|
|
|
@@ -99,10 +97,10 @@ class base_routing(base):
|
99
|
97
|
l1 = []
|
100
|
98
|
for k, v in self.__device_list__.items():
|
101
|
99
|
if v.__class__.__name__ == "group":
|
102
|
|
- if device in v:
|
|
100
|
+ if id(device) in [id(d) for d in v]:
|
103
|
101
|
l1.append(k)
|
104
|
102
|
else:
|
105
|
|
- if v == device:
|
|
103
|
+ if id(v) == id(device):
|
106
|
104
|
l1.append(k)
|
107
|
105
|
l2 = [k for k, v in self.__device_key__.items() if v == key]
|
108
|
106
|
try:
|
|
@@ -234,15 +232,38 @@ class videv_heating(base_routing):
|
234
|
232
|
|
235
|
233
|
|
236
|
234
|
class videv_multistate(base):
|
237
|
|
- def __init__(self, mqtt_client, topic, key_for_topic, device, num_states, default_values=None):
|
|
235
|
+ def __init__(self, mqtt_client, topic, key_for_device, device, num_states, default_values=None):
|
238
|
236
|
dv = dict.fromkeys(["state_%d" % i for i in range(0, num_states)])
|
239
|
237
|
for key in dv:
|
240
|
238
|
dv[key] = False
|
241
|
|
- super().__init__(mqtt_client, topic, (key_for_topic, device), default_values=dv)
|
|
239
|
+ super().__init__(mqtt_client, topic, (key_for_device, device), default_values=dv)
|
242
|
240
|
#
|
243
|
|
- device.add_callback(key_for_topic, None, self.__index_rx__, True)
|
|
241
|
+ device.add_callback(key_for_device, None, self.__index_rx__, True)
|
244
|
242
|
|
245
|
243
|
def __index_rx__(self, device, key, data):
|
246
|
244
|
for index, key in enumerate(self):
|
247
|
245
|
self.set(key, index == data)
|
248
|
246
|
self.__tx__(key, self[key])
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+class videv_audio_player(base_routing):
|
|
250
|
+ KEY_ACTIVE_PLAYER = 'player_%d'
|
|
251
|
+ KEY_TITLE = 'title'
|
|
252
|
+ NO_TITLE = '---'
|
|
253
|
+
|
|
254
|
+ def __init__(self, mqtt_client, topic, *args):
|
|
255
|
+ dv = dict.fromkeys([self.KEY_ACTIVE_PLAYER % i for i in range(0, len(args))])
|
|
256
|
+ for key in dv:
|
|
257
|
+ dv[key] = False
|
|
258
|
+ dv[self.KEY_TITLE] = self.NO_TITLE
|
|
259
|
+ super().__init__(
|
|
260
|
+ mqtt_client, topic,
|
|
261
|
+ *[[self.KEY_ACTIVE_PLAYER % i, device, devices.audio_status.KEY_STATE] for i, device in enumerate(args)],
|
|
262
|
+ default_values=dv
|
|
263
|
+ )
|
|
264
|
+ for audio_device in args:
|
|
265
|
+ audio_device.add_callback(audio_device.KEY_TITLE, None, self.__title_rx__, True)
|
|
266
|
+
|
|
267
|
+ def __title_rx__(self, device, key, data):
|
|
268
|
+ self.set(self.KEY_TITLE, data or self.NO_TITLE)
|
|
269
|
+ self.__tx__(self.KEY_TITLE, self[self.KEY_TITLE])
|