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
Solution to some of the Xiaomi Gateway timeouts #21418
Comments
Keen to see how this works out. My gateways both start with MAC of 04, and I see the same dropped leading zero and the 2.5hour unknown issue with lights not controlled properly. |
Mine's been stable for 19 hours since I made this change, and I get updates from the switch and light sensors. |
CC @syssi |
Great catch! I will prepare a PR. |
Maybe a noob question, but is there a way to know when this fix will appear in an HA update, or should we apply it manually for now? |
It is in 0.88.2 and also the 0.89 beta. |
Awesome. Updated and it's looking good! |
I've posted this in #20329
For completeness...
I have a theory...One thing I have noticed, and including myself, is that the people who appear to have most problems all have MAC address of the gateway starting 04:XX:XX:XX:XX:XX.
When I get updates from a sensor, I can see in the debug these appearing as a PUSH and the sensor gets updated.
However when I get an illumination update from the gateway I don't get the corresponding PUSH debug message.
One thing I notice that the entity_id that home assistant set up, is
sensor.illumination_4XXXXXXXXXX
and
light.gateway_light_4XXXXXXXXXX
thus missing the leading zero.
Could this be causing a mismatch between the SID being broadcast and the HA entitiy?
Okay. Bit more digging, looks like during the discovery phase, the gateway drops this 0 in its response as seen in this nmap trace...
To work around this issue, I modified the xiaomi_gateway init.py in /srv/homeassistant/lib/python3.5/site-packages/xiaomi_gateway on my system. In the following snippet I changed
"sid": resp["sid"],
to
"sid": resp["sid"].rjust(12, '0'),
to pad an extra 0 back to the start of the SID.
now I see the PUSH messages, which according to the code will also reset the last seen item and hence stop the timeouts.
Can somebody who know what they're doing add this into the codebase.
The text was updated successfully, but these errors were encountered: