-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Disable lazy discover in xiaomi_miio #82601
Disable lazy discover in xiaomi_miio #82601
Conversation
Hi mrwogu It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
Hey there @rytilahti, @syssi, @starkillerOG, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this, but I'm wondering if we should default to False
at least for the beta? If we receive bug reports about issues, we can always revert it back to True
during the beta phase.
My reasoning is that I cannot anymore remember why the lazy discovery was even added to the library, but what it does is, IIRC, is to perform the handshake only 1) if it wasn't ever done before or 2) after an error with communicating the device occurred. If it works fine when it's false, I could remove the setting altogether (or default to False) in the future python-miio release.
I'll do some testing with my few devices using False
, and report back my findings soonish.
6116cb4
to
56642b9
Compare
I've fixed code with your review comments, and added new commit with change default lazy_discover to Thanks |
Great, I modified the description and added second-opinion-wanted to get also someone else to chime in if the approach is viable. Please fix the config flow tests to make the CI pass again. |
Just for the reference, I did some digging to find out that the lazy discovery was added in rytilahti/python-miio#215 and I noted that some other impl. (likely aholstenson's miio lib) performed the handshaking only every 180 or 200 seconds. I am still perplexed why not having the handshake is causing the issues with the integration given a handshake should be done automatically when encountering an error, but I start to feel that instead of adding a setting we should just default the For 0.6 series of python-miio, I think it the option will go away in favor of "handshake interval" setting that will default to 120s, if the experiences from beta look promising. |
@rytilahti I think sending the handshake every 120 seconds is indeed better than doing it always. |
@starkillerOG you are right, I added a todo to rytilahti/python-miio#1114 to replace the current lazy discovery in favor of "time since last handshake" option. If some devices require this for every request, it can be configured to 0. The beta cut off is on upcoming wednesday, hopefully we can get this PR merged for that. |
@rytilahti what I'm supposed to do now? Remove setting and just pass False as argument to lazy_discover? |
@mrwogu yeah, I think it would be the best option for the time being, and other devs agreed on discord that introducing low-level configuration options is not a way to go. I cannot test this currently against the devices in my possession, but we are going to need more input to verify that it doesn't break the integration against other devices. Do you have other devices besides the air purifier to check that they keep working? @starkillerOG would you have some time to test the change against the devices you have? |
8e6c9d5
to
76c9ec3
Compare
@rytilahti done.
Yes, I have several purifiers, a humidifier, a fan and a Roborock. |
Okay, great!
So, my personal preference–given the current ongoing refactoring of the lib & the integration–would be disabling it also for the vacuum by setting the property just like I created rytilahti/python-miio#1606 to fix the constructor signature, but I don't have any free time to create a separate maintenance branch for 0.5 series and prepare releases, etc. The 0.6 push is much more important for future-proofing the library, and that's where I prioritize my personal efforts at the moment. |
I can indeed test with my roborock and aqara gateways, but the current code does not touch the vacuums or gateways, so there is now no point in testing for me. |
@rytilahti What are the next steps needed to move this PR forward? |
@frenck Basically doing this & getting this merged for broader testing would be my preference. If it causes more trouble than it fixes, we can easily revert/flip the setting. @starkillerOG if you don't mind testing my suggestion on your local setup (for the vacuum and the gateway), it would be great :-) |
Friendly ping on this PR (if its still relevant for #59215). I have this with one of my fans, it constantly is timing out and would be happy to test this fix out if guided on how to run this locally? |
@Maeur1 I usually just use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just merge this, and revert if it causes more troubles. In the best case this at least alleviates the issue encountered by so many. Thanks for the PR @mrwogu, let's hope this fixes the issue for the time being! 🥇
Proposed change
This PR adds a fix to Xiaomi Miio integration which disable
lazy_discover
mode, which is supported by python-miio.This changes the default behavior as it defaulted previously to enabled. If this change breaks user installations during the beta, we should revert it back to enabled.
Disabling this mode resolves network connection or timeout issues on some Xiaomi devices.
Currently, python-miio supports this for all devices (except RoborockVacuum). For that, we're waiting for python-miio 0.6 release with merged PR rytilahti/python-miio#1606.
For now, I left the TODO in the code.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: