miio
miio copied to clipboard
Problem to connect from outside of local network
Hi,
First of all big kudos for all of that work - works great - unfortunately whatever works on my local network does not work from outside where ultimately I need it...
What I have done is: I've forwarded port 54321 on my router to point to 54321 on the Xiaomi device.
Error I'm getting:
Error { Error: Call to device timed out
at retry (.../node_modules/miio/lib/device.js:229:18)
at _ensureToken.catch.err (.../node_modules/miio/lib/device.js:242:8)
at <anonymous> code: 'timeout' }
Are there any other ports which are required to be forwarded or is there anything else that I'm missing to make it work ?
Please advise ! Cheers! bajzello
Thanks for opening an issue!
I have no idea how this library would work with port forwarding like that. Is your port forwarding setup as an UDP port?
Hi,
Thanks for responding.
Yes both TCP and UDP are forwarded - the thing is that using ports checker (i.e. https://portchecker.co/) they show up as closed when pointing to Xiaomi device whereas it shows open and works properly when pointing to any other working service witin my local network - so I bet I can safely say that forwarding on my router works fine.
Are you aware of any other ports being used in miio to communicate with devices ? Maybe this is what's missing or maybe there is anything "special" in the way they communicate ?
Cheers, bajzello
For most devices 54321 is the only port used and the gateway uses 9898 for multicast events. My best guess is that the device can't send its reply back to you outside the network. But that's just guessing from my part, there is no way to know what the Mi-devices actually do here :)
Thanks for info - unfortunately it does not solve the problem...
Looks like I will need to create some sort of API calls repeater in my local network to be able to control them from outside...
But if someone will figure out a way to do make it work then it would be useful potentially to many people as more and more things we all host on the cloud and it does not work right now without figuring it out.
Cheers !
Thanks for info - unfortunately it does not solve the problem...
Looks like I will need to create some sort of API calls repeater in my local network to be able to control them from outside...
But if someone will figure out a way to do make it work then it would be useful potentially to many people as more and more things we all host on the cloud and it does not work right now without figuring it out.
Cheers !
Hello. I want to do exactly what you're trying to do. Have you found any solution to connect to the gateway from outside of the local network ?
How does Mi Home app work? Can we do the same?
Hello Thanks! I used the miio plug-in probably directly from Home Assistant and only came here for troubleshooting. Anyway when Adding my Xiaomi devices in HomeAssistant I did:
- settings / devices & services / add integration / ...Xiaomi
- chose: Xiaomi Miio
- gave username & pass & server code (u can find the 1st 2 in the App if you search a bit)
- I chose/ticked Configure Manually !!! a) IP: This was necessary since my HomeAssistant is in a totally different location from my Xiaomi Devices, so I needed to write the destination (xiaomi) ip (I have it in ddns so was pretty easy) b) device Token: look for the great xiaomi 'token_extractor' that i found here and copy-paste the Token c) mind that not all devices can be imported, but most will...
- in the destination rooter (the one with the Xiaomi devices) I needed to Port Forward 54321 to my Xiaomi Hub (both TCP & UDP, but I didn't test what was actually needed) as was mentioned earlier Then the Hub and some entities were discovered. The zigbee ones where not, but I'm ok with this
mind that if you run the extractor in 4b from cmd window as token_extractor.exe > device_list.txt ...enter... then give username/enter/password/enter/area_code/enter/...enter some more times... then you get a file w the devices' list :D
Thanks for the ports tip and the great PlugIn