YinHangCode / homebridge-mi-aqara

a homebridge plugin for XiaoMi Aqara plugin.
1.08k stars 154 forks source link

device not match to config because lost first letter 0 in MAC address when read_rsp message back #267

Open xmmwc opened 5 years ago

xmmwc commented 5 years ago
[2019-4-12 15:32:44] [MiAqaraPlatform] [INFO]start success...
[2019-4-12 15:32:44] [MiAqaraPlatform] [INFO]config gateways: 0XXXXXXXXXXX
[2019-4-12 15:32:44] [MiAqaraPlatform] [INFO]bind address is: 0.0.0.0
[2019-4-12 15:32:44] [MiAqaraPlatform] [DEBUG][Revc]{"cmd":"virtual_iam","sid":"0XXXXXXXXXXX","port":"9898","ip":"XXX.XXX.XXX.XXX"}
[2019-4-12 15:32:44] [MiAqaraPlatform] [DEBUG][Send]{"cmd":"read", "sid":"0XXXXXXXXXXX"}
[2019-4-12 15:32:44] [MiAqaraPlatform] [INFO]Aqara LAN protocol server is listening on port: 9898
[2019-4-12 15:32:44] [MiAqaraPlatform] [DEBUG][Revc]{"cmd":"read_rsp","model":"acpartner.v3","sid":"XXXXXXXXXXX","params":[{"ac_state":18947074},{"ac_power":0},{"proto_version":"2.0.1"},{"fw_ver":"1.4.1_156.0149"}]}

后续就会加载配件了

...
    } else if (cmd === 'read_ack' || cmd === 'read_rsp') {
        var msgTag = 'read_' + jsonObj['sid'];
        const p = that.getPromises(msgTag);
        if(!p) {
            that.log.warn("[Revc]" + msg);
            return;
        } else {
...

就是这个地方的 jsonObj['XXXXXXXXXXX'] 和config中配置的 '0XXXXXXXXXXX'不一致 导致msgTag找不到Promises

求修复,暂时不知道前几位是0的情况是不是在网关返回时都出现丢失

tath105 commented 5 years ago

小米網關也會遇上同一個問題. 0會消失

[4/14/2019, 3:29:23 PM] [MiAqaraPlatform] [INFO]config gateways: 04aabbaabbaa, f0aabbaabbaa, f0bbaabbaabb [4/14/2019, 3:29:24 PM] [MiAqaraPlatform] [WARN][Revc]{"cmd":"read_ack","model":"gateway","sid":"4aabbaabbaa","short_id":0,"data":"{\"rgb\":0,\"illumination\":1292,\"proto_version\":\"1.1.2\"}"}

gaojianchina commented 5 years ago

这应该和下面那些报出[Warn][Revc]...的问题是一个吧. 我的网关MAC不幸地以0开头了...

xmmwc commented 5 years ago

很可能就是这个问题,我自己改了下 #268 你可以试试

S9uare commented 5 years ago

@YinHangCode can we have a fix for this?

xmmwc commented 5 years ago

@S9uare you can use this #268.I fix it in my branch

S9uare commented 5 years ago

@S9uare you can use this #268.I fix it in my branch

Thanks, I found that and it's running without any problem on my raspberry pi :D

xmmwc commented 5 years ago

i'm glad it helps :)