Open 1269699120 opened 1 week ago
The "Abnormal Condition" has been showing as "unknown" all the time. I don't know what to do. As shown in the picture.
I've tested the other entities and they all work normally.
Related links of the door lock https://home.miot-spec.com/spec/xiaomi.lock.b03
code files xiaomi_gateway3.py.txt
This is 4.p.1003
property. It has state.
This is 2.e.1020.p.2
event. It hasn't state. It's bad idea to use sensor for it.
This is
4.p.1003
property. It has state. This is2.e.1020.p.2
event. It hasn't state. It's bad idea to use sensor for it.
I have modified the content inside. And for 2.e.1020.p.2, I wrote it by referring to the lumi.lock.mcn002 device from lines 1738 to 1760 in the file at https://github.com/AlexxIT/XiaomiGateway3/blob/master/custom_components/xiaomi_gateway3/core/devices.py. Currently, it can already be displayed in the action entity. Could you please take a look and see if it can be adapted to the plug-in? Here is the complete modified code.
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 异常状态
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 门铃
ConstConv("action", mi="5.e.1006", value="doorbell"),
BaseConv("timestamp", mi="5.e.1006.p.4"),
],
}] + DEVICES
Your converter is very different from those already in the component (locks). I can't accept it as it is
Your converter is very different from those already in the component (locks). I can't accept it as it is
Sorry, my coding level isn't very professional. This is the best I could do with my code. It's okay if you don't accept it. And I'm really grateful if you're still willing to make adjustments for this smart lock
I have a xiaomi.lock.b03 door lock and I hope it can be adapted into the plugin. I have written relevant code in the xiaomi_gateway3.py file. After testing, other parts are normal, but the "Abnormal Condition" entity related to this door lock has no response and keeps reporting errors. I have tried various methods but haven't been able to solve it. Now I request you to help fix this bug and also hope that my code can be merged into the plugin so as to better support this door lock. Thank you!
xiaomi_gateway3.py code