-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplugin.py
executable file
·667 lines (541 loc) · 24.1 KB
/
plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
# Luxtronic2 plugin based on sockets
# Author: ajarzyna, 2021
"""
<plugin key="LUXT2" name="Luxtronic2 based on sockets." author="ajarzyn" version="0.0.6">
<description>
<h2>Luxtronic2 based on sockets.</h2><br/>
Be aware:
Values greater than 30 seconds will cause a message to be regularly logged about the plugin not responding.
The plugin will actually function correctly with values greater than 30 though.
</description>
<params>
<param field="Address" label="luxtronic2 IP Address" width="200px" required="true" default="127.0.0.1"/>
<param field="Port" label="luxtronic2 Port" width="30px" required="true" default="8889"/>
<param field="Mode2" label="Data pull interval in seconds" width="150px" default="25"/>
<param field="Mode3" label="Lang" width="150px">
<options>
<option label="English" value="0" default="true"/>
<option label="Polish" value="1"/>
<option label="Dutch" value="2"/>
</options>
</param>
<param field="Mode6" label="Debug" width="150px">
<options>
<option label="None" value="0" default="true"/>
<option label="Python Only" value="2"/>
<option label="Basic Debugging" value="62"/>
<option label="Basic+Messages" value="126"/>
<option label="Connections Only" value="16"/>
<option label="Connections+Python" value="18"/>
<option label="Connections+Queue" value="144"/>
<option label="All" value="-1"/>
</options>
</param>
</params>
</plugin>
"""
import Domoticz
import socket
import struct
import re
_IDS = {
'Heating supply temperature': [
'Temperatura zasilania',
'Temperatuur aanvoer'
],
'Heating return temperature': [
'Temperatura powrótu',
'Temperatuur retour',
],
'Heating return temperature - target': [
'Temperatura powrótu - cel',
'Retour berekend'
],
'Outside temperature': [
'Temperatura zewnętrzna',
'Buitentemperatuur'
],
'Outside temperature - average': [
'Temperatura zewnętrzna - średnia',
'Buitentemperatuur - gemiddeld'
],
'Hot water temperature': [
'Temperatura cwu',
'Tapwater gemeten'
],
'Hot water temperature - target': [
'Temperatura cwu - cel',
'Tapwater ingesteld'
],
'Ground source temperature - in': [
'Temperatura dolne źródło-wejście',
'Bron-in'
],
'Ground source temperature - out': [
'Temperatura dolne źródło-wyjście',
'Bron-uit'
],
'OM 1 Temperature': [
'Temperatura zasilanie OM 1',
'Menggroep1 aanvoer'
],
'OM 1 Temperature - target': [
'Temperatura zasilanie OM 1 - cel',
'Menggroep1 aanvoer ingesteld'
],
'Heating mode': [
'Obieg grzewczy',
'Verwarmingsbedrijf'
],
'Hot water mode': [
'Woda użytkowa',
'Warmwater'
],
'Cooling': [
'Chłodzenie',
'Koelbedrijf'
],
'Operating time': [
'Czas pracy',
'Bedrijfstijd Verdichter 1'
],
'Cycles': [
'Cykli',
'Impuls VD1'
],
'Energy produced - heating': [
'Energia wyprodukowana - ogrzewanie',
'Verbruik verwarmen'
],
'Energy produced - hot water': [
'Energia wyprodukowana - c.w.u',
'Verbruik warmwater'
],
'Energy produced - sum': [
'Energia wyprodukowana - Razem',
'Verbruik gezamelijk'
],
'Automat.|2nd h. source|Party|Holidays|Off': [
'Automat.|II źr. ciepła|Party|Wakacje|Wył.',
'Automatisch|2e warm.opwek|Party|Vakantie|Uit',
],
'No requirement': [
'Brak zapotrzebowania',
'Geen vraag',
],
'Working mode': [
'Stan pracy',
'Bedrijfsmode'
],
'Swimming pool mode / Photovaltaik': [
'Tryb basen / Fotowoltaika',
'Zwembad / Fotovoltaïek'
],
'EVUM': [
'EVU',
'EVU'
],
'Defrost': [
'Rozmrażanie',
'Ontdooien'
],
'Heating external source mode': [
'Ogrzewanie z zewnętrznego źródła',
'Verwarmen 2e warm.opwek'
],
'Flow': [
'Przepływ',
'Debiet'
],
'Compressor frequency': [
'Częstotliwość sprężarki',
'Freq. '
],
'Temperature +-': [
'Temperatura +-',
'[DE]Temperature +-. '
],
'Actual room temperature': [
'Temperatura pokojowa',
'Raumtemperatur Ist. '
],
'Room temperature set': [
'Temperatura pokojowa - cel',
'Raumtemperatur Soll'
]
}
_IDS_STR = str(_IDS)
# Read callbacks
def to_float(data_list: list, data_idx: int, divider: float) -> dict:
converted = float(data_list[data_idx] / divider)
return {'sValue': str(converted)}
def to_number(data_list: list, data_idx: int, divider: float = 1.0) -> dict:
converted = float(data_list[data_idx] / divider)
return {'nValue': int(converted)}
def selector_switch_level_mapping(data_list: list, data_idx: int, mapping: list) -> dict:
level = mapping.index(data_list[data_idx]) * 10
return {'nValue': int(level), 'sValue': str(level)}
def to_power_counter(data_list: list, cumulative_power_data_idx: int, additional_data_list: list) -> dict:
power_sum_div, power_curr_data_idx, power_curr_div, state_curr_data_idx, acceptable_state = additional_data_list
sum_of_power = str(float(data_list[cumulative_power_data_idx] / power_sum_div))
if int(data_list[state_curr_data_idx]) in acceptable_state:
current_power = str(float(data_list[power_curr_data_idx] / power_curr_div))
return {'sValue': f"{current_power};{sum_of_power}"}
else:
return {'sValue': f"0;{sum_of_power}"}
def to_alert(data_list: list, data_idx: int, mapping: list) -> dict:
Domoticz.Debug(str(data_list[data_idx]) + " " + str(mapping))
return {'nValue': int(mapping[data_list[data_idx]][0]), 'sValue': str(mapping[data_list[data_idx]][1])}
# Write callbacks
def command_to_number(*_args, Command: str, **_kwargs):
return 1 if Command == 'On' else 0
def available_writes_level_with_divider(write_data_list: list, *_args,
available_writes, Level, **_kwargs):
divider, available_writes_idx = write_data_list
return available_writes[available_writes_idx].get_val()[int(Level / divider)]
def level_with_divider(divider: float, *_args, Level, **_kwargs):
return int(Level / divider)
def ids(text):
return _IDS[text][int(Parameters["Mode3"])-1] if int(Parameters["Mode3"]) else text
class Field:
def __init__(self, *args, **kwargs):
if len(args) == len(kwargs) == 0:
self.name = 'Unknown'
self.vales = []
else:
self.name, self.vales = args
def get_name(self):
return self.name
def get_val(self):
return self.vales
SOCKET_COMMANDS = {
'WRIT_PARAMS': 3002,
'READ_PARAMS': 3003,
'READ_CALCUL': 3004,
'READ_VISIBI': 3005
}
class BasePlugin:
def __init__(self):
self.active_connection = None
self.name = None
self.host = None
self.port = None
self.devices_parameters_list = []
self.units = {}
self.available_writes = {}
self.dev_lists = {}
for command in SOCKET_COMMANDS.keys():
self.dev_lists[command] = {}
def prepare_devices_list(self):
self.available_writes = {
-1: Field(),
1: Field(ids('Temperature +-'), [a for a in range(-50, 51, 5)]),
3: Field(ids('Heating mode'), [0, 1, 2, 3, 4]),
4: Field(ids('Hot water mode'), [0, 1, 2, 3, 4]),
105: Field(ids('Hot water temperature - target'), [a for a in range(300, 651, 5)]),
108: Field(ids('Cooling'), [0, 1])
}
work_modes_mapping = [(3, ids('Heating mode')),
(4, ids('Hot water mode')),
(2, ids('Swimming pool mode / Photovaltaik')),
(2, ids('EVUM')),
(1, ids('Defrost')),
(0, ids('No requirement')),
(4, ids('Heating external source mode')),
(1, ids('Cooling'))]
hot_water_temps = '|'.join([str(a / 10) for a in self.available_writes[105].get_val()])
heating_temps = '|'.join([str(a / 10) for a in self.available_writes[1].get_val()])
self.devices_parameters_list = [
# 0 Data group/socket command,
# 1 idx in returned data,
# 2 tuple(data modification callback, list of additional read data (conversion, indexes, relates)),
# 3 Domoticz devices dictionary options,
# 4 Name of the domoticz device,
# 5 tuple(write callback, list of additional write needed data (conversion, indexes))
['READ_CALCUL', 10, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Heating supply temperature')],
['READ_CALCUL', 11, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Heating return temperature')],
['READ_CALCUL', 12, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Heating return temperature - target')],
['READ_CALCUL', 15, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Outside temperature')],
['READ_CALCUL', 16, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Outside temperature - average')],
['READ_CALCUL', 17, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Hot water temperature')],
['READ_CALCUL', 19, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Ground source temperature - in')],
['READ_CALCUL', 20, (to_float, 10),
dict(TypeName='Temperature', Used=1), ids('Ground source temperature - out')],
['READ_CALCUL', 21, (to_float, 10),
dict(TypeName='Temperature', Used=0), ids('OM 1 Temperature')],
['READ_CALCUL', 22, (to_float, 10),
dict(TypeName='Temperature', Used=0), ids('OM 1 Temperature - target')],
['READ_CALCUL', 151, (to_power_counter, [1/100, 257, 1, 80, [0]]),
dict(TypeName='kWh', Used=1), ids('Energy produced - heating')],
['READ_CALCUL', 152, (to_power_counter, [1/100, 257, 1, 80, [1]]),
dict(TypeName='kWh', Used=1), ids('Energy produced - hot water')],
['READ_CALCUL', 154, (to_power_counter, [1/100, 257, 1, 80, [0, 1]]),
dict(TypeName='kWh', Used=1), ids('Energy produced - sum')],
['READ_PARAMS', 3, (selector_switch_level_mapping, self.available_writes[3].get_val()),
dict(TypeName='Selector Switch', Image=7, Used=1,
Options={'LevelActions': '|||||',
'LevelNames': ids('Automat.|2nd h. source|Party|Holidays|Off'),
'LevelOffHidden': 'false',
'SelectorStyle': '1'}),
ids('Heating mode'), (available_writes_level_with_divider, [10, 3])],
['READ_PARAMS', 4, (selector_switch_level_mapping, self.available_writes[4].get_val()),
dict(TypeName='Selector Switch', Image=7, Used=1,
Options={'LevelActions': '|||||',
'LevelNames': ids('Automat.|2nd h. source|Party|Holidays|Off'),
'LevelOffHidden': 'false',
'SelectorStyle': '1'}),
ids('Hot water mode'), (available_writes_level_with_divider, [10, 4])],
['READ_PARAMS', 108, [to_number],
dict(TypeName='Switch', Image=9, Used=0), ids('Cooling'), [command_to_number]],
['READ_PARAMS', 1, (to_float, 10),
dict(Type=242, Subtype=1, Used=1), ids('Temperature +-'), (level_with_divider, 1/10)],
['READ_PARAMS', 105, (to_float, 10),
dict(Type=242, Subtype=1, Used=1), ids('Hot water temperature - target'), (level_with_divider, 1/10)],
['READ_CALCUL', 80, (to_alert, work_modes_mapping),
dict(TypeName='Alert', Image=15, Used=1), ids('Working mode')],
['READ_CALCUL', 173, (to_float, 1),
dict(TypeName='Custom', Used=1, Options={'Custom': '1;l/h'}), ids('Flow')],
['READ_CALCUL', 231, (to_float, 1),
dict(TypeName='Custom', Used=0, Options={'Custom': '1;Hz'}), ids('Compressor frequency')],
['READ_CALCUL', 227, (to_float, 10),
dict(TypeName='Temperature', Used=0), ids('Actual room temperature')],
['READ_CALCUL', 228, (to_float, 10),
dict(TypeName='Temperature', Used=0), ids('Room temperature set')],
# ['READ_CALCUL', 56, 'time', dict(), IDS('Operating time')],
# ['READ_CALCUL', 57, 1, dict(TypeName='Temperature', Used=1), IDS('Cycles')],
# ['READ_CALCUL', 22, 10, dict(TypeName='Temperature', Used=1), IDS('')],
# ['READ_CALCUL', 22, 10, dict(TypeName='Temperature', Used=1), IDS('')],
]
class Unit:
def __init__(self, domoticz_id, message, address, read_conversion, dev_params, name, write_conversion=None):
self.id = domoticz_id
self.message = message
self.address = address
self.data_conversion_callback, *self._read_args = read_conversion
self.dev_params = dev_params
self.name = name
if write_conversion is not None:
self.write_conversion_callback, *self._write_args = write_conversion
else:
self.write_conversion_callback = write_conversion
def update_domoticz_dev(self, data_list):
update_device(Unit=self.id, **self.data_conversion_callback(data_list, self.address, *self._read_args))
def prepare_data_to_send(self, **kwargs):
return ('WRIT_PARAMS', self.address,
self.write_conversion_callback(*self._write_args, **kwargs))
for dev_idx in range(len(self.devices_parameters_list)):
tmp_unit = Unit(dev_idx + 1, *self.devices_parameters_list[dev_idx])
tmp_unit.dev_params.update(dict(Name=tmp_unit.name, Unit=tmp_unit.id))
self.units[tmp_unit.name] = tmp_unit
self.dev_lists[tmp_unit.message][tmp_unit.id] = tmp_unit
if tmp_unit.write_conversion_callback is not None:
self.dev_lists['WRIT_PARAMS'][tmp_unit.id] = tmp_unit
def create_devices(self):
self.prepare_devices_list()
for unit in self.units.values():
if unit.id not in Devices:
Domoticz.Device(**unit.dev_params).Create()
else:
# Do not change "Used" option which can be set by user.
update_params = unit.dev_params
update_params.pop('Used', None)
update_device(**update_params)
def initialize_connection(self):
self.active_connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
self.active_connection.connect((self.host, int(self.port)))
return True
except OSError as msg:
self.active_connection.close()
Domoticz.Error(f"Connection failed, check ip. Error: {str(msg)}")
return False
def send_message(self, command, address, value):
if self.initialize_connection() is False:
return
self.active_connection.send(struct.pack('!i', command))
self.active_connection.send(struct.pack('!i', address))
if command == SOCKET_COMMANDS['WRIT_PARAMS']:
Domoticz.Debug(f"SendMessage {command} {address} {value}")
self.active_connection.send(struct.pack('!i', value))
if struct.unpack('!i', self.active_connection.recv(4))[0] != command:
Domoticz.Debug("Error: REQ_CALCULATED CMD")
return None
length = 0
stat = 0
if command == SOCKET_COMMANDS['READ_PARAMS']:
length = struct.unpack('!i', self.active_connection.recv(4))[0]
elif command == SOCKET_COMMANDS['READ_CALCUL']:
stat = struct.unpack('!i', self.active_connection.recv(4))[0]
length = struct.unpack('!i', self.active_connection.recv(4))[0]
elif command == SOCKET_COMMANDS['READ_VISIBI']:
pass
elif command == SOCKET_COMMANDS['WRIT_PARAMS']:
pass
data_list = []
for i in range(length):
data_list.append(struct.unpack('!i', self.active_connection.recv(4))[0])
self.active_connection.close()
return command, stat, length, data_list
def process_socket_message(self, command='READ_PARAMS', address=0, value=0):
if command is 'WRIT_PARAMS':
if value not in self.available_writes[address].get_val():
Domoticz.Error(f"Incorrect value for {self.available_writes[address].get_name()} value: {value} "
f"but avaialble writables are: {self.available_writes[address].get_val()} for {address}")
return
else:
address = 0
value = 0
try:
raw_data = self.send_message(SOCKET_COMMANDS[command], address, value)
except socket.error:
if self.initialize_connection():
raw_data = self.send_message(SOCKET_COMMANDS[command], address, value)
if raw_data is None:
Domoticz.Error(f"Connection error.")
raw_data = command, 0, 0, 0
return raw_data
def update(self, message):
command, stat, data_length, data_list = self.process_socket_message(message)
if data_length > 0:
for device in self.dev_lists[message].values():
device.update_domoticz_dev(data_list)
def update_all(self):
self.update('READ_CALCUL')
self.update('READ_PARAMS')
def onStart(self):
if Parameters["Mode6"] != "0":
Domoticz.Debugging(int(Parameters["Mode6"]))
dump_config_to_log()
self.name = Parameters['Name']
self.host = Parameters['Address']
self.port = Parameters['Port']
Domoticz.Heartbeat(int(Parameters['Mode2']))
self.create_devices()
if self.initialize_connection() is False:
return
self.update_all()
def onStop(self):
Domoticz.Debug("onStop - Plugin is stopping.")
self.active_connection.close()
self.active_connection = None
def onDisconnect(self, Connection):
Domoticz.Debug(f"onDisconnect called for connection to: {Connection.Address}:{Connection.Port}")
def onConnect(self, Connection, status, Description):
Domoticz.Debug(f"onConnect called for connection to: {Connection.Address}:{Connection.Port}")
def onMessage(self, Connection, Data):
Domoticz.Debug(f"onMessage called for connection to: {Connection.Address}:{Connection.Port}")
def onCommand(self, Unit, Command, Level, Hue):
Domoticz.Debug(f"onCommand called for Unit:{str(Unit)} Command:{str(Command)} Level: {str(Level)}")
argument_list = locals()
argument_list.pop('self', None)
self.process_socket_message(
*self.dev_lists['WRIT_PARAMS'][Unit].prepare_data_to_send(
available_writes=self.available_writes,
**argument_list))
self.update('READ_PARAMS')
def onHeartbeat(self):
Domoticz.Debug("onHeartbeat called.")
self.update_all()
global _plugin
_plugin = BasePlugin()
def onStart():
global _plugin
_plugin.onStart()
def onStop():
global _plugin
_plugin.onStop()
def onConnect(Connection, Status, Description):
global _plugin
_plugin.onConnect(Connection, Status, Description)
def onMessage(Connection, Data):
global _plugin
_plugin.onMessage(Connection, Data)
def onCommand(Unit, Command, Level, Hue):
global _plugin
_plugin.onCommand(Unit, Command, Level, Hue)
def onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile):
global _plugin
_plugin.onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile)
def onDisconnect(Connection):
global _plugin
_plugin.onDisconnect(Connection)
def onHeartbeat():
global _plugin
_plugin.onHeartbeat()
def update_device(Unit: int = None, nValue: int = None, sValue: str = None, Image: int = None, SignalLevel: int = None,
BatteryLevel: int = None, Options: dict = None, TimedOut: int = None, Name: str = None,
TypeName: str = None, Type: int = None, Subtype: int = None, Switchtype: int = None,
Used: int = None, Description: str = None, Color: str = None, SuppressTriggers: int = None):
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
if Unit not in Devices:
global _plugin
_plugin.create_devices()
largs = {}
update_needed = False
# Must always be passed for update
largs["nValue"] = 0
if nValue is not None:
largs["nValue"] = nValue
update_needed = True
elif Devices[Unit].nValue is not None:
largs["nValue"] = Devices[Unit].nValue
largs["sValue"] = ""
if sValue is not None:
largs["sValue"] = str(sValue)
update_needed = True
elif Devices[Unit].sValue is not None:
largs["sValue"] = str(Devices[Unit].sValue)
if TypeName and False and TypeName != Devices[Unit].TypeName:
largs["TypeName"] = TypeName
if Image is not None and Image != Devices[Unit].Image:
largs["Image"] = Image
if SignalLevel is not None and SignalLevel != Devices[Unit].SignalLevel:
largs["SignalLevel"] = SignalLevel
if BatteryLevel is not None and BatteryLevel != Devices[Unit].BatteryLevel:
largs["BatteryLevel"] = BatteryLevel
if Options is not None and Options != Devices[Unit].Options:
largs["Options"] = Options
if TimedOut is not None and TimedOut != Devices[Unit].TimedOut:
largs["TimedOut"] = TimedOut
if Name is not None and Name != Devices[Unit].Name and bool(re.search(Devices[Unit].Name.replace(f"{Parameters['Name']} - " if f"{Parameters['Name']} - " in Devices[Unit].Name else "", ""), _IDS_STR)):
largs["Name"] = f"{Parameters['Name']} - {Name}"
if Type is not None and Type != Devices[Unit].Type:
largs["Type"] = Type
if Subtype is not None:
largs["Subtype"] = Subtype
if Switchtype is not None and Switchtype != Devices[Unit].Switchtype:
largs["Switchtype"] = Switchtype
if Used is not None and Used != Devices[Unit].Used:
largs["Used"] = Used
if Description is not None and Description != Devices[Unit].Description:
largs["Description"] = Description
if Color is not None and Color != Devices[Unit].Color:
largs["Color"] = Color
if SuppressTriggers is not None and SuppressTriggers != Devices[Unit].SuppressTriggers:
largs["SuppressTriggers"] = SuppressTriggers
if len(largs) > 2:
update_needed = True
if update_needed:
Domoticz.Debug(f"update_device unit: {str(Unit)} Name: {Devices[Unit].Name} with parameters: {str(largs)}")
Devices[Unit].Update(**largs)
# Generic helper functions
def dump_config_to_log():
for x in Parameters:
if Parameters[x] != "":
Domoticz.Debug(f"'{x}':'{str(Parameters[x])}'")
Domoticz.Debug(f"Device count: {str(len(Devices))}")
for x in Devices:
Domoticz.Debug(f"Device: {str(x)} - {str(Devices[x])} ")
Domoticz.Debug(f"Device ID: '{str(Devices[x].ID)}' ")
Domoticz.Debug(f"Device Name: '{Devices[x].Name}' ")
Domoticz.Debug(f"Device nValue: {str(Devices[x].nValue)} ")
Domoticz.Debug(f"Device sValue: '{Devices[x].sValue}' ")
Domoticz.Debug(f"Device LastLevel: {str(Devices[x].LastLevel)} ")
return