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
https://github.com/AlexxIT/Blog
MIT License
2.47k stars 348 forks source link

the file xiaomi_gateway3.py doesn't work after upgrade to V4.0.0 #1319

Closed meineihan closed 7 months ago

meineihan commented 7 months ago

could not add new devices by writing an external converter

AlexxIT commented 7 months ago

Can't confirm. I have tested this function.

meineihan commented 7 months ago

Can't confirm. I have tested this function.

from custom_components.xiaomi_gateway3.core.converters.devices import *

DEVICES = [{
    15660: ["Linptech", "Three key Wall Switch", "linp.switch.qt1db3"],
    "spec": [
        BaseConv("switch_1", "switch", mi="2.p.1"),
        BaseConv("switch_2", "switch", mi="3.p.1"),
        BaseConv("switch_3", "switch", mi="4.p.1"),
        MapConv("mode_1", "select", mi="2.p.2", map={0: "wired", 1: "wireless"}),
        MapConv("mode_2", "select", mi="3.p.2", map={0: "wired", 1: "wireless"}),
        MapConv("mode_3", "select", mi="4.p.2", map={0: "wired", 1: "wireless"}),
        BaseConv("action", "sensor"),
        ConstConv("action", mi="5.e.1", value=BUTTON_1_SINGLE),
        ConstConv("action", mi="6.e.1", value=BUTTON_2_SINGLE),
        ConstConv("action", mi="7.e.1", value=BUTTON_3_SINGLE),
    ],
}] + DEVICES

Is this code correct?

It doesn't work. QQ图片20240405170731

But if I add this code to devices.py it works. QQ图片20240405173033

AlexxIT commented 7 months ago

Devices moved: from custom_components.xiaomi_gateway3.core.devices import *

PS. My bad. Made a change to the wiki.

meineihan commented 7 months ago

from custom_components.xiaomi_gateway3.core.devices import *

Great! Now it works!