Skip to content
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

Wi-Fi sensor improvements #3239

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

anyuta1166
Copy link
Contributor

Summary

This request addresses 2 issues at once, because they are interconnected:

  1. Using wifiManager.scanResults to get signal strength is very unreliable. I often see "-1" on some devices even if Wi-Fi is connected. Use conInfo.rssi for a reliable result.

Also, wifiManager.scanResults is not available if Location is disabled on a device, but conInfo.rssi is available in such case.

  1. There is an issue on devices running Android 10+ (tested on various Android 10 and Android 11 devices). If Wi-Fi is connected, but Location is disabled on a device, getNetworkId() returns -1 and Home Assistant app thinks that we are not connected. But some information - IP address, link speed, frequency, signal strength (via getRssi()) is actually still available. If NetworkId == -1, we can additionally check LinkSpeed to determine that we are connected and provide IP address, link speed, frequency and signal strength.

Please note that if Location is disabled on a device, wifiManager.scanResults is not available, but conInfo.rssi is available, that's why I've merged this into one commit.

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Use rssi instead of scanResults to reliably get signal strength.
Get some info (IP, link speed, frequency, signal strength) and determine connection status even if Location is disabled on a device.
Copy link
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, didn't realize we were hitting an odd issue like that. Thanks for the PR.

@JBassett JBassett merged commit 1638c0f into home-assistant:master Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants