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

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

[技术探讨] gatway3接入的米家寄存器只显示一个开关的问题。

[复制链接]

1

主题

88

帖子

783

积分

高级会员

Rank: 4

积分
783
金钱
695
HASS币
0
发表于 2024-5-12 01:42:24 | 显示全部楼层
TestUser123 发表于 2024-5-12 01:22
那应该没问题的,我这里是可以正常显示和控制4个按键的

抱歉哈,是我的问题,我xiaomi_gayeway3.py 这个文件  忘了打开计算机的后缀显示了。所以保存为xiaomi_gateway3.py.txt了。  。.txt没显示。  现在重新 弄了下,后缀改为.py后,HA里已经显示了。 谢谢!
回复

使用道具 举报

1

主题

88

帖子

783

积分

高级会员

Rank: 4

积分
783
金钱
695
HASS币
0
发表于 2024-5-12 22:19:26 | 显示全部楼层
TestUser123 发表于 2024-5-12 01:22
那应该没问题的,我这里是可以正常显示和控制4个按键的

请问一下老哥,这个寄存器还提供一个背光灯作为一路寄存器的,请问有办法接入到gateway3么? 如果有的话,这个代码应该怎么写
回复

使用道具 举报

50

主题

181

帖子

1449

积分

金牌会员

Rank: 6Rank: 6

积分
1449
金钱
1268
HASS币
0
发表于 2024-5-14 18:15:42 | 显示全部楼层
karl321 发表于 2024-5-12 01:42
抱歉哈,是我的问题,我xiaomi_gayeway3.py 这个文件  忘了打开计算机的后缀显示了。所以保存为xiaomi_ga ...

请问,目前还能正常使用吗?我也是买的这个15418的寄存器,但是不管我怎么重启,都只显示一个开关,不知道哪里出在问题?我的xiaomi_gayeway3版本为4.0.5、是在和configration.yaml同一个目录下新建的  xiaomi_gateway3.py
WX20240514-181449@2x.png
WX20240514-180810@2x.png
WX20240514-180844@2x.png
WX20240514-180951@2x.png

回复

使用道具 举报

1

主题

88

帖子

783

积分

高级会员

Rank: 4

积分
783
金钱
695
HASS币
0
发表于 2024-5-14 22:00:40 | 显示全部楼层
zgxman 发表于 2024-5-14 18:15
请问,目前还能正常使用吗?我也是买的这个15418的寄存器,但是不管我怎么重启,都只显示一个开关,不知 ...

你的是老版本的代码,用不了。  看我这个。
from custom_components.xiaomi_gateway3.core.devices import *

DEVICES = [{
     15418: ["LeMesh", "Mesh Switch", "lemesh.switch.sw4a02"],
    "spec": [
        BaseConv("channel_1", "switch", mi="2.p.1"),
        BaseConv("channel_2", "switch", mi="3.p.1"),
        BaseConv("channel_3", "switch", mi="4.p.1"),
        BaseConv("channel_4", "switch", mi="12.p.1"),
        BaseConv("channel_5", "switch", mi="5.p.1"),
        MapConv("power_on_state_1", "select", mi="2.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("power_on_state_2", "select", mi="3.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("power_on_state_3", "select", mi="4.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("power_on_state_4", "select", mi="12.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("wireless_1", "select", mi="2.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("wireless_2", "select", mi="3.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("wireless_3", "select", mi="4.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("wireless_4", "select", mi="12.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("mode", "select", mi="8.p.1", map={1: "Top Speed Mode", 2: "Standard Mode"}),
        BaseConv("action", "sensor", entity=ENTITY_DISABLED),
        ConstConv("action", mi="14.e.1", value=BUTTON_1_SINGLE),
        ConstConv("action", mi="14.e.2", value=BUTTON_1_DOUBLE),
        ConstConv("action", mi="14.e.3", value=BUTTON_1_HOLD),
        ConstConv("action", mi="15.e.1", value=BUTTON_2_SINGLE),
        ConstConv("action", mi="15.e.2", value=BUTTON_2_DOUBLE),
        ConstConv("action", mi="15.e.3", value=BUTTON_2_HOLD),
        ConstConv("action", mi="16.e.1", value=BUTTON_3_SINGLE),
        ConstConv("action", mi="16.e.2", value=BUTTON_2_DOUBLE),
        ConstConv("action", mi="16.e.3", value=BUTTON_3_HOLD),
        ConstConv("action", mi="17.e.1", value=BUTTON_4_SINGLE),
        ConstConv("action", mi="17.e.2", value=button_4_double),
        ConstConv("action", mi="17.e.3", value=BUTTON_4_HOLD),
    ],
}] + DEVICES
回复

使用道具 举报

50

主题

181

帖子

1449

积分

金牌会员

Rank: 6Rank: 6

积分
1449
金钱
1268
HASS币
0
发表于 2024-5-15 02:42:19 | 显示全部楼层
karl321 发表于 2024-5-14 22:00
你的是老版本的代码,用不了。  看我这个。

大佬,请问直接复制你的代码就可以了吗?我直接复制,不行,然后又修改了这样,还是不行 WX20240515-023832@2x.png
回复

使用道具 举报

1

主题

88

帖子

783

积分

高级会员

Rank: 4

积分
783
金钱
695
HASS币
0
发表于 2024-5-15 03:48:13 | 显示全部楼层
zgxman 发表于 2024-5-15 02:42
大佬,请问直接复制你的代码就可以了吗?我直接复制,不行,然后又修改了这样,还是不行
...

改了下 试试这个
from custom_components.xiaomi_gateway3.core.devices import *

DEVICES = [{
     15418: ["LeMesh", "Mesh Switch", "lemesh.switch.sw4a02"],
    "spec": [
        BaseConv("channel_1", "switch", mi="2.p.1"),
        BaseConv("channel_2", "switch", mi="3.p.1"),
        BaseConv("channel_3", "switch", mi="4.p.1"),
        BaseConv("channel_4", "switch", mi="12.p.1"),
        BaseConv("channel_5", "switch", mi="5.p.1"),
        MapConv("power_on_state_1", "select", mi="2.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("power_on_state_2", "select", mi="3.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("power_on_state_3", "select", mi="4.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("power_on_state_4", "select", mi="12.p.2", map={1: "On", 2: "Off", 3: "Default"}),
        MapConv("wireless_1", "select", mi="2.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("wireless_2", "select", mi="3.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("wireless_3", "select", mi="4.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("wireless_4", "select", mi="12.p.3", map={0: "default", 1: "Wireless", 2: "Wireless", 3: "Wireless"}),
        MapConv("mode", "select", mi="8.p.1", map={1: "Top Speed Mode", 2: "Standard Mode"}),
        BaseConv("action", "sensor", entity=ENTITY_DISABLED),
        ConstConv("action", mi="14.e.1", value=BUTTON_1_SINGLE),
        ConstConv("action", mi="14.e.2", value=BUTTON_1_DOUBLE),
        ConstConv("action", mi="14.e.3", value=BUTTON_1_HOLD),
        ConstConv("action", mi="15.e.1", value=BUTTON_2_SINGLE),
        ConstConv("action", mi="15.e.2", value=BUTTON_2_DOUBLE),
        ConstConv("action", mi="15.e.3", value=BUTTON_2_HOLD),
        ConstConv("action", mi="16.e.1", value=BUTTON_3_SINGLE),
        ConstConv("action", mi="16.e.2", value=BUTTON_2_DOUBLE),
        ConstConv("action", mi="16.e.3", value=BUTTON_3_HOLD),
        ConstConv("action", mi="17.e.1", value=BUTTON_4_SINGLE),
        ConstConv("action", mi="17.e.2", value="button_4_double"),
        ConstConv("action", mi="17.e.3", value=BUTTON_4_HOLD),
    ],
}] + DEVICES
回复

使用道具 举报

50

主题

181

帖子

1449

积分

金牌会员

Rank: 6Rank: 6

积分
1449
金钱
1268
HASS币
0
发表于 2024-5-15 06:54:55 | 显示全部楼层
karl321 发表于 2024-5-15 03:48
改了下 试试这个

多谢大佬,已经弄好了
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-25 03:08 , Processed in 0.382241 second(s), 29 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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