『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 66|回复: 2

[插件集成] 小米智能门锁2指静脉版接入ha

[复制链接]

2

主题

10

帖子

180

积分

注册会员

Rank: 2

积分
180
金钱
170
HASS币
0
发表于 3 小时前 | 显示全部楼层 |阅读模式
本帖最后由 deshing 于 2024-11-7 07:55 编辑

开始操作
需要安装插件Xiaomi Gateway 3
AlexxIT/XiaomiGateway3: Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over LAN (github.com)

在/homeassistant/
创建文件xiaomi_gateway3.py

将代码写入

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



重启ha
完成







xiaomi_gateway3.rar

1.66 KB, 下载次数: 0

评分

参与人数 2金钱 +30 收起 理由
tianzhuang55 + 10 论坛有你更精彩!
natic + 20 感谢楼主分享!

查看全部评分

回复

使用道具 举报

22

主题

729

帖子

3800

积分

论坛元老

Rank: 8Rank: 8

积分
3800
金钱
3066
HASS币
20
发表于 2 小时前 | 显示全部楼层
我有涂鸦的zigbee锁,一直用的涂鸦网关,能写这种配置文件,然后接入到小米多模网关2里吗?
回复

使用道具 举报

2

主题

10

帖子

180

积分

注册会员

Rank: 2

积分
180
金钱
170
HASS币
0
 楼主| 发表于 1 小时前 | 显示全部楼层
ms2 发表于 2024-11-7 08:50
我有涂鸦的zigbee锁,一直用的涂鸦网关,能写这种配置文件,然后接入到小米多模网关2里吗? ...

你那是涂鸦,我这个是小米的,没办法
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-7 10:59 , Processed in 0.089610 second(s), 29 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表