from custom_components.xiaomi_gateway3.core.devices import *
DEVICES = [{
# 门锁参数资料 https://home.miot-spec.com/spec/xiaomi.lock.b03
# 参考其它的门锁 6017: ["Xiaomi", "Face Recognition Smart Door Lock", "XMZNMS09LM", "lumi.lock.mcn002"]
# https://github.com/AlexxIT/XiaomiGateway3/blob/master/custom_components/xiaomi_gateway3/core/devices.py
# https://home.miot-spec.com/spec/lumi.lock.mcn002
17601: ["Xiaomi", "Xiaomi Smart Door Lock 2 (Finger Vein Unlock)", "xiaomi.lock.b03"],
"spec": [
# action sensors 传感器
BaseConv("action", "sensor"),
# battery 电池
BaseConv("battery", "sensor", mi="4.p.1003"),
# The door lock status 门开/关状态
MapConv("lock", "binary_sensor", mi="3.p.1021", map={
1: False,
2: True,
17: False,
33: False,
49: False,
18: True,
34: False,
50: False}),
# Door status 门状态
MapConv("door", "sensor", mi="3.p.1021", map={
1: "Locked",
2: "Unlocked",
3: "Door_Closed_Properly_After_Left_Ajar",
4: "Door_Was_Ajar",
5: "Leaving_The_Door_Open_Timed_Out",
6: "Door_Not_Closed_Well",
17: "Locked",
33: "Locked",
49: "Locked",
18: "Unlocked",
34: "Unlocked",
50: "Unlocked",
19: "Door_Closed_Properly_After_Left_Ajar",
35: "Door_Closely_Properly_After_Left_Ajar",
51: "Door_Closed_Properly_After_Left_Ajar",
20: "Door_Was_Ajar",
36: "Door_Was_Ajar",
52: "Door_Was_Ajar",
21: "Leaving_The_Door_Open_Timed_Out",
37: "Leaving_The_Door_Open_Timed_Out",
53: "Leaving_The_Door_Open_Timed_Out",
22: "Door_Not_Closed_Well",
38: "Door_Not_Closed_Well",
54: "Door_Not_Closed_Well"}),
# Operation Method 开锁方式
MapConv("Operation_Method", "sensor", mi="2.e.1020.p.2", map = {
1: "Smart_Device", # Mobile Phone: 智能设备解锁
2: "Biometric", # Finger Print: 生物识别(指纹)
3: "PIN/Password", # PassWord: 密码认证
4: "Contactless", # NFC: 非接触式认证
5: "Physical_Key", # Lock Key: 物理钥匙
6: "OTP", # One Time Password: 一次性密码
7: "Cyclic_Code", # Periodic Password: 周期性密码
8: "Emergency_Override", # Coerce: 强制开锁机制(紧急情况下)
9: "Interior_Unlock", # Button Unlock Inside: 内部按钮解锁
10: "Vein_Recognition"}), # Finger Vein: 指静脉识别
# Operation ID 开锁ID
BaseConv("Operation_ID", "sensor", mi="2.e.1020.p.3"),
# Abnormal Condition 异常状态
# abnormal_condition,error_id 都会显示在action实体的属性里面。
# error_id和abnormal_condition 对应的是各种异常状态
ConstConv("action", mi="2.e.1007", value="error"),
BaseConv("error_id", mi="2.e.1007.p.1"),
MapConv("abnormal_condition", mi="2.e.1007.p.1", map={
1: "Frequent_Unlocking_Failed_By_Multiple_Methods",
2: "Door_Lock_Was_Damaged",
3: "Door_Lock_Was_Reset",
4: "Door_Lock_Batteries_Are_Low",
5: "Door_Lock_Batteries_Are_Nearly_Depleted",
6: "Unlock_From_Inside_After_Leaving_Home",
7: "Door_Was_Ajar",
9: "Leaving_The_Door_Open_Timed_Out",
10: "Door_Closed_Properly_After_Left_Ajar",
11: "The_Door_Is_Not_Closed_Well",
12: "Unlock_Exception"}),
BaseConv("timestamp", mi="2.e.1007.p.4"),
# lock action 门锁执行动作
MapConv("Lock Action", "sensor", mi="2.e.1020.p.6", map={
1: "Lock",
2: "Unlock",
3: "Locked_From_Inside",
4: "Released_Lock_From_Inside",
5: "Enabled_Child_Lock",
6: "Disabled_Child_Lock",
7: "Enable_The_Away_From_Home_Mode",
8: "Disable_The_Away_From_Home_Mode",
9: "Close_The_Door",
10: "Enabled_Child_Lock_And_From_Inside",
11: "Disabled_Child_Lock_And_From_Inside"}),
# Operation Position 哪里开门
MapConv("position", "sensor", mi="2.e.1020.p.5", map={1: "Indoor", 2: "OutDoor"}),
# doorbell action 门铃
BaseConv("doorbell", "sensor"),
#BaseConv("doorbell", mi="5.e.1006.p.1"), 这条代码我也不知道咋整
#doorbell 实体ha是个一串数字很正常,因为我想不到啥好办法,直接获取了按门铃的时间戳。
#时间戳每次的按门铃时间都不一样,保证不重复,实体数据就有刷新
#ConstConv("action3", mi="5.e.1006", value="doorbell"),
BaseConv("doorbell", mi="5.e.1006.p.1"),
],
}] + DEVICES