forked from dresden-elektronik/deconz-rest-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
de_web_plugin.cpp
17133 lines (15180 loc) · 662 KB
/
de_web_plugin.cpp
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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2017-2023 dresden elektronik ingenieurtechnik gmbh.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
* style license a copy of which has been included with this distribution in
* the LICENSE.txt file.
*
*/
#include <QCoreApplication>
#include <QDebug>
#include <QDesktopServices>
#include <QtPlugin>
#include <QtCore/qmath.h>
#include <QNetworkAccessManager>
#include <QPushButton>
#include <QTextCodec>
#include <QTime>
#include <QTimer>
#include <QTcpSocket>
#include <QHostAddress>
#include <QUrl>
#include <QCryptographicHash>
#include <QFile>
#include <QDir>
#include <QProcess>
#include <QSettings>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QJsonParseError>
#include <cmath>
#include "alarm_system_device_table.h"
#include "database.h"
#include "deconz/u_assert.h"
#include "device_ddf_init.h"
#include "device_descriptions.h"
#include "device_tick.h"
#include "device_js/device_js.h"
#include "de_web_plugin.h"
#include "de_web_plugin_private.h"
#include "de_web_widget.h"
#include "ui/device_widget.h"
#include "gateway_scanner.h"
#include "ias_ace.h"
#include "json.h"
#include "poll_control.h"
#include "poll_manager.h"
#include "product_match.h"
#include "rest_ddf.h"
#include "rest_devices.h"
#include "rest_alarmsystems.h"
#include "read_files.h"
#include "tuya.h"
#include "utils/utils.h"
#include "utils/scratchmem.h"
#include "xiaomi.h"
#include "zcl/zcl.h"
#include "zdp/zdp.h"
#include "zdp/zdp_handlers.h"
#ifdef ARCH_ARM
#include <unistd.h>
#include <sys/reboot.h>
#include <errno.h>
#endif
DeRestPluginPrivate *plugin = nullptr;
static int checkZclAttributesDelay = 750;
static uint MaxGroupTasks = 4;
const quint64 macPrefixMask = 0xffffff0000000000ULL;
// New mac prefixes can be checked here: https://wintelguy.com/index.pl
const quint64 legrandMacPrefix = 0x0004740000000000ULL;
const quint64 dishMacPrefix = 0x0008890000000000ULL;
const quint64 silabs1MacPrefix = 0x000b570000000000ULL;
const quint64 emberMacPrefix = 0x000d6f0000000000ULL;
const quint64 instaMacPrefix = 0x000f170000000000ULL;
const quint64 tiMacPrefix = 0x00124b0000000000ULL;
const quint64 netvoxMacPrefix = 0x00137a0000000000ULL;
const quint64 boschMacPrefix = 0x00155f0000000000ULL;
const quint64 jennicMacPrefix = 0x00158d0000000000ULL;
const quint64 develcoMacPrefix = 0x0015bc0000000000ULL;
const quint64 philipsMacPrefix = 0x0017880000000000ULL;
const quint64 ubisysMacPrefix = 0x001fee0000000000ULL;
const quint64 computimeMacPrefix = 0x001e5e0000000000ULL;
const quint64 deMacPrefix = 0x00212e0000000000ULL;
const quint64 celMacPrefix = 0x0022a30000000000ULL; // California Eastern Laboratories
const quint64 zenMacPrefix = 0x0024460000000000ULL;
const quint64 heimanMacPrefix = 0x0050430000000000ULL;
const quint64 davicomMacPrefix = 0x00606e0000000000ULL;
const quint64 xiaomiMacPrefix = 0x04cf8c0000000000ULL;
const quint64 konkeMacPrefix = 0x086bd70000000000ULL;
const quint64 ikea2MacPrefix = 0x14b4570000000000ULL;
const quint64 profaluxMacPrefix = 0x20918a0000000000ULL;
const quint64 stMacPrefix = 0x24fd5b0000000000ULL;
const quint64 samjinMacPrefix = 0x286d970000000000ULL;
const quint64 casaiaPrefix = 0x3c6a2c0000000000ULL;
const quint64 sinopeMacPrefix = 0x500b910000000000ULL;
const quint64 lumiMacPrefix = 0x54ef440000000000ULL;
const quint64 silabs6MacPrefix = 0x588e810000000000ULL;
const quint64 silabs9MacPrefix = 0x5c02720000000000ULL;
const quint64 silabs8MacPrefix = 0x60a4230000000000ULL;
const quint64 silabs4MacPrefix = 0x680ae20000000000ULL;
const quint64 ecozyMacPrefix = 0x70b3d50000000000ULL;
const quint64 silabs11MacPrefix = 0x804b500000000000ULL;
const quint64 osramMacPrefix = 0x8418260000000000ULL;
const quint64 silabs5MacPrefix = 0x842e140000000000ULL;
const quint64 silabs10MacPrefix = 0x8471270000000000ULL;
const quint64 embertecMacPrefix = 0x848e960000000000ULL;
const quint64 YooksmartMacPrefix = 0x84fd270000000000ULL;
const quint64 silabs13MacPrefix = 0x8cf6810000000000ULL;
const quint64 silabsMacPrefix = 0x90fd9f0000000000ULL;
const quint64 zhejiangMacPrefix = 0xb0ce180000000000ULL;
const quint64 silabs12MacPrefix = 0xb4e3f90000000000ULL;
const quint64 silabs7MacPrefix = 0xbc33ac0000000000ULL;
const quint64 dlinkMacPrefix = 0xc4e90a0000000000ULL;
const quint64 silabs2MacPrefix = 0xcccccc0000000000ULL;
const quint64 energyMiMacPrefix = 0xd0cf5e0000000000ULL;
const quint64 schlageMacPrefix = 0xd0cf5e0000000000ULL;
const quint64 bjeMacPrefix = 0xd85def0000000000ULL;
const quint64 silabs3MacPrefix = 0xec1bbd0000000000ULL;
const quint64 onestiPrefix = 0xf4ce360000000000ULL;
const quint64 xalMacPrefix = 0xf8f0050000000000ULL;
const quint64 lutronMacPrefix = 0xffff000000000000ULL;
struct SupportedDevice {
quint16 vendorId;
const char *modelId;
quint64 mac;
};
static const SupportedDevice supportedDevices[] = {
{ VENDOR_3A_SMART_HOME, "FNB56-GAS", jennicMacPrefix }, // Feibit FNB56-GAS05FB1.4 gas leak detector
{ VENDOR_3A_SMART_HOME, "FNB56-COS", jennicMacPrefix }, // Feibit FNB56-COS06FB1.7 Carb. Mon. detector
{ VENDOR_3A_SMART_HOME, "FNB56-SMF", jennicMacPrefix }, // Feibit FNB56-SMF06FB1.6 smoke detector
{ VENDOR_3A_SMART_HOME, "c3442b4ac59b4ba1a83119d938f283ab", jennicMacPrefix }, // ORVIBO SF30 smoke sensor
{ VENDOR_ADEO, "LDSENK10", silabs9MacPrefix }, // ADEO Animal compatible motion sensor (Leroy Merlin)
{ VENDOR_BUSCH_JAEGER, "RB01", bjeMacPrefix },
{ VENDOR_BUSCH_JAEGER, "RM01", bjeMacPrefix },
{ VENDOR_BOSCH, "ISW-ZDL1-WP11G", boschMacPrefix },
{ VENDOR_BOSCH, "ISW-ZPR1-WP13", boschMacPrefix },
{ VENDOR_BOSCH, "RFDL-ZB-MS", emberMacPrefix }, // Bosch motion sensor
{ VENDOR_BOSCH2, "AIR", tiMacPrefix }, // Bosch Air quality sensor
{ VENDOR_CENTRALITE, "3321-S", emberMacPrefix }, // Centralite multipurpose sensor
{ VENDOR_CENTRALITE, "3325-S", emberMacPrefix }, // Centralite motion sensor
{ VENDOR_CENTRALITE, "3305-S", emberMacPrefix }, // Centralite motion sensor
{ VENDOR_CLS, "3200-Sgb", emberMacPrefix }, // Centralite smart plug / Samsung smart outlet
{ VENDOR_CLS, "3200-de", emberMacPrefix }, // Centralite smart plug / Samsung smart outlet
{ VENDOR_C2DF, "3300", emberMacPrefix }, // Centralite contact sensor
{ VENDOR_C2DF, "3320-L", emberMacPrefix }, // Centralite contact sensor
{ VENDOR_C2DF, "3315", emberMacPrefix }, // Centralite water sensor
{ VENDOR_D_LINK, "DCH-B112", dlinkMacPrefix }, // D-Link DCH-B112 door/window sensor
{ VENDOR_D_LINK, "DCH-B122", dlinkMacPrefix }, // D-Link DCH-B122 motion sensor
{ VENDOR_NONE, "SD8SC_00.00.03.09TC", tiMacPrefix }, // Centralite smoke sensor
{ VENDOR_CENTRALITE, "3326-L", emberMacPrefix }, // Iris motion sensor v2
{ VENDOR_C2DF, "3326-L", emberMacPrefix }, // Iris motion sensor v2
{ VENDOR_CENTRALITE, "3328-G", emberMacPrefix }, // Centralite micro motion sensor
{ VENDOR_CENTRALITE, "3323", emberMacPrefix }, // Centralite contact sensor
{ VENDOR_DATEK, "ID Lock 150", silabs4MacPrefix }, // ID-Lock
{ VENDOR_JASCO, "45856", celMacPrefix },
{ VENDOR_NONE, "FB56-DOS06HM1.3", tiMacPrefix }, // Feibit FB56-DOS06HM1.3 door/window sensor
{ VENDOR_NONE, "LM_", tiMacPrefix },
{ VENDOR_NONE, "LMHT_", tiMacPrefix },
{ VENDOR_NONE, "IR_", tiMacPrefix },
{ VENDOR_NONE, "DC_", tiMacPrefix },
{ VENDOR_NONE, "BX_", tiMacPrefix }, // Climax siren
{ VENDOR_NONE, "PSMD_", tiMacPrefix }, // Climax smart plug
{ VENDOR_NONE, "PSMP5_", tiMacPrefix }, // Climax smart plug
{ VENDOR_NONE, "PCM_", tiMacPrefix }, // Climax power meter
{ VENDOR_NONE, "OJB-IR715-Z", tiMacPrefix },
{ VENDOR_NONE, "902010/21", tiMacPrefix }, // Bitron: door/window sensor
{ VENDOR_NONE, "902010/22", tiMacPrefix }, // Bitron: motion sensor
{ VENDOR_NONE, "902010/23", tiMacPrefix }, // Bitron: remote control
{ VENDOR_NONE, "902010/24", tiMacPrefix }, // Bitron: smoke detector
{ VENDOR_NONE, "902010/25", tiMacPrefix }, // Bitron: smart plug
{ VENDOR_NONE, "902010/29", tiMacPrefix }, // Bitron: Outdoor siren
{ VENDOR_NONE, "SPW35Z", tiMacPrefix }, // RT-RK OBLO SPW35ZD0 smart plug
{ VENDOR_NONE, "SWO-MOS1PA", tiMacPrefix }, // Swann One Motion Sensor
{ VENDOR_BITRON, "902010/32", emberMacPrefix }, // Bitron: thermostat
{ VENDOR_IKEA, "TRADFRI remote control", silabs1MacPrefix },
{ VENDOR_IKEA, "TRADFRI remote control", silabsMacPrefix },
{ VENDOR_IKEA, "TRADFRI remote control", silabs2MacPrefix },
{ VENDOR_IKEA, "TRADFRI motion sensor", silabs1MacPrefix },
{ VENDOR_IKEA, "TRADFRI wireless dimmer", silabs1MacPrefix },
{ VENDOR_IKEA, "TRADFRI on/off switch", silabs1MacPrefix },
{ VENDOR_IKEA, "TRADFRI SHORTCUT Button", silabs4MacPrefix },
{ VENDOR_IKEA, "TRADFRI open/close remote", silabs1MacPrefix },
{ VENDOR_IKEA, "SYMFONISK", ikea2MacPrefix }, // sound controller
{ VENDOR_INSTA, "Remote", instaMacPrefix },
{ VENDOR_INSTA, "HS_4f_GJ_1", instaMacPrefix },
{ VENDOR_INSTA, "WS_4f_J_1", instaMacPrefix },
{ VENDOR_INSTA, "WS_3f_G_1", instaMacPrefix },
{ VENDOR_AXIS, "Gear", zenMacPrefix },
{ VENDOR_MMB, "Gear", zenMacPrefix },
{ VENDOR_SI_LABS, "D10110", konkeMacPrefix }, // Yoolax Blinds
{ VENDOR_SI_LABS, "D10110", YooksmartMacPrefix }, // Yoolax Blinds
{ VENDOR_NYCE, "3011", emberMacPrefix }, // NYCE door/window sensor
{ VENDOR_NYCE, "3014", emberMacPrefix }, // NYCE garage door/tilt sensor
{ VENDOR_NYCE, "3041", emberMacPrefix }, // NYCE motion sensor
{ VENDOR_NYCE, "3043", emberMacPrefix }, // NYCE ceiling motion sensor
{ VENDOR_PHYSICAL, "tagv4", stMacPrefix}, // SmartThings Arrival sensor
{ VENDOR_PHYSICAL, "motionv4", stMacPrefix}, // SmartThings motion sensor
{ VENDOR_PHYSICAL, "moisturev4", stMacPrefix}, // SmartThings water leak sensor
{ VENDOR_PHYSICAL, "multiv4", stMacPrefix}, // SmartThings multi sensor 2016
{ VENDOR_SAMJIN, "motion", samjinMacPrefix }, // Smarthings GP-U999SJVLBAA (Samjin) Motion Sensor
{ VENDOR_SAMJIN, "multi", samjinMacPrefix }, // Smarthings (Samjin) Multipurpose Sensor
{ VENDOR_SAMJIN, "water", samjinMacPrefix }, // Smarthings (Samjin) Water Sensor
{ VENDOR_SAMJIN, "button", samjinMacPrefix }, // Smarthings (Samjin) Button
{ VENDOR_SAMJIN, "outlet", samjinMacPrefix }, // Smarthings (Samjin) Outlet
{ VENDOR_JENNIC, "lumi.lock.v1", jennicMacPrefix }, // Xiaomi A6121 Vima Smart Lock
{ VENDOR_JENNIC, "lumi.sensor_magnet", jennicMacPrefix },
{ VENDOR_JENNIC, "lumi.sensor_motion", jennicMacPrefix },
{ VENDOR_JENNIC, "lumi.sensor_switch.aq2", jennicMacPrefix }, // Xiaomi WXKG11LM 2016
{ VENDOR_JENNIC, "lumi.remote.b1acn01", jennicMacPrefix }, // Xiaomi WXKG11LM 2018
{ VENDOR_JENNIC, "lumi.sensor_switch.aq3", jennicMacPrefix }, // Xiaomi WXKG12LM
{ VENDOR_JENNIC, "lumi.sensor_86sw1", jennicMacPrefix }, // Xiaomi single button wall switch WXKG03LM 2016
{ VENDOR_JENNIC, "lumi.remote.b186acn01", jennicMacPrefix }, // Xiaomi single button wall switch WXKG03LM 2018
{ VENDOR_JENNIC, "lumi.remote.b186acn02", jennicMacPrefix }, // Xiaomi single button wall switch WXKG02LM 2020
{ VENDOR_JENNIC, "lumi.sensor_86sw2", jennicMacPrefix }, // Xiaomi dual button wall switch WXKG02LM 2016
{ VENDOR_JENNIC, "lumi.remote.b286acn01", jennicMacPrefix }, // Xiaomi dual button wall switch WXKG02LM 2018
{ VENDOR_JENNIC, "lumi.remote.b286acn02", jennicMacPrefix }, // Xiaomi dual button wall switch WXKG02LM 2020
{ VENDOR_JENNIC, "lumi.sensor_switch", jennicMacPrefix }, // Xiaomi WXKG01LM, WXKG11LM and WXKG12LM (fallback)
{ VENDOR_JENNIC, "lumi.ctrl_neutral", jennicMacPrefix }, // Xiaomi Wall Switch (end-device)
{ VENDOR_JENNIC, "lumi.vibration", jennicMacPrefix }, // Xiaomi Aqara vibration/shock sensor
{ VENDOR_JENNIC, "lumi.sensor_wleak", jennicMacPrefix },
{ VENDOR_JENNIC, "lumi.relay.c", jennicMacPrefix }, // Xiaomi Aqara LLKZMK11LM
{ VENDOR_JENNIC, "lumi.switch.b1lacn02", jennicMacPrefix }, // Xiaomi Aqara D1 1-gang (no neutral wire) QBKG21LM
{ VENDOR_JENNIC, "lumi.switch.b2lacn02", jennicMacPrefix }, // Xiaomi Aqara D1 2-gang (no neutral wire) QBKG22LM
{ VENDOR_XIAOMI, "lumi.switch.b1nacn02", jennicMacPrefix }, // Xiaomi Aqara D1 1-gang (neutral wire) QBKG23LM
{ VENDOR_XIAOMI, "lumi.switch.b2nacn02", jennicMacPrefix }, // Xiaomi Aqara D1 2-gang (neutral wire) QBKG24LM
{ VENDOR_XIAOMI, "lumi.plug", jennicMacPrefix }, // Xiaomi smart plug (router)
{ VENDOR_XIAOMI, "lumi.ctrl_ln", jennicMacPrefix}, // Xiaomi Wall Switch (router)
{ VENDOR_XIAOMI, "lumi.remote.b286opcn01", xiaomiMacPrefix }, // Xiaomi Aqara Opple WXCJKG11LM
{ VENDOR_XIAOMI, "lumi.remote.b486opcn01", xiaomiMacPrefix }, // Xiaomi Aqara Opple WXCJKG12LM
{ VENDOR_XIAOMI, "lumi.remote.b686opcn01", xiaomiMacPrefix }, // Xiaomi Aqara Opple WXCJKG13LM
{ VENDOR_XIAOMI, "lumi.plug", xiaomiMacPrefix }, // Xiaomi smart plugs (router)
{ VENDOR_XIAOMI, "lumi.switch.b1naus01", xiaomiMacPrefix }, // Xiaomi Aqara ZB3.0 Smart Wall Switch Single Rocker WS-USC03
// { VENDOR_XIAOMI, "lumi.curtain", jennicMacPrefix}, // Xiaomi curtain controller (router) - exposed only as light
{ VENDOR_XIAOMI, "lumi.curtain.hagl04", xiaomiMacPrefix}, // Xiaomi B1 curtain controller
{ VENDOR_XIAOMI, "lumi.motion.agl04", lumiMacPrefix}, // Xiaomi Aqara RTCGQ13LM high precision motion sensor
{ VENDOR_XIAOMI, "lumi.flood.agl02", xiaomiMacPrefix}, // Xiaomi Aqara T1 water leak sensor SJCGQ12LM
{ VENDOR_XIAOMI, "lumi.switch.n0agl1", lumiMacPrefix}, // Xiaomi Aqara Single Switch Module T1 (With Neutral)
{ VENDOR_NONE, "Z716A", netvoxMacPrefix },
// { VENDOR_OSRAM_STACK, "Plug", osramMacPrefix }, // OSRAM plug - exposed only as light
{ VENDOR_OSRAM, "Lightify Switch Mini", emberMacPrefix }, // Osram 3 button remote
{ VENDOR_OSRAM, "Switch 4x EU-LIGHTIFY", emberMacPrefix }, // Osram 4 button remote
{ VENDOR_OSRAM, "Switch 4x-LIGHTIFY", emberMacPrefix }, // Osram 4 button remote
{ VENDOR_OSRAM, "Switch-LIGHTIFY", emberMacPrefix }, // Osram 4 button remote
{ VENDOR_OSRAM_STACK, "CO_", heimanMacPrefix }, // Heiman CO sensor
{ VENDOR_OSRAM_STACK, "DOOR_", heimanMacPrefix }, // Heiman door/window sensor - older model
{ VENDOR_OSRAM_STACK, "PIR_", heimanMacPrefix }, // Heiman motion sensor
{ VENDOR_OSRAM_STACK, "GAS_", heimanMacPrefix }, // Heiman gas sensor - older model
{ VENDOR_OSRAM_STACK, "TH-", heimanMacPrefix }, // Heiman temperature/humidity sensor
{ VENDOR_OSRAM_STACK, "SMOK_", heimanMacPrefix }, // Heiman fire sensor - older model
{ VENDOR_OSRAM_STACK, "WATER_", heimanMacPrefix }, // Heiman water sensor
{ VENDOR_OSRAM_STACK, "RC_V14", heimanMacPrefix }, // Heiman HS1RC-M remote control
{ VENDOR_LGE, "LG IP65 HMS", emberMacPrefix },
{ VENDOR_EMBER, "SmartPlug", emberMacPrefix }, // Heiman smart plug
{ VENDOR_HEIMAN, "SmartPlug", emberMacPrefix }, // Heiman smart plug
{ VENDOR_HEIMAN, "GAS", emberMacPrefix }, // Heiman gas sensor - newer model
{ VENDOR_HEIMAN, "Smoke", emberMacPrefix }, // Heiman fire sensor - newer model
{ VENDOR_HEIMAN, "COSensor", emberMacPrefix }, // Heiman CO sensor - newer model
{ VENDOR_HEIMAN, "TH-", emberMacPrefix }, // Heiman temperature/humidity sensor - newer model
{ VENDOR_HEIMAN, "HT-", emberMacPrefix }, // Heiman temperature/humidity sensor - newer model
{ VENDOR_HEIMAN, "Water", emberMacPrefix }, // Heiman water sensor - newer model
{ VENDOR_HEIMAN, "Door", emberMacPrefix }, // Heiman door/window sensor - newer model
{ VENDOR_HEIMAN, "WarningDevice", emberMacPrefix }, // Heiman siren
{ VENDOR_HEIMAN, "Smoke", jennicMacPrefix }, // Heiman fire sensor - newer model
{ VENDOR_HEIMAN, "PIRSensor-EM", jennicMacPrefix }, // Heiman motion sensor - newer model
{ VENDOR_HEIMAN, "SKHMP30", jennicMacPrefix }, // GS (Heiman) smart plug
{ VENDOR_HEIMAN, "RC-EM", emberMacPrefix }, // Heiman IAS ACE remote control
{ VENDOR_HEIMAN, "RC-EF-3.0", silabs5MacPrefix }, // Heiman IAS ACE remote control
{ VENDOR_LUTRON, "LZL4BWHL01", lutronMacPrefix }, // Lutron LZL-4B-WH-L01 Connected Bulb Remote
{ VENDOR_KEEN_HOME , "SV01-", celMacPrefix}, // Keen Home Vent
{ VENDOR_KEEN_HOME , "SV02-", celMacPrefix}, // Keen Home Vent
{ VENDOR_JENNIC, "VMS_ADUROLIGHT", jennicMacPrefix }, // Trust motion sensor ZPIR-8000
{ VENDOR_JENNIC, "CSW_ADUROLIGHT", jennicMacPrefix }, // Trust contact sensor ZMST-808
{ VENDOR_JENNIC, "ZYCT-202", jennicMacPrefix }, // Trust remote control ZYCT-202 (older model)
{ VENDOR_ADUROLIGHT, "ZLL-NonColorController", jennicMacPrefix }, // Trust remote control ZYCT-202 (newer model)
{ VENDOR_INNR, "RC 110", jennicMacPrefix }, // innr remote RC 110
{ VENDOR_VISONIC, "MCT-340", emberMacPrefix }, // Visonic MCT-340 E temperature/motion
{ VENDOR_SUNRICHER, "ZGR904-S", emberMacPrefix }, // Envilar remote
{ VENDOR_SUNRICHER, "ICZB-KPD1", emberMacPrefix }, // iCasa keypad
{ VENDOR_SUNRICHER, "ICZB-RM", silabs2MacPrefix }, // iCasa remote
{ VENDOR_SUNRICHER, "ZGRC-KEY", emberMacPrefix }, // Sunricher wireless CCT remote
{ VENDOR_SUNRICHER, "RGBgenie ZB-5", emberMacPrefix }, // RGBgenie remote control
{ VENDOR_SUNRICHER, "ROB_200-010-0", silabs3MacPrefix }, // Robbshop window covering controller
{ VENDOR_SUNRICHER, "ROB_200-014-0", silabs3MacPrefix }, // Robbshop rotary dimmer
{ VENDOR_SUNRICHER, "Micro Smart Dimmer", silabs3MacPrefix }, // Sunricher SR-ZG9040A built-in dimmer
{ VENDOR_SUNRICHER, "ZG2835", silabs6MacPrefix }, // SR-ZG2835 Zigbee Rotary Switch
{ VENDOR_SUNRICHER, "ZGRC-TEUR-", emberMacPrefix }, // iluminize wall switch 511.524
{ VENDOR_SUNRICHER, "ZG2833PAC", silabs3MacPrefix}, // Sunricher Zigbee Push-Button Coupler SR-ZG2833PAC-C4
{ VENDOR_JENNIC, "SPZB0001", jennicMacPrefix }, // Eurotronic thermostat
{ VENDOR_NONE, "RES001", tiMacPrefix }, // Hubitat environment sensor, see #1308
{ VENDOR_SINOPE, "WL4200S", sinopeMacPrefix}, // Sinope water sensor with wired remote sensor
{ VENDOR_SINOPE, "WL4200", sinopeMacPrefix}, // Sinope water sensor
{ VENDOR_SINOPE, "TH1300ZB", sinopeMacPrefix }, // Sinope Thermostat
{ VENDOR_ZEN, "Zen-01", zenMacPrefix }, // Zen Thermostat
{ VENDOR_C2DF, "3157100", emberMacPrefix }, // Centralite Thermostat
{ VENDOR_EMBER, "Super TR", emberMacPrefix }, // Elko Thermostat
{ VENDOR_DATEK_WIRLESS, "Super TR", silabs4MacPrefix }, // Elko Thermostat
{ VENDOR_EMBER, "ElkoDimmer", emberMacPrefix }, // Elko dimmer
{ VENDOR_ATMEL, "Thermostat", ecozyMacPrefix }, // eCozy Thermostat
{ VENDOR_OWON, "PR412C", emberMacPrefix }, // OWON PCT502 Thermostat
{ VENDOR_STELPRO, "ST218", xalMacPrefix }, // Stelpro Thermostat
{ VENDOR_STELPRO, "STZB402", xalMacPrefix }, // Stelpro baseboard thermostat
{ VENDOR_STELPRO, "SORB", xalMacPrefix }, // Stelpro Orleans Fan
{ VENDOR_DEVELCO, "FLSZB-1", develcoMacPrefix }, // Develco water leak sensor
{ VENDOR_DEVELCO, "EMIZB-1", develcoMacPrefix }, // Develco EMI Norwegian HAN
{ VENDOR_DEVELCO, "SMRZB-3", develcoMacPrefix }, // Develco Smart Relay DIN
{ VENDOR_DEVELCO, "SMRZB-1", develcoMacPrefix }, // Develco Smart Cable
{ VENDOR_DEVELCO, "SIRZB-1", develcoMacPrefix }, // Develco siren
{ VENDOR_DEVELCO, "ZHMS101", develcoMacPrefix }, // Wattle (Develco) magnetic sensor
{ VENDOR_DEVELCO, "MotionSensor51AU", develcoMacPrefix }, // Aurora (Develco) motion sensor
{ VENDOR_DEVELCO, "Smart16ARelay51AU", develcoMacPrefix }, // Aurora (Develco) smart plug
{ VENDOR_DATEK_WIRLESS, "PoP", konkeMacPrefix }, // Apex Smart Plug
{ VENDOR_EMBER, "3AFE14010402000D", konkeMacPrefix }, // Konke Kit Pro-BS Motion Sensor
{ VENDOR_KONKE, "3AFE28010402000D", ikea2MacPrefix }, // Konke Kit Pro-BS Motion Sensor ver.2
{ VENDOR_EMBER, "3AFE140103020000", konkeMacPrefix }, // Konke Kit Pro-FT Temp Humidity Sensor
{ VENDOR_KONKE, "3AFE220103020000", ikea2MacPrefix }, // Konke Kit Pro-BS Temp Humidity Sensor ver.2
{ VENDOR_KONKE, "3AFE220103020000", konkeMacPrefix }, // Konke Kit Pro-BS Temp Humidity Sensor ver ???
{ VENDOR_EMBER, "3AFE130104020015", konkeMacPrefix }, // Konke Kit Pro-Door Entry Sensor
{ VENDOR_EMBER, "ALCANTARA2 D1.00P1.01Z1.00", silabs5MacPrefix }, // Alcantara 2 acova
{ VENDOR_NONE, "RICI01", tiMacPrefix}, // LifeControl smart plug
{ VENDOR_JENNIC, "Adurolight_NCC", jennicMacPrefix}, // Eria Adurosmart Wireless Dimming Switch
{ VENDOR_JENNIC, "VOC_Sensor", jennicMacPrefix}, // LifeControl Enviroment sensor
{ VENDOR_JENNIC, "SN10ZW", jennicMacPrefix }, // ORVIBO motion sensor
{ VENDOR_JENNIC, "e70f96b3773a4c9283c6862dbafb6a99", jennicMacPrefix }, // ORVIBO open/close sensor SM11
{ VENDOR_OSRAM_STACK, "SF20", heimanMacPrefix }, // ORVIBO SF20 smoke sensor
// Danalock support
{ VENDOR_DANALOCK, "V3", silabs1MacPrefix}, // Danalock Smart Lock
// Schlage support
{ VENDOR_SCHLAGE, "BE468", schlageMacPrefix}, // Schlage BE468 Smart Lock
{ VENDOR_HEIMAN, "SF21", emberMacPrefix }, // ORVIBO SF21 smoke sensor
{ VENDOR_3A_SMART_HOME, "ST30 Temperature Sensor", jennicMacPrefix }, // Orvibo ST30 Temp/Humidity Sensor with display
{ VENDOR_EMBER, "ST30 Temperature Sensor", silabs9MacPrefix }, // Orvibo ST30 Temp/Humidity Sensor with display (alternate)
{ VENDOR_HEIMAN, "358e4e3e03c644709905034dae81433e", emberMacPrefix }, // Orvibo Combustible Gas Sensor
{ VENDOR_LEGRAND, "Dimmer switch w/o neutral", legrandMacPrefix }, // Legrand Dimmer switch wired
{ VENDOR_LEGRAND, "Connected outlet", legrandMacPrefix }, // Legrand Plug
{ VENDOR_LEGRAND, "Shutter switch with neutral", legrandMacPrefix }, // Legrand Shutter switch
{ VENDOR_LEGRAND, "Remote toggle switch", legrandMacPrefix }, // Legrand switch module
{ VENDOR_LEGRAND, "Cable outlet", legrandMacPrefix }, // Legrand Cable outlet
{ VENDOR_LEGRAND, "Remote switch", legrandMacPrefix }, // Legrand wireless switch
{ VENDOR_LEGRAND, "Double gangs remote switch", legrandMacPrefix }, // Legrand wireless double switch
{ VENDOR_LEGRAND, "Remote motion sensor", legrandMacPrefix }, // Legrand motion sensor
{ VENDOR_LEGRAND, "Shutters central remote switch", legrandMacPrefix }, // Legrand wireless shutter switch (battery)
{ VENDOR_LEGRAND, "DIN power consumption module", legrandMacPrefix }, // Legrand DIN power consumption module
{ VENDOR_LEGRAND, "Teleruptor", legrandMacPrefix }, // Legrand Teleruptor
{ VENDOR_LEGRAND, "Contactor", legrandMacPrefix }, // Legrand Contactor
{ VENDOR_LEGRAND, "Pocket remote", legrandMacPrefix }, // Legrand wireless 4 x scene remote
{ VENDOR_NETVOX, "Z809AE3R", netvoxMacPrefix }, // Netvox smartplug
{ VENDOR_LDS, "ZB-ONOFFPlug-D0005", silabs2MacPrefix }, // Samsung SmartPlug 2019 (7A-PL-Z-J3)
{ VENDOR_LDS, "ZBT-DIMSwitch", silabs2MacPrefix }, // Linkind 1 key Remote Control / ZS23000178
{ VENDOR_LDS, "ZB-KeypadGeneric-D0002", silabs3MacPrefix }, // Linkind Keypad / ZS130000078
{ VENDOR_LDS, "ZB-MotionSensor-D0003", silabsMacPrefix }, // Linkind motion sensor / ZS110040078
{ VENDOR_LDS, "ZB-DoorSensor-D0003", YooksmartMacPrefix }, // Linkind Door/Window Sensor / ZS110050078
{ VENDOR_LDS, "ZBT-DIMController-D0800", jennicMacPrefix }, // Mueller-Licht tint dimmer
{ VENDOR_PHYSICAL, "outletv4", stMacPrefix }, // Samsung SmartThings plug (IM6001-OTP)
{ VENDOR_EMBER, "RH3040", konkeMacPrefix }, // Tuyatec motion sensor
{ VENDOR_NONE, "RH3001", ikea2MacPrefix }, // Tuyatec door/window sensor
{ VENDOR_EMBER, "RH3001", silabs3MacPrefix }, // Tuya/Blitzwolf BW-IS2 door/window sensor
{ VENDOR_NONE, "RH3052", emberMacPrefix }, // Tuyatec temperature sensor
{ VENDOR_NONE, "RH3052", konkeMacPrefix }, // Tuyatec/Lupus temperature sensor
{ VENDOR_EMBER, "TS0201", silabs3MacPrefix }, // Tuya/Blitzwolf temperature and humidity sensor
{ VENDOR_EMBER, "TS0203", silabs12MacPrefix }, // tuya door windows sensor
{ VENDOR_NONE, "TS0204", silabs3MacPrefix }, // Tuya gas sensor
{ VENDOR_NONE, "TS0205", silabs3MacPrefix }, // Tuya smoke sensor
{ VENDOR_NONE, "TS0121", silabs3MacPrefix }, // Tuya/Blitzwolf smart plug
{ VENDOR_EMBER, "TS0121", silabs3MacPrefix }, // Tuya/Blitzwolf smart plug
{ VENDOR_EMBER, "TS0302", silabs3MacPrefix }, // Tuya curtain switch
{ VENDOR_EMBER, "TS0041", silabs3MacPrefix }, // Tuya wireless switch
{ VENDOR_EMBER, "TS0041", silabs5MacPrefix }, // Tuya wireless switch
{ VENDOR_EMBER, "TS0042", silabs3MacPrefix }, // Tuya wireless switch
{ VENDOR_EMBER, "TS0043", silabs3MacPrefix }, // Tuya wireless switch
{ VENDOR_EMBER, "TS0043", silabs8MacPrefix }, // Tuya wireless switch
{ VENDOR_EMBER, "TS0043", silabs7MacPrefix }, // Tuya wireless switch
{ VENDOR_EMBER, "TS0044", silabs9MacPrefix }, // Tuya wireless switch
{ VENDOR_EMBER, "TS004F", silabs8MacPrefix }, // Tuya wireless switch
{ VENDOR_NONE, "kud7u2l", silabs3MacPrefix }, // Tuya Smart TRV HY369 Thermostatic Radiator Valve
{ VENDOR_NONE, "GbxAXL2", silabs3MacPrefix }, // Another Tuya Smart TRV Thermostatic Radiator Valve
{ VENDOR_NONE, "w7cahqs", silabs8MacPrefix }, // hama Smart Radiator Thermostat
{ VENDOR_EMBER, "TS0601", silabs7MacPrefix }, // Tuya Smart TRV HY369 Thermostatic Radiator Valve
{ VENDOR_EMBER, "TS0601", silabs5MacPrefix }, // MOES Zigbee Radiator Actuator HY368 / Moes Tuya Thermostat BTH-002
{ VENDOR_EMBER, "TS0207", silabs3MacPrefix }, // Tuya water leak sensor
{ VENDOR_NONE, "TS0202", silabs4MacPrefix }, // Tuya presence sensor
{ VENDOR_EMBER, "TS0202", ikea2MacPrefix }, // Tuya multi sensor
{ VENDOR_NONE, "0yu2xgi", silabs5MacPrefix }, // Tuya siren
{ VENDOR_EMBER, "TS0601", silabs9MacPrefix }, // Tuya siren
{ VENDOR_EMBER, "TS0222", silabs9MacPrefix }, // TYZB01 light sensor
{ VENDOR_OWON, "CTHS317ET", casaiaPrefix }, // CASA.ia Temperature probe CTHS-317-ET
{ VENDOR_NONE, "eaxp72v", ikea2MacPrefix }, // Tuya TRV Wesmartify Thermostat Essentials Premium
{ VENDOR_EMBER, "TS011F", YooksmartMacPrefix }, // Tuya Plug Blitzwolf BW-SHP15
{ VENDOR_EMBER, "TS011F", silabs10MacPrefix }, // Other tuya plugs
{ VENDOR_NONE, "88teujp", silabs8MacPrefix }, // SEA802-Zigbee
{ VENDOR_NONE, "uhszj9s", silabs8MacPrefix }, // HiHome WZB-TRVL
{ VENDOR_NONE, "fvq6avy", silabs7MacPrefix }, // Revolt NX-4911-675 Thermostat
{ VENDOR_NONE, "GMB-HAS-WL-B01", tiMacPrefix }, // GamaBit Ltd. water leak Sensor
{ VENDOR_NONE, "GMB-HAS-DW-B01", tiMacPrefix }, // GamaBit Ltd. Window/Door Sensor
{ VENDOR_NONE, "GMB-HAS-VB-B01", tiMacPrefix }, // GamaBit Ltd. Vibration Sensor
{ VENDOR_HEIMAN, "TY0203", silabs3MacPrefix }, // Lidl/Silvercrest Smart Window or Door Sensor
{ VENDOR_HEIMAN, "TY0203", silabs7MacPrefix }, // Lidl/Silvercrest Smart Window or Door Sensor
{ VENDOR_HEIMAN, "TY0202", silabs3MacPrefix }, // Lidl/Silvercrest Smart Motion Sensor
{ VENDOR_HEIMAN, "TY0202", silabs7MacPrefix }, // Lidl/Silvercrest Smart Motion Sensor
{ VENDOR_HEIMAN, "TS0211", silabs3MacPrefix }, // Lidl/Silvercrest Smart Wireless Door Bell
{ VENDOR_HEIMAN, "TS0211", silabs5MacPrefix }, // Lidl/Silvercrest Smart Wireless Door Bell
{ VENDOR_HEIMAN, "TS0211", silabs7MacPrefix }, // Lidl/Silvercrest Smart Wireless Door Bell
{ VENDOR_HEIMAN, "TS0215", silabs3MacPrefix }, // Tuya IAS ACE remote control
{ VENDOR_AURORA, "DoubleSocket50AU", jennicMacPrefix }, // Aurora AOne Double Socket UK
{ VENDOR_COMPUTIME, "SP600", computimeMacPrefix }, // Salus smart plug
{ VENDOR_COMPUTIME, "SPE600", computimeMacPrefix }, // Salus smart plug
{ VENDOR_HANGZHOU_IMAGIC, "1116-S", energyMiMacPrefix }, // iris contact sensor v3
{ VENDOR_HANGZHOU_IMAGIC, "1117-S", energyMiMacPrefix }, // iris motion sensor v3
{ VENDOR_JENNIC, "113D", jennicMacPrefix }, // iHorn (Huawei) temperature and humidity sensor
{ VENDOR_CHINA_FIRE_SEC, "LH05121", jennicMacPrefix }, // iHorn (Huawei) smoke detector
{ VENDOR_SERCOMM, "SZ-ESW01", emberMacPrefix }, // Sercomm / Telstra smart plug
{ VENDOR_SERCOMM, "SZ-SRN12N", emberMacPrefix }, // Sercomm siren
{ VENDOR_SERCOMM, "SZ-SRN12N", energyMiMacPrefix }, // Sercomm siren
{ VENDOR_SERCOMM, "SZ-DWS04", emberMacPrefix }, // Sercomm open/close sensor
{ VENDOR_SERCOMM, "SZ-WTD02N_CAR", emberMacPrefix }, // Sercomm water sensor
{ VENDOR_SERCOMM, "GZ-PIR02", emberMacPrefix }, // Sercomm motion sensor
{ VENDOR_SERCOMM, "Tripper", emberMacPrefix }, // Quirky Tripper (Sercomm) open/close sensor
{ VENDOR_ALERTME, "MOT003", tiMacPrefix }, // Hive Motion Sensor
{ VENDOR_ALERTME, "DWS003", tiMacPrefix }, // Hive Door sensor
{ VENDOR_ALERTME, "SLP2", computimeMacPrefix }, // Hive plug
{ VENDOR_ALERTME, "SLP2b", computimeMacPrefix }, // Hive plug
{ VENDOR_ALERTME, "SLR1b", computimeMacPrefix }, // Hive Heating Receiver 1 channel
{ VENDOR_ALERTME, "SLR2", computimeMacPrefix }, // Hive Heating Receiver 2 channel
{ VENDOR_ALERTME, "SLR2b", computimeMacPrefix }, // Hive Heating Receiver 2 channel second version
{ VENDOR_ALERTME, "SLT2", computimeMacPrefix }, // Hive thermostat
{ VENDOR_ALERTME, "SLT3", computimeMacPrefix }, // Hive thermostat
{ VENDOR_SUNRICHER, "4512705", silabs2MacPrefix }, // Namron remote control
{ VENDOR_SUNRICHER, "4512726", silabs2MacPrefix }, // Namron rotary switch
{ VENDOR_SUNRICHER, "S57003", silabs2MacPrefix }, // SLC 4-ch remote controller
{ VENDOR_SENGLED_OPTOELEC, "E13-", zhejiangMacPrefix }, // Sengled PAR38 Bulbs
{ VENDOR_SENGLED_OPTOELEC, "E1D-", zhejiangMacPrefix }, // Sengled contact sensor
{ VENDOR_SENGLED_OPTOELEC, "E1E-", zhejiangMacPrefix }, // Sengled Smart Light Switch
{ VENDOR_SENGLED_OPTOELEC, "Z01-A19", zhejiangMacPrefix }, // Sengled SMART LED Z01-A19NAE26
{ VENDOR_JENNIC, "4in1-Sensor-ZB3.0", emberMacPrefix }, // Immax NEO ZB3.0 4 in 1 sensor
{ VENDOR_JENNIC, "DoorWindow-Sensor-ZB3.0", emberMacPrefix }, // Immax NEO ZB3.0 window/door sensor 07045L
{ VENDOR_WAXMAN, "leakSMART Water Sensor V2", celMacPrefix }, // WAXMAN LeakSMART v2
{ VENDOR_PHILIO, "PST03A-v2.2.5", emberMacPrefix }, // Philio pst03-a
{ VENDOR_EMBERTEC, "BQZ10-AU", embertecMacPrefix }, // Embertec smart plug
{ VENDOR_MUELLER, "ZBT-Remote-ALL-RGBW", jennicMacPrefix }, // Tint remote control
{ VENDOR_PLUGWISE_BV, "160-01", emberMacPrefix }, // Plugwise smart plug
{ VENDOR_NIKO_NV, "Smart plug Zigbee PE", silabs9MacPrefix }, // Niko Smart Plug 552-80699
{ VENDOR_ATMEL, "Bell", dishMacPrefix }, // Sage doorbell sensor
{ VENDOR_UNIVERSAL2, "4655BC0", emberMacPrefix }, // Ecolink contact sensor
{ VENDOR_NONE, "ZB-SmartPlug-1.0.0", tiMacPrefix }, // edp re:dy plug
{ VENDOR_NONE, "WB01", tiMacPrefix }, // Sonoff SNZB-01
{ VENDOR_NONE, "WB-01", tiMacPrefix }, // Sonoff SNZB-01
{ VENDOR_NONE, "MS01", tiMacPrefix }, // Sonoff SNZB-03
{ VENDOR_NONE, "MSO1", tiMacPrefix }, // Sonoff SNZB-03
{ VENDOR_NONE, "ms01", tiMacPrefix }, // Sonoff SNZB-03
{ VENDOR_NONE, "66666", tiMacPrefix }, // Sonoff SNZB-03
{ VENDOR_NONE, "TH01", tiMacPrefix }, // Sonoff SNZB-02
{ VENDOR_NONE, "DS01", tiMacPrefix }, // Sonoff SNZB-04
{ VENDOR_NONE, "DIYRuZ_Flower", tiMacPrefix }, // DIYRuZ_Flower
{ VENDOR_SCHNEIDER, "CCT591011_AS", emberMacPrefix }, // LK Wiser Door / Window Sensor
{ VENDOR_SCHNEIDER, "CCT592011_AS", emberMacPrefix }, // LK Wiser Water Leak Sensor
{ VENDOR_SCHNEIDER, "CCT593011_AS", emberMacPrefix }, // LK Wiser Temperature and Humidity Sensor
{ VENDOR_SCHNEIDER, "CCT595011_AS", emberMacPrefix }, // LK Wiser Motion Sensor
{ VENDOR_DANFOSS, "0x8020", silabs6MacPrefix }, // Danfoss RT24V Display thermostat
{ VENDOR_DANFOSS, "0x8021", silabs6MacPrefix }, // Danfoss RT24V Display thermostat with floor sensor
{ VENDOR_DANFOSS, "0x8030", silabs6MacPrefix }, // Danfoss RTbattery Display thermostat
{ VENDOR_DANFOSS, "0x8031", silabs6MacPrefix }, // Danfoss RTbattery Display thermostat with infrared
{ VENDOR_DANFOSS, "0x8034", silabs6MacPrefix }, // Danfoss RTbattery Dial thermostat
{ VENDOR_DANFOSS, "0x8035", silabs6MacPrefix }, // Danfoss RTbattery Dial thermostat with infrared
{ VENDOR_LDS, "ZBT-CCTSwitch-D0001", silabs2MacPrefix }, // Leedarson remote control
{ VENDOR_YALE, "YRD256 TSDB", emberMacPrefix }, // Yale YRD256 ZigBee keypad door lock
{ VENDOR_YALE, "YRD226 TSDB", emberMacPrefix }, // Yale YRD226 ZigBee keypad door lock
{ VENDOR_YALE, "YRD226/246 TSDB", emberMacPrefix }, // Yale YRD226 ZigBee keypad door lock
{ VENDOR_YALE, "YRD256L TSDB SL", emberMacPrefix }, // Yale YRD256L ZigBee keypad door lock
{ VENDOR_YALE, "YRD220/240 TSDB", emberMacPrefix }, // Yale
{ VENDOR_KWIKSET, "SMARTCODE_CONVERT_GEN1", zenMacPrefix }, // Kwikset 914 ZigBee smart lock
{ VENDOR_DSR, "easyCodeTouch_v1", onestiPrefix }, // EasyAccess EasyCodeTouch
{ VENDOR_EMBER, "TS1001", silabs5MacPrefix }, // LIDL Livarno Lux Remote Control HG06323
{ VENDOR_EMBER, "TS1001", silabs7MacPrefix }, // LIDL Livarno Lux Remote Control HG06323
{ VENDOR_XFINITY, "URC4450BC0-X-R", emberMacPrefix }, // Xfinity Keypad XHK1-UE / URC4450BC0-X-R
{ VENDOR_CENTRALITE, "3405-L", emberMacPrefix }, // IRIS 3405-L Keypad
{ 0, nullptr, 0 }
};
int TaskItem::_taskCounter = 1; // static rolling taskcounter
/*! Returns the largest supported API version.
There might be one, none or multiple versions listed in \p hdrValue:
Accept: nothing, relevant, here --> ApiVersion_1
Accept: vnd.ddel.v1 --> ApiVersion_1_DDEL
Accept: vnd.ddel.v1,vnd.ddel.v1.1 --> ApiVersion_1_1_DDEL
Accept: vnd.ddel.v2 --> ApiVersion_2_DDEL
Accept: vnd.ddel.v1,vnd.ddel.v2 --> ApiVersion_2_DDEL
*/
static ApiVersion getAcceptHeaderApiVersion(const QLatin1String &hdrValue)
{
ApiVersion result = { ApiVersion_1 };
struct ApiVersionMap {
ApiVersion version;
QLatin1String str;
};
static const std::array<ApiVersionMap, 6> versions = {
{
// ordered by largest version
{ ApiVersion_3_DDEL, QLatin1String("application/vnd.ddel.v3") },
{ ApiVersion_2_DDEL, QLatin1String("application/vnd.ddel.v2") },
{ ApiVersion_1_1_DDEL, QLatin1String("application/vnd.ddel.v1.1") },
{ ApiVersion_1_1_DDEL, QLatin1String("vnd.ddel.v1.1") }, // backward compatibility
{ ApiVersion_1_DDEL, QLatin1String("application/vnd.ddel.v1") },
{ ApiVersion_1_DDEL, QLatin1String("vnd.ddel.v1") } // backward compatibility
}
};
for (const auto &version : versions)
{
if (contains(hdrValue, version.str))
{
result = version.version;
break;
}
}
return result;
}
ApiRequest::ApiRequest(const QHttpRequestHeader &h, const QStringList &p, QTcpSocket *s, const QString &c) :
hdr(h), path(p), sock(s), content(c), version(ApiVersion_1), auth(ApiAuthNone), mode(ApiModeNormal)
{
const auto accept = hdr.value(QLatin1String("Accept"));
if (accept.size() > 4) // rule out */*
{
version = getAcceptHeaderApiVersion(accept);
}
}
/*! Returns the apikey of a request or a empty string if not available
*/
QString ApiRequest::apikey() const
{
if (path.length() > 1 && path[0] == QLatin1String("api"))
{
return path.at(1);
}
return QLatin1String("");
}
/*! Returns the next ZCL sequence number to use.
*/
quint8 zclNextSequenceNumber()
{
Q_ASSERT(plugin);
return plugin->zclSeq++;
}
/*! Returns deCONZ core node for a given \p extAddress.
*/
const deCONZ::Node *getCoreNode(uint64_t extAddress)
{
int i = 0;
const deCONZ::Node *result = nullptr;
const deCONZ::Node *node = nullptr;
deCONZ::ApsController *ctrl = deCONZ::ApsController::instance();
while (ctrl->getNode(i, &node) == 0)
{
if (node->address().ext() == extAddress)
{
result = node;
break;
}
i++;
}
return result;
}
/*! Constructor for pimpl.
\param parent - the main plugin
*/
DeRestPluginPrivate::DeRestPluginPrivate(QObject *parent) :
QObject(parent),
apsCtrlWrapper(deCONZ::ApsController::instance())
{
plugin = this;
ScratchMemInit();
DEV_SetTestManaged(deCONZ::appArgumentNumeric("--dev-test-managed", 0));
#ifdef DECONZ_DEBUG_BUILD
EventTestZclPacking();
#endif
pollManager = new PollManager(this);
databaseTimer = new QTimer(this);
databaseTimer->setSingleShot(true);
eventEmitter = new EventEmitter(this);
connect(eventEmitter, &EventEmitter::eventNotify, this, &DeRestPluginPrivate::handleEvent);
initResourceDescriptors();
restDevices = new RestDevices(this);
connect(restDevices, &RestDevices::eventNotify, eventEmitter, &EventEmitter::enqueueEvent);
connect(eventEmitter, &EventEmitter::eventNotify, restDevices, &RestDevices::handleEvent);
alarmSystemDeviceTable.reset(new AS_DeviceTable);
alarmSystems.reset(new AlarmSystems);
deviceJs = new DeviceJs();
deviceDescriptions = new DeviceDescriptions(this);
connect(deviceDescriptions, &DeviceDescriptions::eventNotify, eventEmitter, &EventEmitter::enqueueEvent);
connect(eventEmitter, &EventEmitter::eventNotify, deviceDescriptions, &DeviceDescriptions::handleEvent);
{
QSettings config(deCONZ::getStorageLocation(deCONZ::ConfigLocation), QSettings::IniFormat);
int filterBronze = config.value("ddf-filter/bronze", 0).toInt();
int filterSilver = config.value("ddf-filter/silver", 0).toInt();
int filterGold = config.value("ddf-filter/gold", 1).toInt();
QStringList filter;
if (filterBronze) { filter.append("Bronze"); }
if (filterSilver) { filter.append("Silver"); }
if (filterGold)
{
filter.append("Gold");
}
else
{
DBG_Printf(DBG_INFO, "Warning: DDF Gold status is not enabled\n");
}
deviceDescriptions->setEnabledStatusFilter(filter);
}
connect(databaseTimer, SIGNAL(timeout()),
this, SLOT(saveDatabaseTimerFired()));
webSocketServer = 0;
gwScanner = new GatewayScanner(this);
connect(gwScanner, SIGNAL(foundGateway(QHostAddress,quint16,QString,QString)),
this, SLOT(foundGateway(QHostAddress,quint16,QString,QString)));
// gwScanner->startScan();
QString dataPath = deCONZ::getStorageLocation(deCONZ::ApplicationsDataLocation);
saveDatabaseItems = 0;
saveDatabaseIdleTotalCounter = 0;
dbZclValueMaxAge = 0; // default disable
sqliteDatabaseName = dataPath + QLatin1String("/zll.db");
idleLimit = 0;
idleTotalCounter = IDLE_READ_LIMIT;
idleLastActivity = 0;
idleUpdateZigBeeConf = idleTotalCounter + 15;
queryTime = QTime::currentTime();
udpSock = 0;
haEndpoint = 0;
gwGroupSendDelay = deCONZ::appArgumentNumeric("--group-delay", GROUP_SEND_DELAY);
gwLinkButton = false;
gwWebSocketNotifyAll = true;
gwdisablePermitJoinAutoOff = false;
gwLightLastSeenInterval = 60;
// preallocate memory to get consistent pointers
nodes.reserve(300);
sensors.reserve(150);
fastProbeTimer = new QTimer(this);
fastProbeTimer->setInterval(500);
fastProbeTimer->setSingleShot(true);
connect(fastProbeTimer, SIGNAL(timeout()), this, SLOT(delayedFastEnddeviceProbe()));
apsCtrl = deCONZ::ApsController::instance();
apsCtrl->setParameter(deCONZ::ParamOtauActive, 0);
// starttime reference counts from here
starttimeRef.start();
initConfig();
updateEtag(gwConfigEtag);
updateEtag(gwSensorsEtag);
updateEtag(gwGroupsEtag);
updateEtag(gwLightsEtag);
// set some default might be overwritten by database
gwAnnounceInterval = ANNOUNCE_INTERVAL;
gwAnnounceUrl = "https://phoscon.de/discover";
inetDiscoveryManager = nullptr;
webhookManager = new QNetworkAccessManager(this);
connect(webhookManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(webhookFinishedRequest(QNetworkReply*)));
// lights
searchLightsState = SearchLightsIdle;
searchLightsTimeout = 0;
// sensors
sensorCheckIter = 0;
searchSensorsState = SearchSensorsIdle;
searchSensorsTimeout = 0;
ttlDataBaseConnection = 0;
openDb();
initDb();
deviceDescriptions->prepare();
deviceDescriptions->readAll();
readDb();
DB_LoadAlarmSystemDevices(alarmSystemDeviceTable.get());
DB_LoadAlarmSystems(*alarmSystems, alarmSystemDeviceTable.get(), eventEmitter);
AS_InitDefaultAlarmSystem(*alarmSystems, alarmSystemDeviceTable.get(), eventEmitter);
closeDb();
initTimezone();
checkConsistency();
if (!gwUserParameter.contains("groupssequenceleft"))
{
gwUserParameter["groupssequenceleft"] = "[]";
}
if (!gwUserParameter.contains("groupssequenceright"))
{
gwUserParameter["groupssequenceright"] = "[]";
}
if (gwUuid.isEmpty())
{
generateGatewayUuid();
}
// create default group
// get new id
if (gwGroup0 == 0)
{
for (uint16_t i = 0xFFF0; i > 0; i--) // 0 and larger than 0xfff7 is not valid for Osram Lightify
{
Group* group = getGroupForId(i);
if (!group)
{
gwGroup0 = i;
break;
}
}
}
// delete old group 0
if (gwGroup0 != 0)
{
for (Group& group : groups)
{
if (group.address() == 0 && !(group.state() == Group::StateDeleted || group.state() == Group::StateDeleteFromDB))
{
group.setState(Group::StateDeleted);
queSaveDb(DB_CONFIG | DB_GROUPS, DB_LONG_SAVE_DELAY);
break;
}
}
}
// create new group 0
Group* group = getGroupForId(gwGroup0);
if (!group)
{
Group group;
group.setAddress(gwGroup0);
group.setName("All");
groups.push_back(group);
queSaveDb(DB_GROUPS, DB_LONG_SAVE_DELAY);
}
connect(apsCtrl, SIGNAL(apsdeDataConfirm(deCONZ::ApsDataConfirm)),
this, SLOT(apsdeDataConfirm(deCONZ::ApsDataConfirm)));
connect(apsCtrl, SIGNAL(apsdeDataIndication(deCONZ::ApsDataIndication)),
this, SLOT(apsdeDataIndication(deCONZ::ApsDataIndication)));
connect(apsCtrl, SIGNAL(apsdeDataRequestEnqueued(deCONZ::ApsDataRequest)),
this, SLOT(apsdeDataRequestEnqueued(deCONZ::ApsDataRequest)));
connect(apsCtrl, SIGNAL(nodeEvent(deCONZ::NodeEvent)),
this, SLOT(nodeEvent(deCONZ::NodeEvent)));
connect(apsCtrl, SIGNAL(sourceRouteCreated(deCONZ::SourceRoute)), this, SLOT(storeSourceRoute(deCONZ::SourceRoute)));
connect(apsCtrl, SIGNAL(sourceRouteDeleted(QString)), this, SLOT(deleteSourceRoute(QString)));
connect(apsCtrl, SIGNAL(nodesRestored()), this, SLOT(restoreSourceRoutes()), Qt::QueuedConnection);
deCONZ::GreenPowerController *gpCtrl = deCONZ::GreenPowerController::instance();
if (gpCtrl)
{
bool ok =
connect(gpCtrl, SIGNAL(gpDataIndication(deCONZ::GpDataIndication)),
this, SLOT(gpDataIndication(deCONZ::GpDataIndication)));
DBG_Assert(ok);
}
taskTimer = new QTimer(this);
taskTimer->setSingleShot(false);
connect(taskTimer, SIGNAL(timeout()),
this, SLOT(processTasks()));
taskTimer->start(100);
groupTaskTimer = new QTimer(this);
groupTaskTimer->setSingleShot(false);
connect(groupTaskTimer, SIGNAL(timeout()),
this, SLOT(processGroupTasks()));
groupTaskTimer->start(250);
fastRuleCheckTimer = new QTimer(this);
fastRuleCheckTimer->setInterval(5);
fastRuleCheckTimer->setSingleShot(true);
connect(fastRuleCheckTimer, SIGNAL(timeout()),
this, SLOT(fastRuleCheckTimerFired()));
checkSensorsTimer = new QTimer(this);
checkSensorsTimer->setSingleShot(false);
checkSensorsTimer->setInterval(CHECK_SENSOR_INTERVAL);
connect(checkSensorsTimer, SIGNAL(timeout()),
this, SLOT(checkSensorStateTimerFired()));
checkSensorsTimer->start();
sensorCheckFast = 0;
bindingTimer = new QTimer(this);
bindingTimer->setSingleShot(true);
bindingTimer->setInterval(1000);
connect(bindingTimer, SIGNAL(timeout()),
this, SLOT(bindingTimerFired()));
bindingTableReaderTimer = new QTimer(this);
bindingTableReaderTimer->setSingleShot(true);
bindingTableReaderTimer->setInterval(1000);
connect(bindingTableReaderTimer, SIGNAL(timeout()),
this, SLOT(bindingTableReaderTimerFired()));
lockGatewayTimer = new QTimer(this);
lockGatewayTimer->setSingleShot(true);
connect(lockGatewayTimer, SIGNAL(timeout()),
this, SLOT(lockGatewayTimerFired()));
openClientTimer = new QTimer(this);
openClientTimer->setSingleShot(false);
connect(openClientTimer, SIGNAL(timeout()),
this, SLOT(openClientTimerFired()));
openClientTimer->start(1000);
quint16 wsPort = deCONZ::appArgumentNumeric(QLatin1String("--ws-port"), gwConfig["websocketport"].toUInt());
webSocketServer = new WebSocketServer(this, wsPort);
gwConfig["websocketport"] = webSocketServer->port();
initNetworkInfo();
initUpnpDiscovery();
initAuthentication();
initInternetDicovery();
initSchedules();
initPermitJoin();
initOtau();
initTouchlinkApi();
initChangeChannelApi();
initResetDeviceApi();
initFirmwareUpdate();
//restoreWifiState();
needRuleCheck = RULE_CHECK_DELAY;
QTimer::singleShot(3000, this, SLOT(initWiFi()));
connect(pollManager, &PollManager::done, this, &DeRestPluginPrivate::pollNextDevice);
auto *deviceTick = new DeviceTick(m_devices, this);
connect(eventEmitter, &EventEmitter::eventNotify, deviceTick, &DeviceTick::handleEvent);
connect(deviceTick, &DeviceTick::eventNotify, eventEmitter, &EventEmitter::enqueueEvent);
const deCONZ::Node *node;
if (apsCtrl && apsCtrl->getNode(0, &node) == 0)
{
addLightNode(node);
}
const QStringList buttonMapLocations = {
deCONZ::getStorageLocation(deCONZ::ApplicationsDataLocation) + QLatin1String("/devices/button_maps.json")
#ifdef Q_OS_LINUX
, "/usr/share/deCONZ/devices/button_maps.json"
#endif
#ifdef Q_OS_WIN
, qApp->applicationDirPath() + QLatin1String("/../devices/button_maps.json")
#endif
#if defined (__APPLE__)
, qApp->applicationDirPath() + QLatin1String("/../Resources/devices/button_maps.json")
#endif
};
for (const auto &path : buttonMapLocations)
{
if (!QFile::exists(path))
{
continue;
}
QStringList requiredJsonObjects = {"buttons", "buttonActions", "clusters", "commands", "maps"};
QJsonDocument buttonMapsDoc = readButtonMapJson(path);
if (checkRootLevelObjectsJson(buttonMapsDoc, requiredJsonObjects))
{
btnMapClusters = loadButtonMapClustersJson(buttonMapsDoc);
btnMapClusterCommands = loadButtonMapCommadsJson(buttonMapsDoc);
buttonMaps = loadButtonMapsJson(buttonMapsDoc, btnMapClusters, btnMapClusterCommands);
buttonMeta = loadButtonMetaJson(buttonMapsDoc, buttonMaps);
buttonProductMap = loadButtonMapModelIdsJson(buttonMapsDoc, buttonMaps);
break; // only load once
}
}
}
/*! Deconstructor for pimpl.
*/
DeRestPluginPrivate::~DeRestPluginPrivate()
{
plugin = nullptr;
if (inetDiscoveryManager)
{
inetDiscoveryManager->deleteLater();
inetDiscoveryManager = 0;
}
delete deviceJs;
deviceJs = nullptr;
eventEmitter = nullptr;
ScratchMemDestroy();
}
DeRestPluginPrivate *DeRestPluginPrivate::instance()
{
DBG_Assert(plugin);
return plugin;
}
void DeRestPluginPrivate::apsdeDataIndicationDevice(const deCONZ::ApsDataIndication &ind, Device *device)
{
if (!device)
{
return;
}
if (!device->item(RCapSleeper)->toBool())
{
auto *item = device->item(RStateReachable);
if (!item->toBool())
{
item->setValue(true);
enqueueEvent(Event(device->prefix(), item->descriptor().suffix, 0, device->key()));
}
}
deCONZ::ZclFrame zclFrame;
if (ind.profileId() == HA_PROFILE_ID || ind.profileId() == ZLL_PROFILE_ID)
{
QDataStream stream(ind.asdu());
stream.setByteOrder(QDataStream::LittleEndian);
zclFrame.readFromStream(stream);
if (!zclFrame.isProfileWideCommand())
{
if (zclFrame.frameControl() & deCONZ::ZclFCDirectionServerToClient)
{
// Keep Device poll state machine happy for non profile wide responses.
// There a response is assumed by 'server to client' direction.
// The status is set to SUCCESS since not all responses contain a status field.
enqueueEvent(Event(device->prefix(), REventZclResponse, EventZclResponsePack(ind.clusterId(), zclFrame.sequenceNumber(), deCONZ::ZclSuccessStatus), device->key()));
}
}
else if (zclFrame.commandId() == deCONZ::ZclReadAttributesResponseId && zclFrame.payload().size() >= 3)
{
const auto status = quint8(zclFrame.payload().at(2));
enqueueEvent(Event(device->prefix(), REventZclResponse, EventZclResponsePack(ind.clusterId(), zclFrame.sequenceNumber(), status), device->key()));
}
else if (zclFrame.commandId() == deCONZ::ZclConfigureReportingResponseId && zclFrame.payload().size() >= 1)
{
const auto status = quint8(zclFrame.payload().at(0));
enqueueEvent(Event(device->prefix(), REventZclResponse, EventZclResponsePack(ind.clusterId(), zclFrame.sequenceNumber(), status), device->key()));
}