home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.23k stars 623 forks source link

Force Refresh for Android Auto #3830

Open GSzabados opened 1 year ago

GSzabados commented 1 year ago

Is your feature request related to a problem? Please describe.

It has happened with me multiple times that the HA app couldn't connect to the server when the phone is connected to Android Auto. When this happens during opening the Android Auto HA app the only icon loaded is the Navigation one and nothing can be accessed. Leaving from the AA HA app and entering again changes nothing, the same screen stays on with only the Navigation icon. Even if trying to enter the Navigation it does nothing. Unfortunately the only solution for me is to unplug the phone from AA and plug it back.

Describe the solution you'd like

It would make sense to add a last default icon to refresh the AA HA app, like the Android app offers a refresh option when cannot connect to the server.

Describe alternatives you've considered, if any

I don't have any alternative solution, how a refresh could be forced from the AA screen.

Additional context

dshokouhi commented 1 year ago

A refresh button wont work here as we are creating a subscription to get state updates. Maybe a good fix here is to move the lifecycle over to RESUMED instead of STARTED? 🤔

https://github.com/home-assistant/android/blob/master/app/src/main/java/io/homeassistant/companion/android/vehicle/MainVehicleScreen.kt#L62

https://github.com/home-assistant/android/blob/master/app/src/main/java/io/homeassistant/companion/android/vehicle/EntityGridVehicleScreen.kt#L78

GSzabados commented 1 year ago

When exited an entered on AA all the listed entities are "refreshed" regarding last state change, etc.

But in this case when none of them listed, it does not load any, so your idea sounds good to me, but would that not put too much load on the solution as every time entering would do a new subscription?

The idea of doing this purposefully by a "force refresh" button would keep things simple, but as I understand the logic here is list according to the subscriptions which happens when entering to AA HA. Right? If, so, then your suggestion is good for me.

dshokouhi commented 1 year ago

But in this case when none of them listed, it does not load any, so your idea sounds good to me, but would that not put too much load on the solution as every time entering would do a new subscription?

the subscription is attached to the screens lifecycle so it will stop when the app is not open, we need to make sure subscriptions stop appropriately otherwise they can run forever in teh background.

For reference our widgets that also update based on a state change have similar issue. Those subscriptions are managed by the screen turning on and off.

dshokouhi commented 1 year ago

So it seems the lifecycle state is not completely what we need to do here. Reloading the entities also needs to happen so we need to rethink things a bit more and also consider the state the user is left in too. A refresh/retry button may be suitable and more expected as we cannot auto update as the subscription is not valid and we dont have any entities.

In the meantime you dont have to disconnect from thar car, force stopping HA from your phone and opening the app again is good enough to retrigger the process. Also switching servers can also help restart things if thats available to you.

GSzabados commented 1 year ago

In the meantime you dont have to disconnect from thar car, force stopping HA from your phone and opening the app again is good enough to retrigger the process.

Actually that is what I am trying to avoid. Taking the phone and doing anything on it.

mgbarton commented 11 months ago

My Volvo XC40 has AAOS, and the HA app now appears in the Play store. I believe it suffers from this problem as well.

When the HA app is first launched it successfully loads all entities and their state. However if the infotainment system goes to sleep (i.e. I run into the grocery store), upon re-awakening HA does not refresh the state. The only solution I've found is to Force Quit the HA app. Upon re-launch it successfully loads all the current entities and their state.

A Refresh button is welcome, but HA should also refresh automatically whenever returning to the foreground - either from a dormant state or from other loss of connectivity.

ingenika commented 11 months ago

https://androidautorepair.github.io/repair

dgomes commented 4 months ago

I believe the issue is related to lost connectivity, it happens predictably in my car whenever it's in an underground garage and loses connection.