-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
WiFi fast_connect: save/load BSSID and channel for faster connect from sleep #5931
Conversation
Why wouldn't you just add the bssid and channel into the yaml? |
If your network has multiple BSSIDs and the esp device is portable, it will do a scan every time the BSSID from the yaml is not in range. |
But setting the bssid in yaml vs it being loaded from the preferences in this PR is exactly the same... |
The difference is the preference will be updated, when the BSSID changes. This ensures a faster connection time for future connects. If you put the BSSID in the yaml, the connection time will be slow if the BSSID changes. |
My WiFi network is 3 access points providing one network, and they automatically check congestion to switch to the least used channel every 2 weeks. So that's 1 SSID, 3 BSSIDs, and a channel that can randomly change. It's not an unusual setup these days - consumer-level mesh WiFi systems are becoming more common, and a lot of them self-optimise. Then there are commercial/industrial environments, which will almost always have multiple access points. As @rguca said, manually setting the BSSID and channel in YAML would only help when you've got only 1 access point. But it also only helps when the channel never changes - even for people with only 1 access point, that's not necessarily the case. Saving them in preferences makes it a cache for the last known good connection, which is the most common case for reconnections for everyone. The times you wouldn't benefit would be (from most common to least common):
Compared to saving in preferences, setting it in YAML would be only help with the last of those conditions - which should be the thing that happens the least often.
In addition to all the above, setting it in YAML requires that you know & manually specify the BSSID and channel - neither of which I would expect the average person to know how to find (doubly so because you'd almost never need to know them). Caching it in preferences makes it configuration-free, so everyone automatically benefits. But I would suggest adding an optional
|
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.
Sorry for the delay. I just came back to this now and reading above, I think its fine to merge. This code is still "hidden" behind fast_connect: true
so it should not affect most people that are not using that.
What does this implement/fix?
The fast_connect option allows to skip the scan for networks. Still, a scan for BSSID and channel is performed, which results in a connect time around 4 seconds.
This PR allows to save BSSID and channel, so no scan has to be performed on wake. The connect time is reduced to 1 second -> significant battery life improvement for sleeping devices that only wake to push their data.
Types of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: