YinHangCode / homebridge-mi-aqara

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

Accesories are not loaded #74

Open fjlopezandreu opened 7 years ago

fjlopezandreu commented 7 years ago

I have a raspberry pi with the latest version of raspbian and when I run homebridge with homebridge-mi-aqara and configuro homekit I do not see any accessory.

In the execution console no error is observed, and the events that produce the accessories are captured by the plugin and shown in the console as you can see in the image.

homebridge-mi-aqara problem

It has been running for two days and the cachedAccessories file is empty ([]).

According to the Mi Home app my model is lumi.gateway.v3.

I have tested it with other plugins like homebridge-aqara and it works perfectly.

weikuan1024 commented 7 years ago

try change homekit pin&username

fjlopezandreu commented 7 years ago

I have done it several times without positive results.

It is clear that the plugin communicates correctly with the gateway since it shows the events that are occurring. I think the problem is that it is not written to the file cachedAccessories.

fjlopezandreu commented 7 years ago

I have debugged the MiAqaraPlatform.js file and noticed that the gateway only sends heartbeat messages.

Therefore, in the function MiAqaraPlatform.prototype.parseMessage runs the code snippet corresponding to the heartbeat condition and finally runs the this.Gateways.updateGateway function.

As this.Gateways.addOrUpdateGateway or this.Gateways.addGateway (get_id_list_ack condition in parseMessage) was not initially executed, no accessory is added since there is no gateway created.

ClarenceTsang commented 7 years ago

I had a same problem, my gateway is v3 too, homebridge-mi-aqara can not show the accessory, but homebridge-aqara is ok.

SpiritAmalthea commented 7 years ago

Had same problem. Fixed by change const multicastAddress = '224.0.0.50' to const multicastAddress = '192.168.1.64' where '192.168.1.64' is IP address of Gateway. Dont know why but gateway not responding on commands ({"cmd":"whois"} for example) from MiAqaraPlatform.js if i try connect by multicast address(224.0.0.50). But in same time if i send commands from my PC (Packet sender application) both IP`s responding well.

Any ideas why?

Jinsterrrr commented 6 years ago

Hi SpiritAmalthea. Where is this multicastaddress variable? It’s not part of my config.json

SpiritAmalthea commented 6 years ago

Hi SpiritAmalthea. Where is this multicastaddress variable? It’s not part of my config.json

Hello Jinsterrrr. Why config.json? We are talking about index.js (https://github.com/YinHangCode/homebridge-mi-aqara/blob/master/index.js)

Jinsterrrr commented 6 years ago

I found index.js in /usr/lib/node_modules/homebridge-mi-aqara Is that the correct location? I modified the multicast address to 10.0.0.123 (my aqara gateway IP) and also tried 10.0.0.210 (the address where homebridge is run). Both resulted in Homebridge crashing on launch with the following:

[2017-12-17 03:01:35] [MiAqaraPlatform] [DEBUG][Send]{"cmd": "whois"} [2017-12-17 03:01:36] [MiAqaraPlatform] [INFO]server is listening on port 9898. dgram.js:614 throw errnoException(err, 'addMembership'); ^

Error: addMembership EINVAL at _errnoException (util.js:1024:11) at Socket.addMembership (dgram.js:614:11) at Socket. (/usr/lib/node_modules/homebridge-mi-aqara/index.js:174:22) at emitNone (events.js:111:20) at Socket.emit (events.js:208:7) at startListening (dgram.js:156:10) at _handle.lookup (dgram.js:273:7) at _combinedTickCallback (internal/process/next_tick.js:141:11) at process._tickCallback (internal/process/next_tick.js:180:9) at Function.Module.runMain (module.js:678:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3

SpiritAmalthea commented 6 years ago

Jinsterrrr. Keep ''224.0.0.50'' in addMembership function

OnilMr commented 6 years ago

Hi guys I'm new to this... I've found the index.js in /usr/local/lib/node_modules/homebridge-mi-aqara and I changed the "const multicastAddress = '224.0.0.50' " to the gateway's IP address but now it gives the same error from addMembership EINVAL.

SpiritAmalthea what do you mean about keeping the "224.0.0.50" ? How can I do it? I've only changed the multicastAddress...

best regards

SpiritAmalthea commented 6 years ago

SpiritAmalthea what do you mean about keeping the "224.0.0.50" ? How can I do it? I've only changed the multicastAddress...

index.js file: line 17 const multicastAddress = 'your gateway IP adress'; line 86 you should change serverSocket.addMembership(multicastAddress) to serverSocket.addMembership('224.0.0.50') line 173 you should change serverSocket.addMembership(multicastAddress) to serverSocket.addMembership('224.0.0.50')

So you changing multicastAddress const, but in addMembership function you keep old value "224.0.0.50"

URBANsUNITED commented 6 years ago

Had same issue but with Homebride working on my Raspberry Pi3 with VPN Could solve loading accessories by using above's fix! Thanks SpiritAmalthea for your fix. All works as it should with homebridge-mi-aqara now :)

URBANsUNITED

stilighen commented 6 years ago

Hi guys, I'm new on homebridge and I'm trying to add xiaomi devices to it. I've installed the plugin, when I run homebridge the plugin is loaded correctly the first time, all the accessories are online in my home app, after few seconds it stops working and the devices do not respond, on debug the error is:

[3/11/2018, 6:42:20 PM] [MiAqaraPlatform] [ERROR]Error: Invalid key [3/11/2018, 6:42:20 PM] [MiAqaraPlatform] [ERROR]Error: Invalid key at MiAqaraPlatform.parseMessage (/usr/local/lib/node_modules/homebridge-mi-aqara-2/index.js:301:26) at emitTwo (events.js:106:13) at Socket.emit (events.js:192:7) at UDP.onMessage [as onmessage] (dgram.js:546:8)

I've already applied the fix, thanks SpiritAmalthea, but my problem still persists, I've though it was due to the multicast address so I've checked and for my network it is 224.0.0.251, I've tried to applied it following the fix, nothing..I have been experiencing this issue and I don't know where is the problem. Ideas? thanks for the support.

SpiritAmalthea commented 6 years ago

Hi guys, I'm new on homebridge and I'm trying to add xiaomi devices to it. I've installed the plugin, when I run homebridge the plugin is loaded correctly the first time, all the accessories are online in my home app, after few seconds it stops working and the devices do not respond, on debug the error is:

[3/11/2018, 6:42:20 PM] [MiAqaraPlatform] [ERROR]Error: Invalid key [3/11/2018, 6:42:20 PM] [MiAqaraPlatform] [ERROR]Error: Invalid key at MiAqaraPlatform.parseMessage (/usr/local/lib/node_modules/homebridge-mi-aqara-2/index.js:301:26) at emitTwo (events.js:106:13) at Socket.emit (events.js:192:7) at UDP.onMessage [as onmessage] (dgram.js:546:8)

I've already applied the fix, thanks SpiritAmalthea, but my problem still persists, I've though it was due to the multicast address so I've checked and for my network it is 224.0.0.251, I've tried to applied it following the fix, nothing..I have been experiencing this issue and I don't know where is the problem. Ideas? thanks for the support.

Hello. Looks like this is error from anoter module 'homebridge-mi-aqara-2' (github.com/acc-ua/homebridge-mi-aqara-2/. You should made issue in corresponding project. Check line 301 in this file (https://github.com/acc-ua/homebridge-mi-aqara-2/blob/master/index.js)

stilighen commented 6 years ago

thanks for the reply, yes I've tried to use homebridge-mi-aqara-2, because with homebridge-mi-aqara i had the same issue,on the first run it didn't work, after multicast address change as you proposed I received the error Invalid key after few seconds.

I've thought that both forks were similar.

At the end, each fork doesn't work: homebridge-aqara homebridge-mi-aqara homebridge-mi-aqara-2

it is little bit frustrating :(

francisco-navarro commented 6 years ago

Same problem :( Any idea?

studentIvan commented 5 years ago

SpiritAmalthea what do you mean about keeping the "224.0.0.50" ? How can I do it? I've only changed the multicastAddress...

index.js file: line 17 const multicastAddress = 'your gateway IP adress'; line 86 you should change serverSocket.addMembership(multicastAddress) to serverSocket.addMembership('224.0.0.50') line 173 you should change serverSocket.addMembership(multicastAddress) to serverSocket.addMembership('224.0.0.50')

So you changing multicastAddress const, but in addMembership function you keep old value "224.0.0.50"

Have same problem. Have done this. now I see my gateway in the MiAqara Manage, but nothing accessories and nothing new in homebridge

SpiritAmalthea commented 5 years ago

Have same problem. Have done this. now I see my gateway in the MiAqara Manage, but nothing accessories and nothing new in homebridge

Did you change your config file? I mean homebridge/config.json