Homeassistant App for Android "Connection lost", not reconnecting

Hej,
so I have the latest version of Hass.os running on a Pi4 in my local network. I can control it via mobilephone and a nice lovelace dashboard without issues. I repurposed an old android phone to use as a wallpanel, so I don’t have to search my phone if I want to turn the lights on.

That wallpanel phone is constantly charging, constantly on. Nontheless it sometimes loses connection (maybe after the display switches off or WiFi goes into some sleep mode), then displays the error message “Connection lost. Reconnecting…” but it doesn’t actually reconnect. It’s only that phone, the pi and hassio are running, because whenI connect with my other phone it’s no problem.
Hence all the “restart Homeassistant” tipps won’t work. How can I make the frontend to refresh, or Homeassistant App to be contantly on?

Some Apps display a permanent notification in Android to keep the system from switching them into battery-saving mode or so. Any chance to implement that for the official homeassistant app as well?

1 Like

You probably need to go into the settings for that app on phone and turn off battery optimisation.
Also check any settings for WiFi power saving

Thanks, but I lready did turn off “Turn WiFi off during sleep” and “Smart Battery Management”. There are unfortunately no settings for the HomeAssistant app in particular. The App “WaveUp” displays a permanaent notification to stay alive, would be great if hass would also allow something like that, or is there a frontend function/script to auto-reconnect every 10 minutes or so?

Not sure, but in the user profile there is an option “Automatically close connection”. Is that on or off?

2 Likes

There we go! Yes! This was turned on, I switched it off now, let’s see what happens. Thanks so much @spacegaier, I’m always amazed how quickly this forum provides help :smiley:

I had the same problem but found that I did have the “automatically close connection” turned off.
However I turned it on and then off and it seems to fix the issue?
Additionally I had created a user that did not have administrative rights for my Samsung A8 10" tablet so that people could not fiddle. I plant to use this as a control panel when I get it bug free.

Update 2022-01-26
The above did not fix the lost connection issue. It loses connection some time after the display goes off. When I bring the display back it reconnects straight away.
Not quite sure what is best as this does conserve battery but does not update things like battery level when not connected. I use an automation to monitor battery level and when it gets to 50% I turn on a smart switch to start charging tablet. I also do similar to turn off at 99%.

Later in Day
I also have turned on the developer options on Android 11 and activated the Stay Awake option. For those unfamiliar with this option; it allows the tablet to stay awake while charging. This seems to have had the desired effect of keeping the tablet alive and connected while a charging device is connected.

I think the app itself has some issue here.

I know this is an old thread, but I did not want to start a new one to kinda go through the same hoops with the obvious solutions.

My tablet has no battery at all. It is one of likely refurbished ones made to be used always on a power supply, so it’s ideal for a wall dashboard panel.

The issue is, it’s only the app that has the issue. If I create a Chrome shortcut to open the HA dashboard, it works even when the app does not. I need to close the app and reopen it to make it connect again, but the chrome window does not have this problem.

It could of course be that Chrome itself is very chatty when it talks with Google all the time, that it keeps the network connection open?

But still, the HA app likely tries to connect too when I tap the buttons on the dashboard, so wouldn’t that also restore the wifi connection, if it would have been powersaving?

So I am kind of wondering if the HA app itself keeps a connection open to the HA server in case there are notifications etc, and during sleep the connection timeouts, and it does not notice that it happened and tries to use the old handle instead of reconnecting? This is just a guess though, but maybe the web app does it some different way and happens to work in this scenario?

Also, mind you, this issue also happens when the app inhibits display going to sleep.

I will try next with “never turn off display” in Android preferences turned on, and also then checking if the “keep display on” setting matters in different combinations of the android setting and the app setting.