android: App closed, phone sensors are not updating
Home Assistant Android version: 2.3.0-306-full
Android version: 10.0.7
Phone model: OnePlus 7pro
Home Assistant version: 0.114.3
Last working Home Assistant release (if known): Unknown
Description of problem: When I close the HA companion app on my phone, non of the app related sensors are updating in HA.
Traceback (if applicable):
Screenshot of problem:
Additional information:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (10 by maintainers)
Fortunately on my devices closing the app (or removing from recent apps) is not the same as Force Stop, so the periodic work continues to run. I’ll test your PR tonight to check if it makes any differences. I wonder if it will bypass the doze mode on Android 9+ or not.
May be a service with a permanent foreground notification could help?
Or abuse alarms as other applications do? 😉
As I already said in the comments to the location tracking issue, this seems to be Android 9+ specific behavior.
If the phone is left intact and enters the doze mode, sensors update may be delayed by up to 2 hours even if the app is running in the background.
You still don’t want to create a service with notification? ^_^ However I’m not sure that it will help.
Currently I’m sending location tracking request intent from Tasker to the Home Assistant app every 5 minutes as a workaround. This doesn’t let the phone enter doze mode and another sensors are getting updated too as a side effect. But ideally I want to get rid of Tasker, because it is a crutch and also draining the battery a bit fast (2% per hour in idle mode).