miio
miio copied to clipboard
discovery command does not work or something's wrong with me?
Hi. I don't get what's wrong.
I have miio installed globally and run miio discover
It writes INFO Discovering devices. Press Ctrl+C to stop.
in console and that's it. Nothing happens, no devices found in about 10 minutes.
Though I have plenty of devices in my network and even able to discover them via UDP 4321 port ("Green meter gateway LAN communication protocol V1.0. 9").
So, what am I doing wrong?
I was just facing the same issue with nodejs v10.7.0 on windows.
I haven't yet figured out the exact reason but my feeling is that it is a bug in nodejs dgram lib (on windows at least) when you have multiple network interfaces, packets are not broadcasted to all the interfaces but only to one selected with an unknown logic.
I managed to work around the issue by forcing miio to bind on my lan interface. Then packet are properly sent over network and devices reply.
Keeping on digging....
@sinopsysHK how did you manage miio to bind to a particular interface?
first option was disabling all the other interfaces.
Second option was hard-coding the IP address to bind in underlying package but I do not remember which one.
Cool, worked for me to hardcode in /usr/lib/node_modules/miio/lib/network.js:136
. Thanks!