I have recently bought a Samsung galaxy s23+ and have been setting it up. I have automations that rely on when I plug in and unplug my phone. I have noticed that when plugging in or unplugging it, the automations wont trigger. Is there a way to fix this? I have already gave it access to basically everything on the permissions side and I have set the battery optimization to unrestricted for the app. Even with all of this, it is still doing the same thing.
#App Keeps Getting Killed in Background
1 messages · Page 1 of 1 (latest)
Hello @icy locust,
You are going to have to share some code if you are going to get any help.
To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.
For what in particular? The problem is with the app going to sleep, not the automation itself.
I will share whatever, I just need to know what specifically.
Share part of one of them so we can see the trigger part.
The automation is to long to send as a normal message with ought nitro so the full automation is just in the text file.
So for that to trigger, that sensor has to change from something else to discharging. If it's already in the discharging state, it won't trigger.
No, it needs to be any other state, then switch to discharging. It dosn't trigger if it was already discharging
We said the same thing
Yes, sorry, I just reread your message a few times until I understood what you meant. I was reading "it wold trigger", not "it won't trigger" for some reason
OK.
So you are saying if it's charging, and you remove the charger, that does not trigger? Check developer - state to see if the sensor actually changes.
It dose trigger, but I need to manually open the home assistant app before unplugging it every morning for it to work. If I just unplug it before opening the app, it wont trigger.
I am pretty sure my phone is killing the home assistant process in the background over night
Just so you can see that it dose update the sensors.
Home Assistant is not running on your phone.
Is the App completely turned off? In order to send the state change the HA app has to always be running. It doesn't have to be open, but it has to be running.
I think that is my problem. The app stops running overnight for some reason. I know the app needs to be running but every morning it just isn't. That's why I open the app every morning, just to get the HA service running again.
Battery saver sometimes turns it off, other things. You have to look at the phone settings to make sure it is always on.
I have it set to unrestricted already. There is a setting for commonly closed apps in the phone but the HA app isn't an option. I don't know what else to try. Some people have said disabling battery optimization all together might fix it but it would kill the battery a lot faster, and it should essentially do the same thing as setting the HA app to unrestricted, just for the whole phone.
Is it intermittent? I have been having issues with my google pixel not reporting home anymore, but when I open the app it'll refresh. Seems to be a newish issue.
do not use battery optimization.. And prevent COMP APP on phone from going to sleep
FWIW, it's not the solution but I bumped up "RAM Plus" to 8 GB on my Samsung phone a few years ago and nearly eliminated this problem, @icy locust . Likely just due to how many apps in general are on the phone and HA being the most convenient one for it to kill to free up RAM.
Settings > Device Care > Memory > RAM Plus
I have tried this as well with the same results as before. I still have it turned on just because I don't need the storage but it didn't noticeably change anything.
Then you likely either have a very large number/size of background apps or one of the power saving features was missed for the HA app. You could use adb to confirm that... mine always said swap was low and HA was the victim