Home Assistant for iOS v2021.7 background battery use

I’m slightly obsessed about my iPhone’s battery life, and try to minimize background activity so that I only have to charge it every other day. For the past couple weeks, I’ve been noticing that Home Assistant has background utilization of at least 7 minutes per hour, up to 18-20 minutes, where before I don’t recall seeing any. I tried deleting the app and re-installing, which fixed the issue for a day or so, but the background utilization has come back. Restarting the phone, today, didn’t help, I didn’t launch the app after starting. After deletion, battery use was back to normal, with almost no background tasks.

Home Assistant app v2021.7
iOS 14.6 ( updated today to 14.7.1 )
Background App Refresh disabled for all apps.
Disabled specifically for the app: Location, Background App Refresh, and Cellular Data.

1 Like

Disabling Local Push may help in the internal connection settings, but in my testing it uses very little battery. Other than that, the only things which can launch the app in the background you have disabled, so if that doesn’t help we can take a look at your logs to see what is running. Followup here and I can give you instructions as it is going to contain a lot of personal data and you should not post it publicly.

I put it back on yesterday evening and looked through the settings again, disabling everything I could, but it’s still making background activity. Looking at the logs, the push provider extension pings once a minute. The only thing I found with “Local Push” is under the App Configuration / Notifications / Debug section where it says “Available (0)”.

Let me know which logs to collect, thanks.

The local push setting looks like the screenshot below. You can find it in App Configuration under the first row, your server settings, then under Internal URL.

Turn off “Local Push” and it’ll stop running in the background.

I understand you wish to closely manage your battery usage and I want you to feel empowered to control it, but since others may stumble across this post unsure about what’s happening, I am going to soliloquize a bit about what’s going on. tl;dr: the way it’s reported makes it look long in ‘activity’ but it should be low in ‘usage’.

Pinging roughly every minute is the system-suggested schedule for Local Push connections, and the app does it using a method which allows the system to optimize the exact timing. I believe the system rounds up this usage to a full minute, hence the large ‘activity’ time, so keep in mind that it’s not actually burning through battery that entire duration. For example, in your screenshot, the Home Assistant app running for ‘5.5 hours’ consumed less battery than Brave running for 5 minutes. This isn’t too surprising because using the display actively is probably the largest possible battery cost on the device. This is the expected experience of reported usage from testers and myself during the beta period, and has held strong through release.

Battery usage is one of my primary concerns for the app’s various features. For example, app sacrifices some hyper-exact location accuracy in favor of focusing on in-or-out-of-Zone status, which drastically reduces battery usage for background location. Local Push is taking some new amount of battery (hence why there’s an option for it), but it’s also absorbing some existing battery cost for some kinds of notifications which require downloading images, videos, etc.

I believe it’s worth the net-new battery cost (as a default) because of the speed of notifications, reduction in rate limiting, and in general the Home Assistant philosophy around local control - we should aim to get things to you phone without going through servers on the internet.

2 Likes

Understood, thanks for the explanation. I disabled “Local Push” on the connection and feel like it’s using less battery, although it still shows up with some background utilization.

A few days later it has no background utilization. I don’t know why, I’m not using the app any different from before.

I’m getting high battery utilization as well. It’s really usage, not only time, so it’s around 10% on average.

I looked at the logs, and actually it’s trying to do something with the websockets several times per minute and gets an error:

2022-04-07 13:25:33.284 [Info] [main] [Environment.swift:71] init() > WebSocket: connecting using HAConnectionInfo(url: http://myexternalurl, userAgent: Optional("Home Assistant/2022.3 (io.robbie.HomeAssistant; build:2022.358; iOS 15.3.1)"), engine: nil)
2022-04-07 13:25:33.339 [Error] [main] [Environment.swift:72] init() > WebSocket: Error: Optional(POSIXErrorCode: Connection refused)
2022-04-07 13:25:33.340 [Info] [main] [Environment.swift:71] init() > WebSocket: phase transition to disconnected(error: Optional(POSIXErrorCode: Connection refused), forReset: false)
2022-04-07 13:25:33.340 [Info] [main] [Environment.swift:71] init() > WebSocket: disconnecting; permanently: false, error: Optional(POSIXErrorCode: Connection refused)
2022-04-07 13:25:33.340 [Info] [main] [Environment.swift:71] init() > WebSocket: phase transition to disconnected(error: nil, forReset: true)

I replaced the url. The interesting thing is it’s using the external url all the time even though I’m home. This is strange because the app normally knows which url to use when it’s open (the external one doesn’t work from inside my network)…

Any ideas?

So I have disabled local push and this has removed HA background activity. Battery life is now much better.
I’m still wondering what happened. Why is the websocket trying to access the external URL when the app is clearly connected using the internal one? Local push was shown as “deactivated” in the app, while websocket was shown as “connected”. But only when I turned off local push, background activity stopped…

1 Like