Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加支持ddy.switch.sw4a02 #1356

Open
invoker-karl opened this issue May 14, 2024 · 5 comments
Open

添加支持ddy.switch.sw4a02 #1356

invoker-karl opened this issue May 14, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@invoker-karl
Copy link

invoker-karl commented May 14, 2024

最近购买了米家寄存器。型号是https://home.miot-spec.com/spec/ddy.switch.sw4a02。
`我发现当前版本的gateway3不支持该设备。我尝试自己写了一个转换器,看起来所有功能都工作正常。我希望在未来的版本中能够添加对该设备的支持。谢谢。

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
@1043717432
Copy link

你好。请问你用什么转换器写的?我买了一个橱柜电源也是蓝牙的。也没识别成功。

@invoker-karl
Copy link
Author

参照gateway3的代码手写的呀。 转换器的意思是 按照gateway3的代码,依据米家的代码,比如说mi="2.p.1"(网页可查),然后转换的呀。 换句话说,上面的代码就是转换器。

@1043717432
Copy link

https://home.miot-spec.com/spec/ftd.light.dsplmp 请问这个如何转换。目前在HA最新版本和Xiaomi Gateway 3 最新固件里。他显示的只是一个开关,其实是一个调光调色的电源驱动。。谢谢了!

@AlexxIT AlexxIT added the enhancement New feature or request label May 24, 2024
@AlexxIT AlexxIT self-assigned this May 24, 2024
@invoker-karl
Copy link
Author

https://bbs.hassbian.com/thread-17548-1-3.html 请参考这篇帖子,同时参考本插件的devices设备,模仿写。

@1043717432
Copy link

https://bbs.hassbian.com/thread-17548-1-3.html 请参考这篇帖子,同时参考本插件的devices设备,模仿写。

谢谢。。我看一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants