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

 找回密码
 立即注册
楼主: relliky

[经验分享] 米家无线八键旋钮:接入,自动化编写和维护

  [复制链接]

5

主题

114

帖子

958

积分

高级会员

Rank: 4

积分
958
金钱
844
HASS币
0
发表于 2024-6-5 09:56:18 | 显示全部楼层
感谢大佬无锡奉献,咨询一下大佬,gateway3 直接接入需要有米家网关吗,还是直接安装插件就可以接入了呢,我的hassos小主机自己加装了一个usb蓝牙,可以接入一些无线蓝牙开关,就不知道我这种可以接入吗,谢谢。
回复

使用道具 举报

32

主题

1059

帖子

4870

积分

论坛元老

Rank: 8Rank: 8

积分
4870
金钱
3796
HASS币
90
 楼主| 发表于 2024-6-5 20:40:04 | 显示全部楼层
心之向阳 发表于 2024-6-5 09:56
感谢大佬无锡奉献,咨询一下大佬,gateway3 直接接入需要有米家网关吗,还是直接安装插件就可以接入了呢, ...

需要多模网关
我家全屋智能的HA设置 https://github.com/relliky/Tais_Home_Assistant_Config
回复

使用道具 举报

0

主题

11

帖子

112

积分

注册会员

Rank: 2

积分
112
金钱
101
HASS币
0
发表于 2024-6-6 14:06:09 | 显示全部楼层
谢谢大佬
回复

使用道具 举报

0

主题

5

帖子

34

积分

新手上路

Rank: 1

积分
34
金钱
29
HASS币
0
发表于 2024-6-12 19:05:14 | 显示全部楼层
好复杂 大佬强
回复

使用道具 举报

2

主题

93

帖子

695

积分

高级会员

Rank: 4

积分
695
金钱
602
HASS币
0
发表于 2024-6-14 17:24:58 | 显示全部楼层
旋钮开关.png 大佬,我看米家有款旋钮lemesh.remote.ts10支持旋转角度的,这种拿来根据旋转角度对应温度或者亮度跨度的是不是有搞头。  https://home.miot-spec.com/spec? ... 0A021:lemesh-ts10:1
回复

使用道具 举报

32

主题

1059

帖子

4870

积分

论坛元老

Rank: 8Rank: 8

积分
4870
金钱
3796
HASS币
90
 楼主| 发表于 2024-6-15 20:36:26 | 显示全部楼层
invincible 发表于 2024-6-14 17:24
大佬,我看米家有款旋钮lemesh.remote.ts10支持旋转角度的,这种拿来根据旋转角度对应温度或者亮度跨度的 ...

看文档上确实是。https://miot-spec.org/miot-spec- ... 0A021:lemesh-ts10:1

我研究一下。
我家全屋智能的HA设置 https://github.com/relliky/Tais_Home_Assistant_Config
回复

使用道具 举报

2

主题

93

帖子

695

积分

高级会员

Rank: 4

积分
695
金钱
602
HASS币
0
发表于 2024-6-16 08:30:11 | 显示全部楼层
relliky 发表于 2024-6-15 20:36
看文档上确实是。https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:remote-co ...

大佬有进展的话踢我下
回复

使用道具 举报

32

主题

1059

帖子

4870

积分

论坛元老

Rank: 8Rank: 8

积分
4870
金钱
3796
HASS币
90
 楼主| 发表于 2024-6-16 18:40:20 | 显示全部楼层
本帖最后由 relliky 于 2024-6-16 18:41 编辑
invincible 发表于 2024-6-16 08:30
大佬有进展的话踢我下

我研究了一下,原本这个芯片是不支持这个8键功能的,只支持4键。

原本芯片只支持的是你截图里面的那一套,就是这些动作。

  - access: []
    description: Button Type
    format: uint8
    gatt-access: []
    iid: 1
    source: 1
    type: urn:miot-spec-v2:property:button-type:0000011F:lemesh-ts10:1
    value-list:
    - description: Up Button
      value: 1
    - description: Right Button
      value: 2
    - description: Down Button
      value: 3
    - description: Left Button
      value: 4
    - description: Right Rotation
      value: 5
    - description: Left Rotation
      value: 6
    - description: Down Button Press Right Rotation
      value: 7
    - description: Down Button Press Left Rotation
      value: 8
    - description: Press To Turn Right
      value: 9
    - description: Press To Turn Left
      value: 10
    - description: Press To Turn Right
      value: 11
    - description: Press To Turn Left
      value: 12
    - description: Press To Turn Right
      value: 13
    - description: Press To Turn Left
      value: 14
  - access:
    - notify
    - read
    description: Mode
    format: uint8
    gatt-access: []
    iid: 1020
    source: 1
    type: urn:miot-spec-v2:property:mode:00000008:lemesh-ts10:1
    value-list:
    - description: Quick Single Click
      value: 0
    - description: Multiple Click
      value: 1
  - access: []
    description: Rotation Amplitude
    format: int8
    iid: 2
    source: 1
    type: urn:miot-spec-v2:property:rotation-amplitude:0000011D:lemesh-ts10:1
    unit: percentage
    value-range:
    - -100
    - 100
    - 1


但开发者想实现8个键的功能,原本芯片又只支持4个键,所以他就干脆不用那个上下左右4键的那个接口了,把旋转幅度这个参数用来复用来传递8个键加旋钮的状态。这就是为什么你的截图里面的英文是只能选择了上下左右4个键的动作的原因。

对于这个设备,任何时候按键或者旋钮的话,这个设备就会发送一个旋转角度状态给米家,然后米家那边再把这个旋转角度的状态附上文字告诉用户这个动作的意义。对照表如下。

        MapConv("action", mi="5.e.1036.p.2", map={-11: "knob_anticlockwise_after_toggling_button_1", 
                                                  -12: "knob_anticlockwise_after_toggling_button_2", 
                                                  -13: "knob_anticlockwise_after_toggling_button_3",
                                                  -14: "knob_anticlockwise_after_toggling_button_4", 
                                                  -15: "knob_anticlockwise_after_toggling_button_5", 
                                                  -16: "knob_anticlockwise_after_toggling_button_6",
                                                  -17: "knob_anticlockwise_after_toggling_button_7", 
                                                  -18: "knob_anticlockwise_after_toggling_button_8", 
                                                  11: "knob_clockwise_after_toggling_button_1", 
                                                  12: "knob_clockwise_after_toggling_button_2", 
                                                  13: "knob_clockwise_after_toggling_button_3",
                                                  14: "knob_clockwise_after_toggling_button_4", 
                                                  15: "knob_clockwise_after_toggling_button_5", 
                                                  16: "knob_clockwise_after_toggling_button_6",
                                                  17: "knob_clockwise_after_toggling_button_7", 
                                                  18: "knob_clockwise_after_toggling_button_8", 
                                                  -21: "knob_anticlockwise_after_toggling_button_1_and_knob", 
                                                  -22: "knob_anticlockwise_after_toggling_button_2_and_knob", 
                                                  -23: "knob_anticlockwise_after_toggling_button_3_and_knob",
                                                  -24: "knob_anticlockwise_after_toggling_button_4_and_knob", 
                                                  -25: "knob_anticlockwise_after_toggling_button_5_and_knob", 
                                                  -26: "knob_anticlockwise_after_toggling_button_6_and_knob",
                                                  -27: "knob_anticlockwise_after_toggling_button_7_and_knob", 
                                                  -28: "knob_anticlockwise_after_toggling_button_8_and_knob", 
                                                  22: "knob_clockwise_after_toggling_button_1_and_knob", 
                                                  22: "knob_clockwise_after_toggling_button_2_and_knob", 
                                                  23: "knob_clockwise_after_toggling_button_3_and_knob",
                                                  24: "knob_clockwise_after_toggling_button_4_and_knob", 
                                                  25: "knob_clockwise_after_toggling_button_5_and_knob", 
                                                  26: "knob_clockwise_after_toggling_button_6_and_knob",
                                                  27: "knob_clockwise_after_toggling_button_7_and_knob", 
                                                  28: "knob_clockwise_after_toggling_button_8_and_knob",}),
我家全屋智能的HA设置 https://github.com/relliky/Tais_Home_Assistant_Config
回复

使用道具 举报

2

主题

93

帖子

695

积分

高级会员

Rank: 4

积分
695
金钱
602
HASS币
0
发表于 2024-6-16 18:59:20 | 显示全部楼层
relliky 发表于 2024-6-16 18:40
我研究了一下,原本这个芯片是不支持这个8键功能的,只支持4键。

原本芯片只支持的是你截图里面的那一套 ...

最后贴出来的是大佬你写的八键的列表吧,小白不大看得懂,可以指导下这个四键设备要怎么写converter才能实现旋转角度吗
回复

使用道具 举报

32

主题

1059

帖子

4870

积分

论坛元老

Rank: 8Rank: 8

积分
4870
金钱
3796
HASS币
90
 楼主| 发表于 2024-6-17 00:21:31 | 显示全部楼层
本帖最后由 relliky 于 2024-6-17 00:30 编辑
invincible 发表于 2024-6-16 18:59
最后贴出来的是大佬你写的八键的列表吧,小白不大看得懂,可以指导下这个四键设备要怎么写converter才能 ...

对的,那个是八键的,设备不会返回真实的旋转幅度。

我以为你和我是同一个设备。。。原来你是个四键的设备。
我不确定它有不有一样的问题,你先的看看它没有像八键一样搞这种骚操作,如果四键旋钮的开发者没有返回真实的旋转角度,你米家里是无法搜到这个数据的。

如何看有不有?去gateway3集成里打开mqtt log,搜旋钮的mac地址的日志,在旋转按钮的时候有没有返回旋钮值。


日志里应该是这样的

2024-05-08 21:15:53.601 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.1.40] {'topic': 'miio/report', 'data': b'{"id":580456024,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1hk9un6hkcg00","mac":"CA:6E:1B:6A:8F:89","pdid":17825},"evt":[{"eid":22052,"edata":"16"}],"frmCnt":1,"gwts":1715199353}}'}


如果你旋的时候,朝一个方向,旋转的多和旋转的少,是返回的一样的edata,那它肯定就没有记录旋钮幅度。如果不一样,那有可能它有记录角度,你可以再尝试写converter。

具体的怎么弄我没有设备,没办法测试,但你可以试试


        ConstConv("action", mi="5.e.1036", value="rotate"),
        BaseConv("rotate", mi="5.e.1036.p.2"),


但我不保证工作,我也没办法查错。
我家全屋智能的HA设置 https://github.com/relliky/Tais_Home_Assistant_Config
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-10-18 15:12 , Processed in 0.062222 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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