-
-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some devices not responding across subnets. #422
Comments
yes this is definitely a bug. i bought two chuangmi_ir devices and encountered same issue |
@syssi any chance you know what is going on here? :-) |
I own the device and will try to reproduce the issue. I don't know what's going on here. The code is untouched for month. I've no clue why it's broken now. |
I just don't think we have catched this bug before, is it only manifests when trying to communicate across subnets (in my case routed VLANs) In my case the IR device is in 10.0.3.0/24 One idea I had is just that the device does not like to communicate with IPs that are not in the same subnets as itself, in which case I don't think there is anything we can do. |
for my case, my hassbian and the remote is in the same subnet, sadly i still get the issue |
This is the initial commit to rework the handshake/discovery process, separating them to separate entities. The discovery part from Device class is moved into MiIODiscovery class usable for broadcast discovery of available devices. Also, instead of printing out the details from discovered devices, a list of Devices is being returned. The discover() method of the class is extended to allow discovery on all network interfaces (instead of using 255.255.255.255), making it easier to perform the initial configuration of non-provisioned devices and/or work with devices in other subnets. Although the change cause some duplicate code (mainly the handshake payload), this will make the responsibilities of corresponding classes clearer and code more usable for 3rd party developers. There will be cleanups and (likely also) renamings of some of the parts, but I wanted to make this available for others to comment. TODO: * Upcasting the Device to a corresponding implementation class (miIO.info model information could be useful, too..) * Decide how to handle the returning of discovered devices. Use a separate DiscoveredDevice class which can be used to initialize the real device, or use the existing Device and do the casting trick? Related to #152 (and maybe #422).
I've the same issue with my humidifiers! My test script: #!/usr/bin/env python
from miio.airhumidifier import AirHumidifier
x = AirHumidifier(ip='10.9.10.23', token='…')
print(x.status()) My error:
I've the same issue with the I'm sure the tokens and IP address are correct, as I can |
@domibarton Could you capture some network traffic? There must be a difference between the MiHome app (android <-> device) and the python-miio traffic (python-miio <-> device). |
@syssi I didn't capture anything, but I can try if you want. The communication isn't encrypted? I'm using the iOS client. When starting the humidifier via, isn't the traffic then routed via Xiaomi's cloud service/server? |
So my setup looks like this:
The firewall is configured as following:
I also tried to I'm now capturing traffic the following ways:
There's no reply to the UDP packet, thus the timeout before the |
The MiHome app talks the same protocol as python-miio as long the device is available directly. If your are not at home the instructions are delivered (TCP?) via the xiaomi cloud. Your capture proved: The MiHome app is unable to communicate directly, too. |
My guess is still that it is a "security" feature where the device will not respond to messages not coming from the same subnet. @domibarton any chance you are able to replay that first UDP package but change the IP header such that it looks to be coming from the same subnet? |
@syssi OC the app isn't communicating directly, as I'm connected to a different subnet. I assume the app wouldn't "guess" that the device is probably in another routed subnet and just give it a try. I think the app will check the direct connection only when the device IP is in the same subnet / SSID or alike? @cnrd Mhm good point, I can try to SNAT that UDP package and see if I get a response from the device. Or I could configure the Nvmd of it, the RoboRock and the humidifiers apparently work differently. The RoboRock is in the same subnet and responds to the UDP packages, while the humidifers stay silent. I'll test the SNAT-thingy this evening (Switzerland UTC+1 ^^) and let you know! |
@cnrd Sorry for the delay, but I was quite busy the last three days. But I've good news: YAY IT WORKS! I've masqueraded the traffic on the outbound interface of the VLAN/subnet |
Thank you for confirming my suspicion :-) @syssi is there anything we can do about this or do we just have to accept that it only respond if the devices are in the same subnet? (Also I'm not sure if it happens for other devices, but we should probably add something to the documentation, if it can't be fixed). |
ProblemAs @cnrd described above, discovering and querying devices across subnets doesn't work. @cnrd experienced this issue with chuangmi_ir devices, while I discovered the same issue with my humidifers! Please read the comments above for more insights. WorkaroundsMove into the same subnetThe most obvious solution: Move yourself into the same subnet as the Xiaomi devices or vice-versa. Dual-homed nodeInstead of moving your whole HomeAssistant (or whatever hub) into a new subnet, you can also dual-home your node (e.g. server, Raspberry Pi). You can do this either physically by connecting two ethernet cables (requires 2 ethernet ports on your server), or virtually by using VLAN's. I'd probably prefer VLAN's in this case ;) MasqueradingIf you've multiple VLAN's/subnets and you're in control over the router in between, then I'd setup masquerading for the outgoing routing interface of the VLAN/subnet where the Xiaomi devices reside. This basically means changing the source address in the UDP packet headers to the IP address of routing interface. If you want to know more about this, just inform yourself about packet masquerading and/or SNAT. |
I don't think we can do anything about that in the At least if we're staying at this communication protocol & payload. There's probably another way to communicate with the Xiaomi devices, but I didn't look into that. Xiaomi's cloud servers also communicate with the devices. However, the devices are initiating the connection there, so that's most likely a dead path too ;) Nevermind of it, I'd recommend changing the title of this issue to something more generic, as it doesn't only affect IR devices. What I can say right now is that it's also affecting both Xiaomi humidifer types, but not the RoboRock S50. Mentioning this issue in the docs would also be helpful for new users :) |
Btw thanks for your awesome work guys ;) |
@domibarton considering you have been exploring this issue for a while, it would be really awesome if you could create a PR to add your discoveries to the documentation. A new troubleshooting section would be very helpful (there are also other well-known issues, e.g., the token encryption, that are currently only documented in various github issues which are really hard to locate aftwards). |
@rytilahti I'll have a look into it, as I love Sphinx as a Python dev… ;) |
@cnrd What was your device? I'm currently writing the docs, and I'd like to mention that in it! |
This troubleshooting guide is the result of the outcome of issue rytilahti#422. Please have a look at the issue for more insights: rytilahti#422
This troubleshooting guide is the result of the outcome of issue rytilahti#422. Please have a look at the issue for more insights: rytilahti#422
This troubleshooting guide is the result of the outcome of issue rytilahti#422. Please have a look at the issue for more insights: rytilahti#422
I tried on mikrotik router without success. |
For me it also doesn't work with OPNsense. Someone had more luck? Can someone post a screen from inside the rule? Edit: yeah, working now. Wrong configuration of the rule. |
Yes sir, i have this working.
10.0.20.213 = L10 BR_IOT is my IOT vlan interface. You could limit the port to UDP/54321 i suppose, but i couldn't be bothered. |
I run pfsense and even though my HassOS has multiple interfaces, it also has one in the IOT Subnet, and I'm still getting these connectivity blips. I don't see how NAT is the solution to this problem. As far as I can tell everyone here has HASS and their IOT devices on the same home network, be it in the same subnet, or a separate one. Pfsense being a router, should route the packets to the destination subnet, no NAT required, nothing is leaving the home network. |
Hi, I migrated from FHEM to Home Assistant and now my masquerading doesn't work with home assistant. This is how it worked with FHEM:
and this is how it works with Home Assistant:
But why? Which ports are needed by Home Assistant, that FHEM doesn't need? Thanks Hoppel |
I wouldn't use masquerade or NAT-ing. You want HA to talk to another LOCAL device. If that device in another subnet then your router should do the talking for you. |
The router still does the talking. The problem is that the robots wont accept traffic from addresses outside of their own subnet range. |
@rwjack Yes, the iptables rules are configured on my router (Unifi Dream Machine SE). Your last post triggered me to investigate some time into this again. After the migration from FHEM to Home Assistant, my iptables rules didn’t work any more. I described that in my last post. So I configured a trunk port to my home assistant vm and connected the iot vlan to HA. Now, my Xiaomi devices were reachable, but I also had the „connectivity blips“. The devices were switching between available/unavailable constantly. Now with the working iptables rules, the connectivity blips seem to be solved in my case. At least there was no unavailable log for the last 5 hours. Hurrah… 😃 EDIT: Did you see the „Note“ in the HA documentation under „Prerequisites“?
|
@gespo89 this saved me a significant amount of time, thank you so much for writing this out, would suggest adding this to the documentation |
Is here anybody who can help making iptables nat masquerading rules permanent on a Unifi Dram Machine (firmware 3.x)? EDIT: Issue solved. You can find the solution in the link before. Thanks and regards Hoppel |
Any chance to get this done with a simple FritzBox (I don't have any nice pfSense oder DM setup yet)? |
@frank8the9tank wrote:
Hello @frank8the9tank , thanks for the little howto. Today I removed my custom iptables from my udm-se and configured three masquerades for my three xiaomi devices via the unifi network application web interface. It works absolutely fine. My configuration looks similar to yours, but as source I only specified the IP address of my home assistant instance and not my entire VLAN. My Home Assistant is located in my main VLAN (tagged). Thanks again Hoppel |
Hi
I'm trying to change around a couple of things in my HASS setup, which seems to have surfaced a bug in the communication with chuangmi_ir devices.
I can ping the device just fine:
but if i try to get info:
doing the same thing with my Roborock Vacuum works fine:
It does work fine if I have an IP in the same subnet:
I have tested on 2 different physical machines in different subnets, so it shouldn't be a problem with my network configuration.
The text was updated successfully, but these errors were encountered: