home-assistant / home-assistant/android
Enable persistent connection only when at home and disconnected from the internet
- Dominant language
- Kotlin
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 81
Description
**Is your feature request related to a problem? Please describe.**
I'd like to save battery under normal circumstances by keeping the websocket connection disabled (relying on Firebase for notifications). _However_, one key feature that I like of the websocket connection (when on the same local network as my HA server) is the ability to get notifications from HA locally, without relying on any internet connections. This is very useful, for example, when the internet is down; I have an automation in HA to _notify me_ when the internet is down.
The problem is that to do this, websocket connection must be enabled for this to work; but this uses more battery. Since I spend the _majority_ of my time at home, it effectively stays on almost all the time, negating any battery savings from the "enable only when at home" setting.
**Describe the solution you'd like**
Would it be possible to add an option to enable the websocket when at home, but only when there's no external internet access available? I noticed [this line](https://github.com/home-assistant/android/blob/44807af50fd915b10bb99d2f8cd55965d5a50dd7/app/src/main/java/io/homeassistant/companion/android/websocket/WebsocketManager.kt#L133) in the Websocket Manager code; is this possible information to get from Android's API?
**Describe alternatives you've considered, if any**
If this is not possible, an alternative solution would be to use something like Tasker to do the "home, but no internet" detection. However, we'd need a way to inform the HA app to change the websocket setting _EDIT: without relying on the HA server sending a message, which would not reach the device without an internet connection_. Could we expose that setting through an intent receiver, like the [`io.homeassistant.companion.android.UPDATE_SENSORS` intent](https://github.com/home-assistant/android/blob/44807af50fd915b10bb99d2f8cd55965d5a50dd7/app/src/main/AndroidManifest.xml#L102)?
In fact, even if the primary request above _is_ fulfilled, adding this could a useful feature, anyway.
**Additional context**
Contributor guide
Assessment
This issue has not been assessed yet.