-
Notifications
You must be signed in to change notification settings - Fork 364
/
Copy pathdevices.py
4318 lines (4270 loc) · 236 KB
/
devices.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
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
"""
Each device has a specification:
{
"<model>": ["<brand>", "<name>", "<market model>", "<other model>"],
"spec": [<list of converters>],
"ttl": <time to live>
}
- model - `lumi.xxx` for Zigbee devices, number (pdid) for BLE and Mesh devices
- spec - list of converters
- ttl - optional available timeout
Each converter has:
Converter(<attribute name>, <hass domain>, <mi name>)
- attribute - required, entity or attribute name in Hass
- domain - optional, hass entity type (`sensor`, `switch`, `binary_sensor`...)
- mi - optional, item name in:
- Lumi spec `mi="8.0.2012"`
- MIoT spec `mi="2.p.1"` or `mi="2.e.1"` or `mi="3.e.1012.p.1"`
- MiBeacon spec `mi=4100`
Old Zigbee devices uses Lumi format, new Zigbee 3 and Mesh devices uses MIoT format.
Converter may have different types:
- BaseConv - default, don't change/convert value
- BoolConv - converts int to bool on decode and bool to int on encode
- MapConv - translate value using mapping: `{0: "disarmed", 1: "armed_home"}`
- MathConv - support multiply, round value and min/max borders
- and many others...
For MIoT bool properties you should use `BaseConv`. For MIoT uint8 properties you
should use `BoolConv`.
If converter has `entity=ENTITY_LAZY` - it will work, but entity will setup only with
first data from device. Useful if we don't know exact spec of device. Example, battery
not exist on some firmwares of some devices.
The name of the attribute defines the device class, icon and unit of measure.
Recommended attributes names:
- `motion` - the sensor can only send motion detection (timeout in Hass)
- `occupancy` - the sensor can send motion start and motion stop
- `plug` - for sockets with male connector
- `outlet` - for sockets with only female connector (wall installation)
- `switch` - for relays and switches with buttons (wall installation, remotes)
- `led` - control device led light
- `wireless` - change mode from wired to wireless (decoupled)
- `power_on_state` - default state when electricity is supplied
- `contact` - for door/windor sensor (zigbee2mqtt - contact, hass - door or window)
- `water_leak` - for water leak sensor (zigbee2mqtt - water_leak, hass - moisture)
Nice project with MIoT spec description: https://home.miot-spec.com/
"""
from .converters.base import *
from .converters.const import *
from .converters.lumi import *
from .converters.mesh import *
from .converters.mibeacon import *
from .converters.zigbee import *
# Disable Black formatter and ignore line width
# fmt: off
# Gateways (lumi and miot specs)
DEVICES = [{
"lumi.gateway.mgl03": ["Xiaomi", "Multimode Gateway", "ZNDMWG03LM", "ZNDMWG02LM", "YTC4044GL"],
"spec": [
# write pair=60 => report discovered_mac => report 8.0.2166? => write pair_command => report added_device => write pair=0
MapConv("pair", mi="8.0.2109", map={60: True, 0: False}),
BaseConv("discovered_mac", mi="8.0.2110"),
BaseConv("pair_command", mi="8.0.2111"),
BaseConv("added_device", mi="8.0.2084"),
BaseConv("remove_did", mi="8.0.2082"),
BaseConv("z3_version", mi="8.0.2080"), # can be read
BaseConv("z3_info", mi="8.0.2166"),
BaseConv("ota", mi="8.0.2091"), # percent
# support change with remote.send_command
BaseConv("power_tx", mi="8.0.2012"),
BaseConv("channel", mi="8.0.2024"),
BaseConv("command", "select"),
BaseConv("data", "select"),
MapConv("alarm", "alarm_control_panel", mi="3.p.1", map={0: "disarmed", 1: "armed_home", 2: "armed_away", 3: "armed_night"}),
BoolConv("alarm_trigger", "switch", mi="3.p.22"),
BoolConv("led", "switch", mi="6.p.6"),
],
}, {
"lumi.gateway.aqcn02": ["Aqara", "Hub E1 CN", "ZHWG16LM"],
"lumi.gateway.aqcn03": ["Aqara", "Hub E1 EU", "HE1-G01"],
"lumi.gateway.mcn001": ["Xiaomi", "Multimode Gateway 2 CN", "DMWG03LM"],
"lumi.gateway.mgl001": ["Xiaomi", "Multimode Gateway 2 EU", "ZNDMWG04LM", "BHR6765GL"],
"spec": [
MapConv("pair", mi="8.0.2109", map={60: True, 0: False}),
BaseConv("discovered_mac", mi="8.0.2110"),
BaseConv("pair_command", mi="8.0.2111"),
BaseConv("added_device", mi="8.0.2084"),
BaseConv("remove_did", mi="8.0.2082"), # support change
BaseConv("power_tx", mi="8.0.2012"), # support change
BaseConv("channel", mi="8.0.2024"), # support change
BaseConv("pan_id", mi="8.0.2157"),
BaseConv("command", "select"),
BaseConv("data", "select"),
MapConv("led", "light", mi="6.p.1", map={0: True, 1: False}, entity=ENTITY_CONFIG), # dnd mode for mgl001
BrightnessConv("brightness", mi="6.p.3"), # works only for Multimode 2
BaseConv("action", "sensor", entity=ENTITY_DISABLED),
ConstConv("action", mi="4.e.1", value=BUTTON_SINGLE),
ConstConv("action", mi="4.e.2", value=BUTTON_DOUBLE),
ConstConv("action", mi="4.e.3", value=BUTTON_HOLD),
],
}]
# Zigbee (lumi spec)
DEVICES += [{
# don't work: protect 8.0.2014, power 8.0.2015, plug_detection 8.0.2044
"lumi.plug": ["Xiaomi", "Plug CN", "ZNCZ02LM"], # tested
"lumi.plug.mitw01": ["Xiaomi", "Plug TW", "ZNCZ03LM"],
"lumi.plug.maus01": ["Xiaomi", "Plug US", "ZNCZ12LM"],
"support": 5, # @AlexxIT
"spec": [
BoolConv("plug", "switch", mi="4.1.85"),
MathConv("power", "sensor", mi="0.12.85", round=2),
MathConv("energy", "sensor", mi="0.13.85", multiply=0.001, round=2),
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "off", 1: "previous"}), # config
BoolConv("charge_protect", "switch", mi="8.0.2031"), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
# Converter("max_power", "sensor", mi="8.0.2042", entity=ENTITY_DISABLED),
],
}, {
"lumi.plug.mmeu01": ["Xiaomi", "Plug EU", "ZNCZ04LM"],
"spec": [
BoolConv("plug", "switch", mi="4.1.85"),
MathConv("power", "sensor", mi="0.12.85", round=2),
MathConv("voltage", "sensor", mi="0.11.85", multiply=0.001, round=2),
MathConv("energy", "sensor", mi="0.13.85", multiply=0.001, round=2),
BoolConv("plug_detection", "binary_sensor", mi="8.0.2044"),
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "off", 1: "previous"}), # config
],
}, {
"lumi.ctrl_86plug.aq1": ["Aqara", "Wall Outlet", "QBCZ11LM"],
"lumi.ctrl_86plug": ["Aqara", "Wall Outlet", "QBCZ11LM"],
"spec": [
BoolConv("outlet", "switch", mi="4.1.85"),
MathConv("power", "sensor", mi="0.12.85", round=2),
MathConv("energy", "sensor", mi="0.13.85", multiply=0.001, round=2),
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "off", 1: "previous"}), # config
BoolConv("charge_protect", "switch", mi="8.0.2031"), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
BoolConv("wireless", "switch", mi="4.10.85"), # config
],
}, {
"lumi.ctrl_ln1.aq1": ["Aqara", "Single Wall Switch", "QBKG11LM"],
"lumi.ctrl_ln1": ["Aqara", "Single Wall Switch", "QBKG11LM"],
"lumi.switch.b1nacn02": ["Aqara", "Single Wall Switch D1 (with N)", "QBKG23LM"],
"spec": [
BoolConv("switch", "switch", mi="4.1.85"),
MathConv("power", "sensor", mi="0.12.85", round=2),
MathConv("energy", "sensor", mi="0.13.85", multiply=0.001, round=2),
BaseConv("action", "sensor"),
ButtonConv("button", mi="13.1.85"),
BoolConv("wireless", "switch", mi="4.10.85"), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
],
}, {
"lumi.ctrl_neutral1": ["Aqara", "Single Wall Switch", "QBKG04LM"],
"lumi.switch.b1lacn02": ["Aqara", "Single Wall Switch D1 (no N)", "QBKG21LM"],
"spec": [
BoolConv("switch", "switch", mi="4.1.85"),
BaseConv("action", "sensor"),
ButtonConv("button", mi="13.1.85"),
BoolConv("wireless", "switch", mi="4.10.85"), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
],
}, {
# dual channel on/off, power measurement
"lumi.ctrl_ln2.aq1": ["Aqara", "Double Wall Switch", "QBKG12LM"],
"lumi.ctrl_ln2": ["Aqara", "Double Wall Switch", "QBKG12LM"],
"lumi.switch.b2nacn02": ["Aqara", "Double Wall Switch D1 (with N)", "QBKG24LM"],
"spec": [
BoolConv("channel_1", "switch", mi="4.1.85"),
BoolConv("channel_2", "switch", mi="4.2.85"),
MathConv("power", "sensor", mi="0.12.85", round=2),
MathConv("energy", "sensor", mi="0.13.85", multiply=0.001, round=2),
BaseConv("action", "sensor"),
ButtonConv("button_1", mi="13.1.85"),
ButtonConv("button_2", mi="13.2.85"),
ButtonConv("button_both", mi="13.5.85"),
BoolConv("wireless_1", "switch", mi="4.10.85"), # config
BoolConv("wireless_2", "switch", mi="4.11.85"), # config
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "off", 1: "previous"}), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
],
}, {
"lumi.relay.c2acn01": ["Aqara", "Relay CN", "LLKZMK11LM"], # tested
"support": 4, # @AlexxIT
"spec": [
BoolConv("channel_1", "switch", mi="4.1.85"),
BoolConv("channel_2", "switch", mi="4.2.85"),
MathConv("current", "sensor", mi="0.14.85", multiply=0.001, round=2),
MathConv("power", "sensor", mi="0.12.85", round=2),
MathConv("voltage", "sensor", mi="0.11.85", multiply=0.001, round=2),
MathConv("energy", "sensor", mi="0.13.85", multiply=0.001, round=2),
BaseConv("action", "sensor"),
ButtonConv("button_1", mi="13.1.85"),
ButtonConv("button_2", mi="13.2.85"),
ButtonConv("button_both", mi="13.5.85"),
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "off", 1: "previous"}), # config
BoolConv("interlock", "switch", mi="4.9.85", entity=ENTITY_CONFIG),
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
],
}, {
"lumi.ctrl_neutral2": ["Aqara", "Double Wall Switch (no N)", "QBKG03LM"],
"lumi.switch.b2lacn02": ["Aqara", "Double Wall Switch D1 (no N)", "QBKG22LM"],
"spec": [
BoolConv("channel_1", "switch", mi="4.1.85"),
BoolConv("channel_2", "switch", mi="4.2.85"),
BaseConv("action", "sensor"),
ButtonConv("button_1", mi="13.1.85"),
ButtonConv("button_2", mi="13.2.85"),
ButtonConv("button_both", mi="13.5.85"),
BoolConv("wireless_1", "switch", mi="4.10.85"), # config
BoolConv("wireless_2", "switch", mi="4.11.85"), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
],
}, {
# triple channel on/off, no neutral wire
"lumi.switch.l3acn3": ["Aqara", "Triple Wall Switch D1 (no N)", "QBKG25LM"],
"spec": [
BoolConv("channel_1", "switch", mi="4.1.85"),
BoolConv("channel_2", "switch", mi="4.2.85"),
BoolConv("channel_3", "switch", mi="4.3.85"),
BaseConv("action", "sensor"),
ButtonConv("button_1", mi="13.1.85"),
ButtonConv("button_2", mi="13.2.85"),
ButtonConv("button_3", mi="13.3.85"),
ButtonConv("button_both_12", mi="13.5.85"),
ButtonConv("button_both_13", mi="13.6.85"),
ButtonConv("button_both_23", mi="13.7.85"),
BoolConv("wireless_1", "switch", mi="4.10.85"), # config
BoolConv("wireless_2", "switch", mi="4.11.85"), # config
BoolConv("wireless_3", "switch", mi="4.12.85"), # config
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "off", 1: "previous"}), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
],
}, {
# with neutral wire, thanks @Mantoui
"lumi.switch.n3acn3": ["Aqara", "Triple Wall Switch D1 (with N)", "QBKG26LM"],
"spec": [
BoolConv("channel_1", "switch", mi="4.1.85"),
BoolConv("channel_2", "switch", mi="4.2.85"),
BoolConv("channel_3", "switch", mi="4.3.85"),
MathConv("power", "sensor", mi="0.12.85", round=2),
MathConv("voltage", "sensor", mi="0.11.85", multiply=0.001, round=2),
MathConv("energy", "sensor", mi="0.13.85", multiply=0.001, round=2),
BaseConv("action", "sensor"),
ButtonConv("button_1", mi="13.1.85"),
ButtonConv("button_2", mi="13.2.85"),
ButtonConv("button_3", mi="13.3.85"),
ButtonConv("button_both_12", mi="13.5.85"),
ButtonConv("button_both_13", mi="13.6.85"),
ButtonConv("button_both_23", mi="13.7.85"),
BoolConv("wireless_1", "switch", mi="4.10.85"), # config
BoolConv("wireless_2", "switch", mi="4.11.85"), # config
BoolConv("wireless_3", "switch", mi="4.12.85"), # config
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "off", 1: "previous"}), # config
BoolConv("led", "switch", mi="8.0.2032"), # config
],
}, {
# we are using lumi+zigbee converters for support heartbeats and transition
# light with brightness and color temp
"lumi.light.cwopcn02": ["Aqara", "Opple MX650 CN", "XDD12LM"],
"lumi.light.cwopcn03": ["Aqara", "Opple MX480 CN", "XDD13LM"],
"ikea.light.led1545g12": ["IKEA", "Bulb E27 980 lm", "LED1545G12"],
"ikea.light.led1546g12": ["IKEA", "Bulb E27 950 lm", "LED1546G12"],
"ikea.light.led1536g5": ["IKEA", "Bulb E14 400 lm", "LED1536G5"],
"ikea.light.led1537r6": ["IKEA", "Bulb GU10 400 lm", "LED1537R6"],
"spec": [
BoolConv("light", "light", mi="4.1.85"),
ZLumiBrightness("brightness", mi="14.1.85"),
ZLumiColorTemp("color_temp", mi="14.2.85"),
ZTransitionConv("transition"),
],
}, {
"lumi.light.aqcn02": ["Aqara", "Bulb CN", "ZNLDP12LM"],
"spec": [
BoolConv("light", "light", mi="4.1.85"),
ZLumiBrightness("brightness", mi="14.1.85"),
ZLumiColorTemp("color_temp", mi="14.2.85"),
ZTransitionConv("transition"),
MapConv("power_on_state", "select", mi="8.0.2030", map={0: "on", 1: "previous"}), # config
],
}, {
# light with brightness
"ikea.light.led1623g12": ["IKEA", "Bulb E27 1000 lm", "LED1623G12"],
"ikea.light.led1650r5": ["IKEA", "Bulb GU10 400 lm", "LED1650R5"],
"ikea.light.led1649c5": ["IKEA", "Bulb E14 400 lm", "LED1649C5"], # tested
"spec": [
BoolConv("light", "light", mi="4.1.85"),
ZLumiBrightness("brightness", mi="14.1.85"),
ZTransitionConv("transition"),
],
}, {
# button action, no retain
"lumi.sensor_switch": ["Xiaomi", "Button", "WXKG01LM"],
"lumi.remote.b1acn01": ["Aqara", "Button CN", "WXKG11LM"],
"lumi.sensor_switch.aq2": ["Aqara", "Button", "WXKG11LM"],
"lumi.sensor_switch.aq3": ["Aqara", "Shake Button", "WXKG12LM"],
"lumi.remote.b186acn01": ["Aqara", "Single Wall Button CN", "WXKG03LM"],
"lumi.remote.b186acn02": ["Aqara", "Single Wall Button D1 CN", "WXKG06LM"],
"lumi.sensor_86sw1": ["Aqara", "Single Wall Button", "WXKG03LM"],
"spec": [
BaseConv("action", "sensor"),
ButtonConv("button", mi="13.1.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BoolConv("battery_low", "binary_sensor", mi="8.0.9001"), # diagnostic
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
],
}, {
# multi button action, no retain
"lumi.sensor_86sw2.es1": ["Aqara", "Double Wall Button", "WXKG02LM"],
"lumi.sensor_86sw2": ["Aqara", "Double Wall Button", "WXKG02LM"],
"lumi.remote.b286acn01": ["Aqara", "Double Wall Button CN", "WXKG02LM"],
"lumi.remote.b286acn02": ["Aqara", "Double Wall Button D1 CN", "WXKG07LM"],
"spec": [
BaseConv("action", "sensor"),
ButtonConv("button_1", mi="13.1.85"),
ButtonConv("button_2", mi="13.2.85"),
ButtonConv("button_both", mi="13.5.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BoolConv("battery_low", "binary_sensor", mi="8.0.9001"), # diagnostic
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
],
}, {
"lumi.remote.b286opcn01": ["Aqara", "Opple Two Button CN", "WXCJKG11LM"],
"lumi.remote.b486opcn01": ["Aqara", "Opple Four Button CN", "WXCJKG12LM"],
"lumi.remote.b686opcn01": ["Aqara", "Opple Six Button CN", "WXCJKG13LM"],
"spec": [
BaseConv("action", "sensor"),
ButtonConv("button_1", mi="13.1.85"),
ButtonConv("button_2", mi="13.2.85"),
ButtonConv("button_3", mi="13.3.85"),
ButtonConv("button_4", mi="13.4.85"),
ButtonConv("button_5", mi="13.6.85"),
ButtonConv("button_6", mi="13.7.85"),
ButtonConv("button_both", mi="13.5.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
ZLumiOppleMode("mode", "select"), # config
BoolConv("battery_low", "binary_sensor", mi="8.0.9001"), # diagnostic
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
],
}, {
# temperature and humidity sensor
"lumi.sensor_ht": ["Xiaomi", "TH Sensor", "WSDCGQ01LM"],
"spec": [
MathConv("temperature", "sensor", mi="0.1.85", multiply=0.01, min=-4000, max=12500),
MathConv("humidity", "sensor", mi="0.2.85", multiply=0.01, min=0, max=10000),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BoolConv("battery_low", "binary_sensor", mi="8.0.9001"), # diagnostic
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
],
}, {
# temperature, humidity and pressure sensor
"lumi.weather": ["Aqara", "TH Sensor", "WSDCGQ11LM"],
"spec": [
MathConv("temperature", "sensor", mi="0.1.85", multiply=0.01, min=-4000, max=12500),
MathConv("humidity", "sensor", mi="0.2.85", multiply=0.01, min=0, max=10000),
MathConv("pressure", "sensor", mi="0.3.85", multiply=0.01),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("battery_voltage", "sensor"), # diagnostic
],
}, {
# door window sensor
"lumi.sensor_magnet": ["Xiaomi", "Door/Window Sensor", "MCCGQ01LM"],
"lumi.sensor_magnet.aq2": ["Aqara", "Door/Window Sensor", "MCCGQ11LM"],
"spec": [
# hass: On means open, Off means closed
BoolConv("contact", "binary_sensor", mi="3.1.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BoolConv("battery_low", "binary_sensor", mi="8.0.9001"), # diagnostic
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
],
}, {
# motion sensor
"lumi.sensor_motion": ["Xiaomi", "Motion Sensor", "RTCGQ01LM"],
"spec": [
BoolConv("motion", "binary_sensor", mi="3.1.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BoolConv("battery_low", "binary_sensor", mi="8.0.9001"), # diagnostic
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("chip_temperature", "sensor", mi="8.0.2006"), # diagnostic
],
}, {
# motion sensor with illuminance
"lumi.sensor_motion.aq2": ["Aqara", "Motion Sensor", "RTCGQ11LM"],
"spec": [
BoolConv("motion", "binary_sensor", mi="3.1.85"),
BaseConv("illuminance", "sensor", mi="0.3.85"),
# Converter("illuminance", "sensor", mi="0.4.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
],
}, {
# motion sensor E1 with illuminance
"lumi.motion.acn001": ["Aqara", "Motion Sensor E1", "RTCGQ15LM"],
"spec": [
ConstConv("motion", "binary_sensor", mi="2.e.1", value=True),
BaseConv("illuminance", "sensor", mi="2.e.1.p.1"),
BaseConv("illuminance", mi="2.p.1"),
BatVoltConv("battery", "sensor", mi="3.p.2"), # voltage, mV
MapConv("battery_low", "binary_sensor", mi="3.p.1", map={1: False, 2: True}), # diagnostic
],
}, {
# water leak sensor
"lumi.sensor_wleak.aq1": ["Aqara", "Water Leak Sensor", "SJCGQ11LM"],
"spec": [
BoolConv("moisture", "binary_sensor", mi="3.1.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
ZLumiBasicAlarm("moisture", basic_attr=100), # read "no alarm" from heartbeats
],
}, {
# vibration sensor
"lumi.vibration.aq1": ["Aqara", "Vibration Sensor", "DJT11LM"],
"support": 3, # @AlexxIT
"spec": [
BaseConv("action", "sensor"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BoolConv("battery_low", "binary_sensor", mi="8.0.9001"), # diagnostic
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
BaseConv("bed_activity", mi="0.1.85"),
TiltAngleConv("tilt_angle", mi="0.2.85"),
BaseConv("vibrate_intensity", mi="0.3.85"),
VibrationConv("vibration", mi="13.1.85"),
BaseConv("vibration_level", mi="14.1.85"), # read/write from 1 to 30
],
}, {
# cube action, no retain
"lumi.sensor_cube.aqgl01": ["Aqara", "Cube EU", "MFKZQ01LM"], # tested
"lumi.sensor_cube": ["Aqara", "Cube", "MFKZQ01LM"],
"support": 5, # @AlexxIT
"spec": [
ZLumiCubeMain("action", "sensor"),
ZLumiCubeRotate("angle"),
# Converter("action", mi="13.1.85"),
# Converter("duration", mi="0.2.85", parent="action"),
# MathConv("angle", mi="0.3.85", parent="action", multiply=0.001),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
],
}, {
"lumi.sensor_smoke": ["Honeywell", "Smoke Sensor", "JTYJ-GD-01LM/BW"],
"spec": [
BaseConv("smoke_density", "sensor", mi="0.1.85"),
BoolConv("smoke", "binary_sensor", mi="13.1.85"),
BatVoltConv("battery", "sensor", mi="8.0.2008"),
BaseConv("battery_original", mi="8.0.2001"), # diagnostic
ZLumiSensConv("sensitivity", "select"), # config
ZLumiBasicAlarm("smoke", basic_attr=150), # read "no alarm" from heartbeats
],
}, {
"lumi.sensor_natgas": ["Honeywell", "Gas Sensor", "JTQJ-BF-01LM/BW"],
"support": 4, # @AlexxIT
"spec": [
BaseConv("gas_density", "sensor", mi="0.1.85"),
BoolConv("gas", "binary_sensor", mi="13.1.85"),
ZLumiSensConv("sensitivity", "select"), # config
ZLumiBasicAlarm("gas", basic_attr=150), # read "no alarm" from heartbeats
],
}, {
"lumi.curtain": ["Aqara", "Curtain", "ZNCLDJ11LM"],
"lumi.curtain.aq2": ["Aqara", "Roller Shade", "ZNGZDJ11LM"],
"spec": [
MapConv("motor", "cover", mi="14.2.85", map={0: "close", 1: "open", 2: "stop"}),
BaseConv("position", mi="1.1.85"),
MapConv("run_state", mi="14.4.85", map={0: "closing", 1: "opening", 2: "stop"}),
],
}, {
"lumi.curtain.hagl04": ["Aqara", "Curtain B1 EU", "ZNCLDJ12LM"],
"spec": [
MapConv("motor", "cover", mi="14.2.85", map={0: "close", 1: "open", 2: "stop"}),
BaseConv("position", mi="1.1.85"),
MapConv("run_state", mi="14.4.85", map={0: "closing", 1: "opening", 2: "stop"}),
BaseConv("battery", "sensor", mi="8.0.2001"),
MapConv("power_mode", mi="14.5.85", map={1: "adapter", 3: "battery", 4: "charging"}),
],
}, {
"lumi.lock.aq1": ["Aqara", "Door Lock S1", "ZNMS11LM"],
"lumi.lock.acn02": ["Aqara", "Door Lock S2 CN", "ZNMS12LM"],
"spec": [
# dead_bolt or square_locked or 13.22.85
LockConv("square", "binary_sensor", mi="13.16.85", mask=0x10),
# anti_bolt or reverse_locked or 3.1.85
LockConv("reverse", "binary_sensor", mi="13.16.85", mask=0x04),
# latch_bolt
LockConv("latch", "binary_sensor", mi="13.16.85", mask=0x01),
# other sensors
BaseConv("battery", "sensor", mi="8.0.2001"),
LockActionConv("key_id", "sensor", mi="13.1.85"),
LockActionConv("method", mi="13.15.85", map={1: "fingerprint", 2: "password"}),
LockActionConv("error", mi="13.4.85", map={1: "Wrong password", 2: "Wrong fingerprint"}),
# BoolConv("lock", "binary_sensor", mi="13.20.85")
BaseConv("action", "sensor"),
],
}, {
# it's better to read only one property 13.26.85 and ignore others
"lumi.lock.acn03": ["Aqara", "Door Lock S2 Pro CN", "ZNMS13LM"],
"spec": [
# corner_bolt or door_state or 13.26.85 (only on S2 Pro)
LockConv("lock", "binary_sensor", mi="13.16.85", mask=0x40),
# dead_bolt or square_locked or 13.22.85
LockConv("square", "binary_sensor", mi="13.16.85", mask=0x10),
# anti_bolt or reverse_locked or 3.1.85
LockConv("reverse", "binary_sensor", mi="13.16.85", mask=0x04),
# latch_bolt
LockConv("latch", "binary_sensor", mi="13.16.85", mask=0x01),
# other sensors
BaseConv("battery", "sensor", mi="8.0.2001"),
LockActionConv("key_id", mi="13.1.85"),
LockActionConv("lock_control", mi="13.25.85", map={0: "in_unlocked", 1: "out_unlocked", 2: "in_locked", 3: "out_locked"}),
LockActionConv("door_state", mi="13.26.85", map={0: "open", 1: "close", 2: "ajar"}),
LockActionConv("lock_state", mi="13.28.85", map={0: "door_cannot_locked", 1: "door_opened", 2: "door_without_lift", 3: "door_locked", 4: "reverse_locked"}),
LockActionConv("alarm", mi="13.5.85", map={0: "off", 1: "key_open", 4: "unlocked", 8: "hijack", 16: "pry", 32: "normally_open", 256: "less_storage", 500: "low_bat", 512: "doorbell"}),
LockActionConv("card_wrong", mi="13.2.85"),
LockActionConv("psw_wrong", mi="13.3.85"),
LockActionConv("fing_wrong", mi="13.4.85"),
LockActionConv("verified_wrong", mi="13.6.85"),
BaseConv("action", "sensor"),
# BoolConv("reverse_locked", "binary_sensor", mi="3.1.85"),
# BoolConv("square_locked", mi="13.22.85"),
# BoolConv("open_verified", mi="13.15.85"),
# BoolConv("elekey_verified", mi="13.27.85"),
# BoolConv("key_not_pull", mi="13.35.85"),
],
}, {
# https://github.com/AlexxIT/XiaomiGateway3/issues/101
"lumi.airrtc.tcpecn02": ["Aqara", "Thermostat S2 CN", "KTWKQ03ES"],
"spec": [
ClimateConv("climate", "climate", mi="14.2.85"),
BoolConv("power", mi="3.1.85"),
BaseConv("current_temp", mi="3.2.85"),
MapConv("hvac_mode", mi="14.8.85", map={0: "heat", 1: "cool", 15: "off"}),
MapConv("fan_mode", mi="14.10.85", map={0: "low", 1: "medium", 2: "high", 3: "auto"}),
ClimateTempConv("target_temp", mi="14.9.85"),
],
}, {
"lumi.airrtc.agl001": ["Aqara", "Thermostat E1", "SRTS-A01"],
"spec": [
# The following code is very different to the spec defined in home.miot-spec.com thus leave unmodified
BoolConv("climate", "climate", mi="4.21.85"),
# 0: Manual module 1: Smart schedule mode # 2: Antifreeze mode 3: Installation mode
MapConv("mode", mi="14.51.85", map={0: "heat", 2: "auto"}),
MathConv("current_temp", mi="0.1.85", multiply=0.01),
MathConv("target_temp", mi="1.8.85", multiply=0.01),
MathConv("antifreeze_temp", "number", mi="1.10.85", multiply=0.01, min=5, max=15, entity={"category": "config", "enabled": False, "units": UNIT_CELSIUS}),
BoolConv("window_detection", "switch", mi="4.24.85", entity=ENTITY_CONFIG),
BoolConv("valve_calibration", "switch", mi="4.22.85", entity=ENTITY_CONFIG),
BoolConv("valve_notification", "switch", mi="4.25.85", entity=ENTITY_CONFIG),
BoolConv("child_lock", "switch", mi="4.26.85"),
MapConv("find_device", "switch", mi="8.0.2096", map={2: True, 1: False}, entity=ENTITY_CONFIG),
BaseConv("battery", "sensor", mi="8.0.2001"),
BaseConv("chip_temperature", "sensor", mi="8.0.2006"),
],
}, {
"lumi.airrtc.vrfegl01": ["Xiaomi", "VRF Air Conditioning EU"],
"support": 1,
"spec": [
BaseConv("channels", "sensor", mi="13.1.85"),
],
}]
# Zigbee (miot)
DEVICES += [{
"lumi.sen_ill.mgl01": ["Xiaomi", "Light Sensor EU", "GZCGQ01LM", "YTC4043GL"],
"lumi.sen_ill.agl01": ["Aqara", "Light Sensor T1 CN", "GZCGQ11LM"],
"spec": [
BaseConv("illuminance", "sensor", mi="2.p.1"),
BatVoltConv("battery", "sensor", mi="3.p.1"), # voltage, mV
# new gw firmwares has a bug - don't bind power cluster
# ZBatteryVoltConv("battery", bind=True, report=True),
],
}, {
"lumi.magnet.acn001": ["Aqara", "Door/Window Sensor E1 CN", "MCCGQ14LM"],
"spec": [
MapConv("contact", "binary_sensor", mi="2.p.1", map={0: True, 1: False}),
BatVoltConv("battery", "sensor", mi="3.p.2"), # voltage, mV
MapConv("battery_low", "binary_sensor", mi="3.p.1", map={1: False, 2: True}), # diagnostic
],
}, {
"lumi.flood.acn001": ["Aqara", "Water Leak Sensor E1", "SJCGQ13LM"],
"spec": [
BaseConv("moisture", "binary_sensor", mi="2.p.1"), # bool
BatVoltConv("battery", "sensor", mi="3.p.2"), # voltage, mV
MapConv("battery_low", "binary_sensor", mi="3.p.1", map={1: False, 2: True}), # diagnostic
]
}, {
"lumi.sensor_ht.agl02": ["Aqara", "TH Sensor T1", "WSDCGQ12LM"],
"spec": [
BaseConv("temperature", "sensor", mi="2.p.1"), # celsius
BaseConv("humidity", "sensor", mi="2.p.2"), # percentage
BaseConv("pressure", "sensor", mi="2.p.3"), # kilopascal
BatVoltConv("battery", "sensor", mi="3.p.1"), # voltage, mV
MapConv("battery_low", "binary_sensor", mi="4.p.1", map={1: False, 2: True}), # diagnostic
],
}, {
# https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:motion-sensor:0000A014:lumi-agl04:1:0000C813
# for spec names Fibaro has good example: https://manuals.fibaro.com/motion-sensor/
"lumi.motion.agl04": ["Aqara", "Precision Motion Sensor EU", "RTCGQ13LM"],
"spec": [
ConstConv("motion", "binary_sensor", mi="4.e.1", value=True),
BatVoltConv("battery", "sensor", mi="3.p.1"), # voltage, mV
MapConv("sensitivity", "select", mi="8.p.1", map={1: "low", 2: "medium", 3: "high"}), # config
MathConv("blind_time", "number", mi="10.p.1", min=2, max=180), # config
MapConv("battery_low", "binary_sensor", mi="5.p.1", map={1: False, 2: True}), # diagnostic
BaseConv("idle_time", "sensor", mi="6.p.1"), # diagnostic
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-monitor:0000A008:lumi-acn01:1
"lumi.airmonitor.acn01": ["Aqara", "Air Quality Monitor CN", "VOCKQJK11LM"],
"spec": [
BaseConv("temperature", "sensor", mi="3.p.1"), # celsius
BaseConv("humidity", "sensor", mi="3.p.2"), # percentage
BaseConv("tvoc", "sensor", mi="3.p.3"), # ppb
BatVoltConv("battery", "sensor", mi="4.p.2"), # voltage, mV
MapConv("battery_low", "binary_sensor", mi="4.p.1", map={1: False, 2: True}), # diagnostic
MapConv("display_unit", "select", mi="6.p.1", map={0: "℃, mg/m³", 1: "℃, ppb", 16: "℉, mg/m³", 17: "℉, ppb"}), # config
],
}, {
"lumi.curtain.acn002": ["Aqara", "Roller Shade E1 CN", "ZNJLBL01LM"],
"spec": [
MapConv("motor", "cover", mi="2.p.2", map={0: "stop", 1: "close", 2: "open"}),
BaseConv("target_position", mi="2.p.4"),
CurtainPosConv("position", mi="2.p.5"),
MapConv("run_state", mi="2.p.6", map={0: "closing", 1: "opening", 2: "stop"}),
BaseConv("battery", "sensor", mi="3.p.4"), # percent
BaseConv("motor_reverse", "switch", mi="2.p.7"), # config
MapConv("motor_speed", "select", mi="5.p.5", map={0: "low", 1: "mid", 2: "high"}), # config
MapConv("battery_low", "binary_sensor", mi="3.p.1", map={1: False, 2: True}), # diagnostic
BaseConv("battery_voltage", "sensor", mi="3.p.2"), # diagnostic
MapConv("battery_charging", "binary_sensor", mi="3.p.3", map={0: False, 1: True, 2: False}), # diagnostic
# BoolConv("fault", "sensor", mi="2.p.1", entity=ENTITY_DISABLED),
# Converter("mode", "sensor", mi="2.p.3"), # only auto
],
}, {
19363: ["Xijia", "Curtain Motor", "xijia1.curtain.x3"],
"spec": [
MapConv("motor", "cover", mi="2.p.1", map={0: "close", 1: "stop", 2: "open"}),
BaseConv("target_position", mi="2.p.4"),
CurtainPosConv("position", mi="2.p.3"),
MapConv("run_state", mi="2.p.2", map={0: "closing", 1: "stop", 2: "opening"}),
BaseConv("battery", "sensor", mi="3.p.1"), # percent
BoolConv("motor_reverse", "switch", mi="2.p.5"), # uint8, config
MapConv("battery_charging", "binary_sensor", mi="3.p.2", map={1: True, 2: False}), # diagnostic
],
}, {
"lumi.remote.acn003": ["Aqara", "Single Wall Button E1 CN", "WXKG16LM"],
# https://github.com/niceboygithub/AqaraGateway/pull/118/files
"lumi.remote.acn007": ["Aqara", "Single Wall Button E1", "WXKG20LM"],
"spec": [
BaseConv("action", "sensor"),
ConstConv("action", mi="2.e.1", value=BUTTON_SINGLE),
ConstConv("action", mi="2.e.2", value=BUTTON_DOUBLE),
ConstConv("action", mi="2.e.3", value=BUTTON_HOLD),
BatVoltConv("battery", "sensor", mi="3.p.2"),
],
}, {
"lumi.remote.acn004": ["Aqara", "Double Wall Button E1 CN", "WXKG17LM"],
"spec": [
BaseConv("action", "sensor"),
ConstConv("action", mi="2.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="2.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="2.e.3", value=BUTTON_1_HOLD),
ConstConv("action", mi="7.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="7.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="7.e.3", value=BUTTON_2_HOLD),
ConstConv("action", mi="8.e.1", value=BUTTON_BOTH_SINGLE),
BatVoltConv("battery", "sensor", mi="3.p.2"),
MapConv("mode", "select", mi="5.p.1", map={1: "speed", 2: "multi"}), # config
],
}]
# relays and switches
DEVICES += [{
# https://www.aqara.com/en/single_switch_T1_no-neutral.html
"lumi.switch.l0agl1": ["Aqara", "Relay T1 EU (no N)", "SSM-U02"],
"spec": [
BaseConv("switch", "switch", mi="2.p.1"),
BaseConv("chip_temperature", "sensor", mi="2.p.6"), # diagnostic
MapConv("power_on_state", "select", mi="4.p.1", map={0: "off", 1: "previous"}), # config
MapConv("mode", "select", mi="6.p.2", map={1: "toggle", 2: "momentary"}), # config
],
}, {
# https://www.aqara.com/en/single_switch_T1_with-neutral.html
"lumi.switch.n0agl1": ["Aqara", "Relay T1 EU (with N)", "SSM-U01"],
"lumi.switch.n0acn2": ["Aqara", "Relay T1 CN (with N)", "DLKZMK11LM"],
"spec": [
BaseConv("switch", "switch", mi="2.p.1"),
MathConv("energy", "sensor", mi="3.p.1", multiply=0.001, round=2),
MathConv("power", "sensor", mi="3.p.2", round=2),
BoolConv("led", "switch", mi="4.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="5.p.1", map={0: "off", 1: "previous"}), # config
MapConv("mode", "select", mi="7.p.2", map={1: "toggle", 2: "momentary"}), # config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:outlet:0000A002:lumi-maeu01:1
"lumi.plug.maeu01": ["Aqara", "Plug EU", "SP-EUC01"], # no spec
"spec": [
BaseConv("plug", "switch", mi="2.p.1"),
MathConv("energy", "sensor", mi="3.p.1", multiply=0.001, round=2),
MathConv("power", "sensor", mi="3.p.2", round=2),
BoolConv("led", "switch", mi="4.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="5.p.1", map={0: "off", 1: "previous"}), # config
],
}, {
"lumi.switch.b1lc04": ["Aqara", "Single Wall Switch E1 (no N)", "QBKG38LM"],
"spec": [
BaseConv("switch", "switch", mi="2.p.1"),
ConstConv("action", mi="6.e.1", value=BUTTON_SINGLE),
ConstConv("action", mi="6.e.2", value=BUTTON_DOUBLE),
BaseConv("action", "sensor"),
BoolConv("led", "switch", mi="3.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="4.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless", "switch", mi="6.p.1"), # config
MapConv("mode", "select", mi="10.p.1", map={1: "250 ms", 2: "500 ms", 3: "750 ms", 4: "1 sec"}), # config
],
}, {
"lumi.switch.b2lc04": ["Aqara", "Double Wall Switch E1 (no N)", "QBKG39LM"],
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
ConstConv("action", mi="7.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="7.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="8.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="8.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="9.e.1", value=BUTTON_BOTH_SINGLE),
BaseConv("action", "sensor"),
BoolConv("wireless_1", "switch", mi="7.p.1"), # config
BoolConv("wireless_2", "switch", mi="8.p.1"), # config
BoolConv("led", "switch", mi="4.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="5.p.1", map={0: "off", 1: "previous"}), # config
MapConv("mode", "select", mi="15.p.1", map={1: "250 ms", 2: "500 ms", 3: "750 ms", 4: "1 sec"}) # config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-b1nc01:1
"lumi.switch.b1nc01": ["Aqara", "Single Wall Switch E1 (with N)", "QBKG40LM"],
# "support": 5,
"spec": [
BaseConv("switch", "switch", mi="2.p.1"),
BaseConv("action", "sensor"),
ConstConv("action", mi="7.e.1", value=BUTTON_SINGLE),
ConstConv("action", mi="7.e.2", value=BUTTON_DOUBLE),
BoolConv("led", "switch", mi="4.p.1"), # uint8, config
BoolConv("led_reverse", "switch", mi="4.p.2"), # uint8, config
MapConv("power_on_state", "select", mi="5.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless", "switch", mi="7.p.1"), # config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-b2nc01:1
"lumi.switch.b2nc01": ["Aqara", "Double Wall Switch E1 (with N)", "QBKG41LM"],
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
ConstConv("action", mi="8.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="8.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="9.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="9.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="10.e.1", value=BUTTON_BOTH_SINGLE),
BaseConv("action", "sensor"),
BoolConv("led", "switch", mi="5.p.1"), # uint8, config
BoolConv("led_reverse", "switch", mi="5.p.2"), # uint8, config
MapConv("power_on_state", "select", mi="6.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless_1", "switch", mi="8.p.1"), # config
BoolConv("wireless_2", "switch", mi="9.p.1"), # config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-acn040:1
"lumi.switch.acn040": ["Aqara", "Triple Wall Switch E1 (with N)", "ZNQBKG31LM"],
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
BaseConv("channel_3", "switch", mi="4.p.1"),
# Button press actions
BaseConv("action", "sensor"),
ConstConv("action", mi="9.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="9.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="10.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="10.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="11.e.1", value=BUTTON_3_SINGLE),
ConstConv("action", mi="11.e.2", value=BUTTON_3_DOUBLE),
ConstConv("action", mi="12.e.1", value=BUTTON_BOTH_12),
ConstConv("action", mi="13.e.1", value=BUTTON_BOTH_13),
ConstConv("action", mi="14.e.1", value=BUTTON_BOTH_23),
# Wireless switch
# Native false = Wireless, Native true = Relay
MapConv("wireless_1", "switch", mi="9.p.1", map={0: True, 1: False}), # config
MapConv("wireless_2", "switch", mi="10.p.1", map={0: True, 1: False}), # config
MapConv("wireless_3", "switch", mi="11.p.1", map={0: True, 1: False}), # config
# Others
MapConv("power_on_state", "select", mi="7.p.1", map={0: "off", 1: "previous"}), # config
MapConv("temperature_alarm", "sensor", mi="8.p.1", map={0: "normal", 1: "protected", 2: "abnormal"}),
# LED control
BoolConv("led_inverted", "switch", mi="6.p.2"), # config
BoolConv("led_dnd", "switch", mi="6.p.1", entity=ENTITY_CONFIG),
AqaraDNDTimeConv("led_dnd_time", "text", mi="6.p.3", entity=ENTITY_CONFIG)
]
}, {
# required switch firmware 0.0.0_0030
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-b2naus01:1
"lumi.switch.b2naus01": ["Aqara", "Double Wall Switch US (with N)", "WS-USC04"],
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
MathConv("energy", "sensor", mi="4.p.1", multiply=0.001, round=2),
MathConv("power", "sensor", mi="4.p.2", round=2),
BaseConv("action", "sensor"),
ConstConv("action", mi="8.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="8.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="9.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="9.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="10.e.1", value=BUTTON_BOTH_SINGLE),
BoolConv("led", "switch", mi="5.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="6.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless_1", "switch", mi="8.p.1"), # uint8, config
BoolConv("wireless_2", "switch", mi="9.p.1"), # uint8, config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-l1acn1:1
"lumi.switch.l1acn1": ["Aqara", "Single Wall Switch H1 CN (no N)", "QBKG27LM"],
"lumi.switch.l1aeu1": ["Aqara", "Single Wall Switch H1 EU (no N)", "WS-EUK01"],
"spec": [
BaseConv("switch", "switch", mi="2.p.1"),
BaseConv("action", "sensor"),
ConstConv("action", mi="6.e.1", value=BUTTON_SINGLE),
ConstConv("action", mi="6.e.2", value=BUTTON_DOUBLE),
BoolConv("led", "switch", mi="3.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="4.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless", "switch", mi="6.p.1"), # uint8, config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-l2acn1:1
"lumi.switch.l2acn1": ["Aqara", "Double Wall Switch H1 CN (no N)", "QBKG28LM"],
"lumi.switch.l2aeu1": ["Aqara", "Double Wall Switch H1 EU (no N)", "WS-EUK02"],
# "support": 5,
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
ConstConv("action", mi="7.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="7.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="8.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="8.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="9.e.1", value=BUTTON_BOTH_SINGLE),
BaseConv("action", "sensor"),
BoolConv("led", "switch", mi="4.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="5.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless_1", "switch", mi="7.p.1"), # uint8, config
BoolConv("wireless_2", "switch", mi="8.p.1"), # uint8, config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-n1acn1:1
"lumi.switch.n1acn1": ["Aqara", "Single Wall Switch H1 CN (with N)", "QBKG30LM"],
"lumi.switch.n1aeu1": ["Aqara", "Single Wall Switch H1 EU (with N)", "WS-EUK03"],
"spec": [
BaseConv("switch", "switch", mi="2.p.1"),
MathConv("energy", "sensor", mi="3.p.1", multiply=0.001, round=2),
MathConv("power", "sensor", mi="3.p.2", round=2),
BaseConv("action", "sensor"),
ConstConv("action", mi="7.e.1", value=BUTTON_SINGLE),
ConstConv("action", mi="7.e.2", value=BUTTON_DOUBLE),
BoolConv("led", "switch", mi="4.p.1"), # uint8, config
BoolConv("led_reverse", "switch", mi="4.p.2"), # uint8, config
MapConv("power_on_state", "select", mi="5.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless", "switch", mi="7.p.1"), # uint8, config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-n2acn1:1
"lumi.switch.n2acn1": ["Aqara", "Double Wall Switch H1 CN (with N)", "QBKG31LM"],
"lumi.switch.n2aeu1": ["Aqara", "Double Wall Switch H1 EU (with N)", "WS-EUK04"],
# "support": 5,
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
MathConv("energy", "sensor", mi="4.p.1", multiply=0.001, round=2),
MathConv("power", "sensor", mi="4.p.2", round=2),
BaseConv("action", "sensor"),
ConstConv("action", mi="8.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="8.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="9.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="9.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="10.e.1", value=BUTTON_BOTH_SINGLE),
BoolConv("led", "switch", mi="5.p.1"), # uint8, config
BoolConv("led_reverse", "switch", mi="5.p.2"), # uint8, config
MapConv("power_on_state", "select", mi="6.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless_1", "switch", mi="8.p.1"), # uint8, config
BoolConv("wireless_2", "switch", mi="9.p.1"), # uint8, config
],
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-l3acn1:1
"lumi.switch.l3acn1": ["Aqara", "Triple Wall Switch H1 CN (no N)", "QBKG29LM"],
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
BaseConv("channel_3", "switch", mi="4.p.1"),
ConstConv("action", mi="8.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="8.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="9.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="9.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="10.e.1", value=BUTTON_3_SINGLE),
ConstConv("action", mi="10.e.2", value=BUTTON_3_DOUBLE),
ConstConv("action", mi="11.e.1", value=BUTTON_BOTH_12),
ConstConv("action", mi="12.e.1", value=BUTTON_BOTH_13),
ConstConv("action", mi="13.e.1", value=BUTTON_BOTH_23),
BaseConv("action", "sensor"),
BoolConv("led", "switch", mi="5.p.1"), # uint8, config
MapConv("power_on_state", "select", mi="6.p.1", map={0: "off", 1: "previous"}), # config
BoolConv("wireless_1", "switch", mi="8.p.1"), # uint8, config
BoolConv("wireless_2", "switch", mi="9.p.1"), # uint8, config
BoolConv("wireless_3", "switch", mi="10.p.1"), # uint8, config
]
}, {
# https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:switch:0000A003:lumi-n3acn1:1
"lumi.switch.n3acn1": ["Aqara", "Triple Wall Switch H1 CN (with N)", "QBKG32LM"],
"spec": [
BaseConv("channel_1", "switch", mi="2.p.1"),
BaseConv("channel_2", "switch", mi="3.p.1"),
BaseConv("channel_3", "switch", mi="4.p.1"),
MathConv("energy", "sensor", mi="5.p.1", multiply=0.001, round=2),
MathConv("power", "sensor", mi="5.p.2", round=2),
ConstConv("action", mi="9.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="9.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="10.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="10.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="11.e.1", value=BUTTON_3_SINGLE),
ConstConv("action", mi="11.e.2", value=BUTTON_3_DOUBLE),
ConstConv("action", mi="12.e.1", value=BUTTON_BOTH_12),
ConstConv("action", mi="13.e.1", value=BUTTON_BOTH_13),
ConstConv("action", mi="14.e.1", value=BUTTON_BOTH_23),
BaseConv("action", "sensor"),
BoolConv("led", "switch", mi="6.p.1"), # uint8, config
BoolConv("led_reverse", "switch", mi="6.p.2"), # uint8, config
MapConv("power_on_state", "select", mi="7.p.1", map={0: "off", 1: "previous"}), # config
MapConv("wireless_1", "switch", mi="9.p.1", map={0: True, 1: False}), # config
MapConv("wireless_2", "switch", mi="10.p.1", map={0: True, 1: False}), # config
MapConv("wireless_3", "switch", mi="11.p.1", map={0: True, 1: False}), # config
]
}, {
"lumi.remote.b28ac1": ["Aqara", "Double Wall Button H1", "WRS-R02"],
"spec": [
BaseConv("action", "sensor"),
ConstConv("action", mi="3.e.1", value=BUTTON_1_SINGLE),
ConstConv("action", mi="3.e.2", value=BUTTON_1_DOUBLE),
ConstConv("action", mi="3.e.3", value=BUTTON_1_HOLD),
ConstConv("action", mi="4.e.1", value=BUTTON_2_SINGLE),
ConstConv("action", mi="4.e.2", value=BUTTON_2_DOUBLE),
ConstConv("action", mi="4.e.3", value=BUTTON_2_HOLD),
BatVoltConv("battery", "sensor", mi="6.p.2"), # voltage
MapConv("battery_low", "binary_sensor", mi="6.p.1", map={1: False, 2: True}), # diagnostic
MapConv("mode", "select", mi="8.p.1", map={1: "single_click", 2: "multi_click"}), # config
]
}, {
"lumi.sensor_smoke.acn03": ["Aqara", "Smoke Sensor", "JY-GZ-01AQ"],
"spec": [
BoolConv("smoke", "binary_sensor", mi="2.p.1"),
BaseConv("smoke_density", "sensor", mi="2.p.3"),
BoolConv("fault", "binary_sensor", mi="2.p.2"), # diagnostic
BoolConv("led", "switch", mi="5.p.1"), # uint8, config
MapConv("battery_low", "binary_sensor", mi="3.p.1", map={1: False, 2: True}), # diagnostic
BaseConv("battery_voltage", "sensor", mi="3.p.2"), # diagnostic
]
}, {
# https://github.com/AlexxIT/XiaomiGateway3/issues/865
"lumi.sensor_gas.acn02": ["Aqara", "Gas Sensor", "JT-BZ-01AQ/A"],
"spec": [
MapConv("status", "sensor", mi="2.p.1", map={0: "Normal Monitoring", 1: "Alarm", 2: "Fault", 3: "Warm Up", 4: "End Of Life"}),
BaseConv("gas_density", "sensor", mi="2.p.3"), # percentage
MapConv("sensitivity", "select", mi="5.p.1", map={1: "LEL15", 2: "LEL10"}, entity=ENTITY_CONFIG), # config