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

 找回密码
 立即注册
楼主: 27hh

[修仙教程] 【持续更新优化】小米米家智能设备通用接入HomeAssistant插件

  [复制链接]

15

主题

438

帖子

4348

积分

论坛元老

Rank: 8Rank: 8

积分
4348
金钱
3910
HASS币
0
发表于 2020-12-30 23:41:13 | 显示全部楼层
本帖最后由 miniknife 于 2020-12-30 23:42 编辑

手上有一个37度的睡眠监测器,不知道该怎么写配置,按照楼主的说明,获取sleep state,siid应该是2,piid应该是1,配置里的did楼主没有解释从哪里可以获取,这个设备相关信息如下:

{
    "type":"urn:miot-spec-v2:device:sleep-monitor:0000A080:degree-smh013:1",
    "description":"Sleep Monitor",
    "services":[
        {
            "iid":1,
            "type":"urn:miot-spec-v2:service:device-information:00007801:degree-smh013:1",
            "description":"Device Information",
            "properties":[
                {
                    "iid":1,
                    "type":"urn:miot-spec-v2:property:manufacturer:00000001:degree-smh013:1",
                    "description":"Device Manufacturer",
                    "format":"string",
                    "access":[
                        "read"
                    ]
                },
                {
                    "iid":2,
                    "type":"urn:miot-spec-v2:property:model:00000002:degree-smh013:1",
                    "description":"Device Model",
                    "format":"string",
                    "access":[
                        "read"
                    ]
                },
                {
                    "iid":3,
                    "type":"urn:miot-spec-v2:property:serial-number:00000003:degree-smh013:1",
                    "description":"Device Serial Number",
                    "format":"string",
                    "access":[
                        "read"
                    ]
                },
                {
                    "iid":4,
                    "type":"urn:miot-spec-v2:property:firmware-revision:00000005:degree-smh013:1",
                    "description":"Current Firmware Version",
                    "format":"string",
                    "access":[
                        "read"
                    ]
                }
            ]
        },
        {
            "iid":2,
            "type":"urn:miot-spec-v2:service:sleep-monitor:00007885:degree-smh013:1",
            "description":"Sleep Monitor",
            "properties":[
                {
                    "iid":1,
                    "type":"urn:miot-spec-v2:property:sleep-state:000000C9:degree-smh013:1",
                    "description":"Sleep State",
                    "format":"uint8",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none",
                    "value-list":[
                        {
                            "value":0,
                            "description":"Out of Bed"
                        },
                        {
                            "value":1,
                            "description":"Awake"
                        },
                        {
                            "value":3,
                            "description":"Light Sleep"
                        },
                        {
                            "value":4,
                            "description":"Deep Sleep"
                        },
                        {
                            "value":2,
                            "description":"Rapid Eye Movement"
                        }
                    ]
                }
            ]
        },
        {
            "iid":4,
            "type":"urn:degree-spec:service:sleep-info:00007801:degree-smh013:1",
            "description":"sleep-info",
            "properties":[
                {
                    "iid":1,
                    "type":"urn:degree-spec:property:sleep-section:00000001:degree-smh013:1",
                    "description":"sleep-section",
                    "format":"string",
                    "access":[
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":2,
                    "type":"urn:degree-spec:property:sleep-report:00000002:degree-smh013:1",
                    "description":"sleep-report",
                    "format":"string",
                    "access":[
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":3,
                    "type":"urn:degree-spec:property:heart-chart:00000003:degree-smh013:1",
                    "description":"heart-chart",
                    "format":"string",
                    "access":[
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":4,
                    "type":"urn:degree-spec:property:breath-chart:00000004:degree-smh013:1",
                    "description":"breath-chart",
                    "format":"string",
                    "access":[
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":5,
                    "type":"urn:degree-spec:property:search-report:00000005:degree-smh013:1",
                    "description":"search-report",
                    "format":"string",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":6,
                    "type":"urn:degree-spec:property:set-sleep-time:00000006:degree-smh013:1",
                    "description":"set-sleep-time",
                    "format":"string",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":7,
                    "type":"urn:degree-spec:property:user-info:00000007:degree-smh013:1",
                    "description":"user-info",
                    "format":"string",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":8,
                    "type":"urn:degree-spec:property:sleep-info:00000008:degree-smh013:1",
                    "description":"sleep-info",
                    "format":"string",
                    "access":[
                        "notify"
                    ],
                    "unit":"none"
                },
                {
                    "iid":10,
                    "type":"urn:degree-spec:property:realtime-heart-rate:0000000a:degree-smh013:1",
                    "description":"realtime-heart-rate",
                    "format":"uint8",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none",
                    "value-range":[
                        0,
                        255,
                        1
                    ]
                },
                {
                    "iid":11,
                    "type":"urn:degree-spec:property:realtime-breath-rate:00000009:degree-smh013:1",
                    "description":"realtime-breath-rate",
                    "format":"uint8",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none",
                    "value-range":[
                        0,
                        255,
                        1
                    ]
                },
                {
                    "iid":12,
                    "type":"urn:degree-spec:property:realtime-sleepstage:0000000b:degree-smh013:1",
                    "description":"realtime-sleepstage",
                    "format":"uint8",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none",
                    "value-range":[
                        0,
                        255,
                        1
                    ]
                },
                {
                    "iid":13,
                    "type":"urn:degree-spec:property:user-info-down:0000000c:degree-smh013:1",
                    "description":"user-info-down",
                    "format":"string",
                    "access":[
                        "write"
                    ],
                    "unit":"none"
                },
                {
                    "iid":14,
                    "type":"urn:degree-spec:property:set-sleep-time-down:0000000d:degree-smh013:1",
                    "description":"set-sleep-time-down",
                    "format":"string",
                    "access":[
                        "write"
                    ],
                    "unit":"none"
                },
                {
                    "iid":15,
                    "type":"urn:degree-spec:property:fast-update-switch:0000000e:degree-smh013:1",
                    "description":"fast-update-switch",
                    "format":"bool",
                    "access":[
                        "write"
                    ],
                    "unit":"none"
                },
                {
                    "iid":16,
                    "type":"urn:degree-spec:property:linkage-sleepstage:0000000f:degree-smh013:1",
                    "description":"linkage-sleepstage",
                    "format":"uint8",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none",
                    "value-range":[
                        0,
                        255,
                        1
                    ]
                },
                {
                    "iid":17,
                    "type":"urn:degree-spec:property:linkage-warning:00000010:degree-smh013:1",
                    "description":"linkage-warning",
                    "format":"uint8",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none",
                    "value-range":[
                        0,
                        255,
                        1
                    ]
                },
                {
                    "iid":18,
                    "type":"urn:degree-spec:property:gen-report:00000011:degree-smh013:1",
                    "description":"gen-report",
                    "format":"bool",
                    "access":[
                        "write"
                    ],
                    "unit":"none"
                },
                {
                    "iid":19,
                    "type":"urn:degree-spec:property:search-report-today:00000012:degree-smh013:1",
                    "description":"search-report-today",
                    "format":"uint8",
                    "access":[
                        "read",
                        "notify"
                    ],
                    "unit":"none",
                    "value-range":[
                        0,
                        5,
                        1
                    ]
                }
            ]
        }
    ]
}
回复

使用道具 举报

15

主题

636

帖子

2201

积分

金牌会员

Rank: 6Rank: 6

积分
2201
金钱
1565
HASS币
0
发表于 2020-12-30 23:47:02 | 显示全部楼层
膜拜楼主,真是太牛了。
我这正纠结凉霸不大好用,风扇灯不大好用,晾衣架无法接入呢。。。
spec的信息,通过老毛子修改版的米家app,在logs里应该可以拿到。
回复

使用道具 举报

19

主题

251

帖子

1138

积分

金牌会员

Rank: 6Rank: 6

积分
1138
金钱
887
HASS币
0
发表于 2020-12-31 00:38:53 | 显示全部楼层
yinghu183 发表于 2020-12-30 19:49
哥们你试试,试过了来说下,我就省的试了

指望我是指望不上了,我看了,我的设备都是MIOT的
回复

使用道具 举报

19

主题

251

帖子

1138

积分

金牌会员

Rank: 6Rank: 6

积分
1138
金钱
887
HASS币
0
发表于 2020-12-31 00:42:23 | 显示全部楼层
MattSmell 发表于 2020-12-30 21:04
插座是“米家智能插座2 蓝牙网关版”吗,正准备买一个

不要买了。米家的重点明显转到蓝牙Mesh上面去了,以后的蓝牙设备估计都是Mesh的。
回复

使用道具 举报

10

主题

103

帖子

487

积分

中级会员

Rank: 3Rank: 3

积分
487
金钱
384
HASS币
0
发表于 2020-12-31 09:59:57 | 显示全部楼层
我特地看了,现在的小米设备好像都是这个协议啊。从老毛子的app logs看都有这一段协议。那是不是所有类型都可以接入~~目前就期待把这个插件完善咯。~来个通杀~。。
回复

使用道具 举报

16

主题

168

帖子

1409

积分

金牌会员

Rank: 6Rank: 6

积分
1409
金钱
1241
HASS币
0
发表于 2020-12-31 10:08:38 | 显示全部楼层
27hh 发表于 2020-12-30 16:16
非常感谢您热心回答大家的问题!
我也想问问:小米miot的设备都会有一个specs的链接,比如 https://miot-s ...

你想查哪个型号的?
回复

使用道具 举报

20

主题

219

帖子

2184

积分

金牌会员

Rank: 6Rank: 6

积分
2184
金钱
1950
HASS币
87
发表于 2020-12-31 12:12:43 | 显示全部楼层
natic 发表于 2020-12-30 22:08
杜亚M1已经有插件可以接入HA了

请问可以提供一下插件吗?杜亚M1找了很久没找到方法接入
回复

使用道具 举报

0

主题

50

帖子

1230

积分

金牌会员

Rank: 6Rank: 6

积分
1230
金钱
1180
HASS币
0
发表于 2020-12-31 12:51:59 | 显示全部楼层
学习,太好了
回复

使用道具 举报

32

主题

986

帖子

4233

积分

论坛元老

Rank: 8Rank: 8

积分
4233
金钱
3207
HASS币
110

教程狂人论坛风云人物

 楼主| 发表于 2020-12-31 12:52:46 | 显示全部楼层
miniknife 发表于 2020-12-30 23:41
手上有一个37度的睡眠监测器,不知道该怎么写配置,按照楼主的说明,获取sleep state,siid应该是2,piid应 ...

siid和diid都没错,did随便打一个就行,没有影响,

sensor:
  - platform: xiaomi_miot_raw
    name: 睡眠监测器
    host: 192.168.0.201
    token: 81xxxxxxxxxxxxxxxxxxxxxxxxxxxx02
    default_properties_getter: 'get_properties'
    default_properties: 
      - did: sleepstate
        siid: 2
        piid: 1
    sensor_property: sleepstate

这样就行
回复

使用道具 举报

32

主题

986

帖子

4233

积分

论坛元老

Rank: 8Rank: 8

积分
4233
金钱
3207
HASS币
110

教程狂人论坛风云人物

 楼主| 发表于 2020-12-31 12:54:45 | 显示全部楼层
xztxy 发表于 2020-12-31 09:59
我特地看了,现在的小米设备好像都是这个协议啊。从老毛子的app logs看都有这一段协议。那是不是所有类型都 ...

有的不行,旧版的miio设备,好像只是在形式上适配了这个协议,但是并没有去实现,所以局域网控制还是用老的miio;小爱音箱虽然有这个,但是不支持局域网控制,只能云端下发指令
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-24 13:29 , Processed in 1.133505 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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