home-assistant / android

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

zone change / SSID change sometimes doesn't work #1575

Closed energywave closed 2 years ago

energywave commented 3 years ago

Home Assistant Android version: 2021.5.1-full Android version: 9 Phone model: Samsung Galaxy S8 Home Assistant version: 2021.4.6 Last working Home Assistant release (if known):

Description of problem: I have enabled wifi SSID sensor and I use it to speed up identify zone change (like I was discussing here: https://github.com/home-assistant/android/issues/620 ). With latest version of the app it seems that very often the app don't send zone change data when I'm returning from home, while with precious app version it was running in a good way. As said I use wifi SSID change to detect that but then there is the zone, that I expect to be detected by geofencing some way after wifi disconnection. But none of the two works, some days. Then I open the app and it updates, like the background execution is doing something wrong (I know it's running because I continuosly have that SensorWorker notification from the last update...) Today I arrived nearly home from work (about 10 Km) and got no notification so I opened the app and I've seen that it even had not detected that I was at work... But as soon as I opened the app the location updated correctly. So I exported the log in that moment and I've seen that the SSID change thrown an exception but I cannot understand what appened. I've seen that it was trying with local URL, while it should have been external one. Hope those could be hints.

All the permissions for background execution are set and battery optimization for the app is disabled as with previous version it was working pretty good.

Traceback (if applicable, to get the logs you may refer to: https://companion.home-assistant.io/docs/troubleshooting/faqs/#android-crash-logs): homeassistant_companion_log_4-31-2021_13-22-41.txt

Screenshot of problem:

Additional information:

dshokouhi commented 3 years ago

The error is failed to connect to your HA instance. Seems to be an internal networking issue. You try restarting modem or anything yet?

dshokouhi commented 3 years ago

One other thing that I see here is that it might be a connection issue. It seems your device had sent 3 different wifi state change updates all pretty quickly after one another just before the error. Its possible the call just failed to update because you had no network connection so it was queued up to send on the next update which happened to be when you opened the app to speed it up. There really isn't much we can do in that sense, have you tried checking to see if your device keeps an active connection so when your device comes on or off wifi it still has a connection to send an update? Might find that setting under developer options. The app keeps track of the last state successfully sent to HA so that part seems to be working as intended.

energywave commented 3 years ago

Thank you for your feedback @dshokouhi , it was a temporary time in wich the app didn't update properly Home Assistant instance. My phone was completely ok as I've used it as usual, I even used the app to access my Home Assistant from outside home without problems. If it's useful I'm using Nabu Casa. After that period the update of sensors began to work again, without any intervention from me. My phone had connection with wifi, then could not communicate while going away from the office until wifi went down, then again connection from the mobile carrier. This is usual and normal. I can confirm that Home Assistant was working from mobile carrier as I've used normally Whatsapp and other internet services. I don't know what happened but it was some days long. I'm sharing just to let you know, in case that could be useful for your wonderful app :) It's some days that my automation about my exit from the office is working good, every time at the same point driving my car, I suppose for wifi disconnection that triggers the zone change.

dshokouhi commented 3 years ago

It sounds like things are working as designed. If the app is unable to send an update, it will get sent in the next update when it comes to sensors and from what you describe thats what happened. When it comes to things like location and zone events those will not get sent again as we rely on Google for that live data so they come as needed.

energywave commented 3 years ago

I'm not sure about that. Every day I arrive at some point down the road I go from my office and the automation about my office exit is triggered. Not in those days. The wifi SSID disconnection event was not sent at all, I've discovered that in those days even the home status was not set, I was always not_home. There was something strange like the app was not able to communicate with my instance (but the UI was working so everything was fine). Maybe callbacks didn't work? If that isn't useful to you just close the issue and don't loose your precious time. If it will happen I'll open ASAP an issue so that maybe we can do some test and send some valuable info that now I can't have anymore. Thank you for your time.

dshokouhi commented 3 years ago

So the HA frontend uses the authenticated webview to login and display HA. The app itself when it comes to sensor and location updates uses webhooks. When it comes to firing an event or getting entity/service data we use the REST API. The only implementation the app does not support yet is websockets. We would need to see the logs for when the app is unable to communicate but if the error shows failed to connect the entire time then I am not sure what we can do in those cases. One other thing you can look at is the debug logs from HA for the mobile_app integration. Every thing sent from the app to HA shows up under those debug logs so that might help troubleshooting. Lets keep this open for a bit since it seems like you may hit it again due to the frequency you describe.

dshokouhi commented 2 years ago

Closing as we havent heard back yet.