-
Notifications
You must be signed in to change notification settings - Fork 37
/
homeauto.py
801 lines (722 loc) · 32.4 KB
/
homeauto.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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
# -*- coding: utf-8 -*-
# Copyright (c) 2022 - 2023 Ricardo Bartels. All rights reserved.
#
# fritzinfluxdb.py
#
# This work is licensed under the terms of the MIT license.
# For a copy, see file LICENSE.txt included in this
# repository or visit: <https://opensource.org/licenses/MIT>.
"""
FritzBox home automation interface description (German):
https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf
"""
import xmltodict
import random
from datetime import datetime
from fritzinfluxdb.common import grab, in_test_mode
from fritzinfluxdb.classes.fritzbox.service_handler import FritzBoxLuaURLPath
from fritzinfluxdb.classes.fritzbox.service_definitions import lua_services
home_automation_device_classes = {
0: "HAN-FUN",
1: "UNDEFINED 1",
2: "Light",
3: "UNDEFINED 3",
4: "Alarm Sensor",
5: "AVM Button",
6: "Heating Regulator",
7: "Energy Measurement",
8: "Temperature Sensor",
9: "Switchable Power Sockets",
10: "AVM DECT Repeater",
11: "Microphone",
12: "UNDEFINED 12",
13: "HAN-FUN-Unit",
14: "UNDEFINED 14",
15: "Switchable Device",
16: "Dimmable Device",
17: "Light with Adjustable Color",
18: "Blinds"
}
hun_fun_unit_types = {
"273": "SIMPLE_BUTTON",
"256": "SIMPLE_ON_OFF_SWITCHABLE",
"257": "SIMPLE_ON_OFF_SWITCH",
"262": "AC_OUTLET",
"263": "AC_OUTLET_SIMPLE_POWER_METERING",
"264": "SIMPLE_LIGHT",
"265": "DIMMABLE_LIGHT",
"266": "DIMMER_SWITCH",
"277": "COLOR_BULB",
"278": "DIMMABLE_COLOR_BULB",
"281": "BLIND",
"282": "LAMELLAR",
"512": "SIMPLE_DETECTOR",
"513": "DOOR_OPEN_CLOSE_DETECTOR",
"514": "WINDOW_OPEN_CLOSE_DETECTOR",
"515": "MOTION_DETECTOR",
"518": "FLOOD_DETECTOR",
"519": "GLAS_BREAK_DETECTOR",
"520": "VIBRATION_DETECTOR",
"640": "SIREN"
}
hun_fun_interface_types = {
"277": "KEEP_ALIVE",
"256": "ALERT",
"512": "ON_OFF",
"513": "LEVEL_CTRL",
"514": "COLOR_CTRL",
"516": "OPEN_CLOSE",
"517": "OPEN_CLOSE_CONFIG",
"772": "SIMPLE_BUTTON",
"1024": "SUOTA-Update"
}
test_data = None
test_file_location = "test/homeauto_sample.xml"
test_start_ts = datetime.now().timestamp()
def force_int(data, path: str, default: int = 0):
"""
cast 'path' in data (object) to integer,
if this fails return default
"""
# noinspection PyBroadException
try:
return int(grab(data, path, fallback=f"{default}"))
except Exception:
return default
def avm_temp_map(value, input_min, input_max, output_min, output_max):
"""
Map home temperature data for AVM devices back to °C
"""
int_value = int(value)
if int_value in [253, 254]:
return float(int_value)
if int_value < input_min:
return float(output_min)
if int_value > input_max:
return float(output_max)
return float((int_value-input_min)/(input_max-input_min)*(output_max-output_min)+output_min)
def get_ha_temperature(data):
if in_test_mode():
return random.randrange(220, 250) / 10
return float((int(grab(data, "temperature.celsius")) + int(grab(data, "temperature.offset")))/10)
def get_ha_powermeter_power(data):
if in_test_mode():
return random.randrange(300_000, 500_000) / 1000
return float(int(grab(data, "powermeter.power")) / 1000)
def get_ha_powermeter_energy(data):
energy = grab(data, "powermeter.energy")
if in_test_mode():
return float(energy) + float(datetime.now().timestamp() - test_start_ts)
return energy
def get_ha_powermeter_voltage(data):
if in_test_mode():
return random.randrange(225_000, 234_000) / 1000
return float(int(grab(data, "powermeter.voltage")) / 1000)
def get_ha_switch_state(data):
if in_test_mode():
return int((datetime.now().timestamp() - test_start_ts) / 1000) % 2
return force_int(data, "switch.state")
def get_ha_alert_state(data):
if in_test_mode():
return int((datetime.now().timestamp() - test_start_ts) / 600) % 2
return force_int(data, "alert.state")
def decode_function_bitmask(bitmask: int):
return_values = list()
# noinspection PyBroadException
try:
binary_value = int(bitmask)
except Exception:
return return_values
for bit_shift, value in home_automation_device_classes.items():
if binary_value & 1 << bit_shift:
return_values.append(value)
return return_values
def reformat_homeauto_device_list(data):
device_list = data.get("devicelist")
devices_by_id = {x.get("@id"): x for x in device_list.get("device", [])}
hun_fun_device_id = 0 # these need to be skipped and only scraped for the @fwversion
hun_fun_unit_id = 13 # these ones are kept
new_device_list = list()
for device in device_list.get("device", []):
device_functions = decode_function_bitmask(device.get("@functionbitmask"))
# add function list
device["@devicefunctions"] = device_functions
if home_automation_device_classes[hun_fun_device_id] in device_functions:
continue
if home_automation_device_classes[hun_fun_unit_id] in device_functions:
parent_unit_id = grab(device, "etsiunitinfo.etsideviceid")
if parent_unit_id is None:
continue
device["etsiunitinfo"]["unittype"] = hun_fun_unit_types.get(grab(device, "etsiunitinfo.unittype"), "")
device["etsiunitinfo"]["interfaces"] = hun_fun_unit_types.get(grab(device, "etsiunitinfo.interfaces"), "")
hun_fun_device_fw = devices_by_id.get(parent_unit_id, dict()).get("@fwversion")
if hun_fun_device_fw is not None:
device["@fwversion"] = hun_fun_device_fw
new_device_list.append(device)
data["devicelist"]["device"] = new_device_list
return data
def prepare_response_data(response):
"""
handler to prepare returned data for parsing
Parameters
----------
response: requests.response
the FritzBox request response
Return
------
dict: xml response parsed to dict
"""
global test_data
if in_test_mode():
if test_data is None:
with open(test_file_location) as f:
test_data = f.read()
content = test_data
else:
content = response.content
return reformat_homeauto_device_list(xmltodict.parse(content, force_list=('device',)))
lua_services.append(
{
"name": "Home Automation",
"os_min_versions": "7.29",
"url_path": FritzBoxLuaURLPath.homeautomation,
"method": "GET",
"params": {
"switchcmd": "getdevicelistinfos"
},
"response_parser": prepare_response_data,
"value_instances": {
# Base Data
"ha_fw_version": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": str,
"tags_function": lambda data: {"name": data.get("name")},
"data_path": "@fwversion"
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_product_name": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": str,
"tags_function": lambda data: {"name": data.get("name")},
"data_path": "@productname"
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_manufacturer": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": str,
"tags_function": lambda data: {"name": data.get("name")},
"data_path": "@manufacturer"
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_devicefunctions": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": str,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: ", ".join(data.get("@devicefunctions"))
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_device_present": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"data_path": "present"
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# Battery data
"ha_battery_percent": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"data_path": "battery",
"exclude_filter_function": lambda data: "battery" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_battery_low": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"data_path": "batterylow",
"exclude_filter_function": lambda data: "batterylow" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# Temperature
"ha_temperature": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": get_ha_temperature,
"exclude_filter_function": lambda data: (
grab(data, "temperature.celsius") is None or grab(data, "temperature.offset") is None
)
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_temperature_celsius": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
float(int(grab(data, "temperature.celsius")) / 10)
),
"exclude_filter_function": lambda data: grab(data, "temperature.celsius") is None
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_temperature_offset": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
float(int(grab(data, "temperature.offset")) / 10)
),
"exclude_filter_function": lambda data: grab(data, "temperature.offset") is None
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# Power
"ha_powermeter_power": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": get_ha_powermeter_power,
"exclude_filter_function": lambda data: grab(data, "powermeter.power") is None
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_powermeter_energy": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": get_ha_powermeter_energy,
"exclude_filter_function": lambda data: grab(data, "powermeter.energy") is None
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_powermeter_voltage": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": get_ha_powermeter_voltage,
"exclude_filter_function": lambda data: grab(data, "powermeter.voltage") is None
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# Switch data
"ha_switch_state": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": get_ha_switch_state,
"exclude_filter_function": lambda data: "switch" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_switch_mode": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": str,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: grab(data, "switch.mode", fallback=""),
"exclude_filter_function": lambda data: "switch" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_switch_lock": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "switch.lock"),
"exclude_filter_function": lambda data: "switch" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_switch_devicelock": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "switch.devicelock"),
"exclude_filter_function": lambda data: "switch" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_simpleonoff_state": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "simpleonoff.state"),
"exclude_filter_function": lambda data: "simpleonoff" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_levelcontrol_level": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "levelcontrol.levelpercentage"),
"exclude_filter_function": lambda data: "levelcontrol" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# HUN-FUN device data
"ha_hun_fun_interfaces": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": str,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: grab(data, "etsiunitinfo.interfaces"),
"exclude_filter_function": lambda data: "etsiunitinfo" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_hun_fun_unittype": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": str,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: grab(data, "etsiunitinfo.unittype"),
"exclude_filter_function": lambda data: "etsiunitinfo" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# Colorcontrol
# colorcontrol: { supported_modes: '5', current_mode: '1', hue: '35', saturation: '214', temperature: '' },
"ha_colorcontrol_current_mode": {
"data_path": "devicelist.device",
"type": list,
"next": {
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "colorcontrol.current_mode"),
"exclude_filter_function": lambda data: "colorcontrol" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_colorcontrol_hue": {
"data_path": "devicelist.device",
"type": list,
"next": {
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "colorcontrol.hue"),
"exclude_filter_function": lambda data: "colorcontrol" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_colorcontrol_saturation": {
"data_path": "devicelist.device",
"type": list,
"next": {
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "colorcontrol.saturation"),
"exclude_filter_function": lambda data: "colorcontrol" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_colorcontrol_temperature": {
"data_path": "devicelist.device",
"type": list,
"next": {
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "colorcontrol.temperature"),
"exclude_filter_function": lambda data: "colorcontrol" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# Alarm
"ha_alert": {
"data_path": "devicelist.device",
"type": list,
"next": {
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": get_ha_alert_state,
"exclude_filter_function": lambda data: "alert" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
# Heating
"ha_heating_tist": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map(force_int(data, "hkr.tist"), 0, 120, 0, 60)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_tsoll": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map(force_int(data, "hkr.tsoll", 253), 16, 56, 8, 28)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_komfort": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map(force_int(data, "hkr.komfort", 253), 16, 56, 8, 28)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_absenk": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map(force_int(data, "hkr.absenk", 253), 16, 56, 8, 28)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_lock": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.lock"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_devicelock": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.devicelock"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_errorcode": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.errorcode"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_windowopenactiv": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.windowopenactiv"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_windowopenactiveendtime": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.windowopenactiveendtime"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_boostactive": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.boostactive"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_boostactiveendtime": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.boostactiveendtime"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_batterylow": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.batterylow"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_battery": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.battery"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_nextchange_endperiod": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.nextchange.endperiod"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_nextchange_tchange": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map(force_int(data, "hkr.nextchange.tchange"), 16, 56, 8, 28)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_summeractive": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.summeractive"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
"ha_heating_holidayactive": {
"data_path": "devicelist.device",
"type": list,
"next": {
# data struct type: dict
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: force_int(data, "hkr.holidayactive"),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
},
}
})