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

Update wifi sensor on state changes #734

Merged
merged 2 commits into from Aug 11, 2020

Conversation

dshokouhi
Copy link
Member

@dshokouhi dshokouhi commented Aug 11, 2020

Use a broadcast receiver to update the wifi sensor whenever the state has changed. This includes enabling/disabling and network changes.

Adds is_wifi_on attribute to the sensor

Fixes: #429

@JBassett
Copy link
Collaborator

Was this tested without having location permissions? I'm not sure what happens when you try to register a receiver when you don't have permissions.

@dshokouhi
Copy link
Member Author

@JBassett so in the emulator I cleared storage for the app. Logged into my dev instance and did not grant location permssions. Then I proceeded to turn wifi on/off and the app did not crash.

What I see in logcat is 2020-08-11 12:13:59.097 8055-8110/io.homeassistant.companion.android.debug W/NetworkSM: Tried getting wifi info without permission. followed by an error for updating the sensors however the other sensors are able to update just fine. The receiver is still working actually which doesn't make sense?

Should I just add a permission check when we register the receiver to avoid this? I don't see any harm if we are able to trigger sensor updates for everything else when the wifi state changes.

@JBassett
Copy link
Collaborator

No need for the permission check. I'm working on a slight rework of the sensors to help eleviate some of the problems we are seeing with the dynamic updates which should take care of them being enabled vs disabled.

@JBassett JBassett merged commit 7b0e28f into home-assistant:master Aug 11, 2020
@dshokouhi dshokouhi deleted the wifi_sensor_improvement branch August 11, 2020 19:30
@JBassett JBassett added enhancement New feature or request patch A tiny change - Bumps patch build number labels Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed enhancement New feature or request patch A tiny change - Bumps patch build number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Joining or leaving WiFi network should update wifi sensor immediately
3 participants