iOS Companion App approx 15 minutes of background activity per hour

I keep finding periods of faster than expected battery drain on both my iPhone and iPad. When I look at battery usage through the iOS settings app, it typically shows 14-18 minutes of background activity per hour for the Home Assistant iOS companion app.

This occurs even when I’m asleep and there is very little activity going on.

For the 24 hour view the iOS settings app says the companion app ran 5:33 in the background - so about 20-25% of the time, which fits with the 14-18 minutes I usually see looking at a specific hour.

When this happens it typically happens on both of my iOS devices.

There are however periods (days/weeks) that the background usage seems to much lower, or I don’t notice because I’m not checking to see where my battery went.

I haven’t figured out a pattern yet.

Force closing the companion app once doesn’t seem to do it. It seems like if I force close the app multiple times that might work. Also restarting Home Assistant especially if it has been running for a few weeks seems like it might help but I don’t have any real proof.

I don’t see much in the event log when this is occurring.

The one log file that shows regular activity is HomeAssistant-Extensions-PushProvider.txt. There is a
init() > WebSocket: Ping that happens somewhere around once a minute:

2022-03-31 05:00:35.977 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:01:45.937 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:02:42.152 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:03:38.442 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:04:43.218 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:05:39.663 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:06:36.276 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:07:33.439 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:08:50.193 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:09:47.382 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-03-31 05:10:43.889 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping

There is a init() > WebSocket: Sending: {"id":402,"type":"ping"} that occurs roughly every 3 minutes:

2022-03-31 05:00:49.601 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":389,"type":"ping"}
2022-03-31 05:03:46.930 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":390,"type":"ping"}
2022-03-31 05:06:35.974 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":391,"type":"ping"}
2022-03-31 05:07:54.212 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":392,"type":"ping"}
2022-03-31 05:11:03.484 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":393,"type":"ping"}
2022-03-31 05:15:00.346 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":394,"type":"ping"}
2022-03-31 05:18:15.645 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":395,"type":"ping"}
2022-03-31 05:21:50.228 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":396,"type":"ping"}
2022-03-31 05:23:53.265 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":397,"type":"ping"}
2022-03-31 05:26:58.720 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":398,"type":"ping"}
2022-03-31 05:30:46.575 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":399,"type":"ping"}

Is this normal activity, or something to be concerned about?

Both devices are on iOS 15.4, running the latest version of the iOS companion app. The app is connected to two servers running 2022.3.4. Both servers have been running for a few weeks since upgrading to 2022.3.4.

Note this is a pattern I’ve been observing for at least the last three months.

Any guidance on how to control this is appreciated.

This is normal for Local Push, to show this duration; it would not be normal for it also to burn through battery. You can disable it in App Configuration > (Your Server). I believe the usage number is a bit misleading, you can read more.

@zacwest - thank you for your reply and all the work you do on Home Assistanct.

The amount of time the app is running in the background seems to be somewhat modal to me. I’ve seen days where I don’t have that kind of usage.

If something on the order of 15 minutes per hour is expected due to local push, could that indicate local push isn’t working correctly?

I realize usage being a percent of the total is very dependent on what else is running. I do see periods when the usage allocated to the companion app doesn’t seem to be low to me. My phone this morning showed Home Assistant as the top consumer at 32%.

Yesterday morning was 25%

My iPad tends to show something more reasonable like 11%

I noticed something new on my iPad this morning, which I hesitate to mention because it is the first time I’ve seen it and is somewhat different from what I’m asking about above. Overnight the companion app was running constantly (showing about an hour usage per hour). It was plugged in overnight and didn’t manage to charge fully, though it was only on a 1amp charger. Usage in my phone was consistent with other days so only the iPad saw that problem.

Turning off Local Push should give some indication if that’s the core reason. It’s possible your Wi-Fi network and phone do not provide a good mix, but in general Wi-Fi + Local Push should be relatively innocuous amounts of usage. It’s hard to gauge from just the %'s there, especially with only like 30 minutes of screen time (which generally dominates battery usage); if you primarily used the HA app on the phone in those 30 minutes it would take the lion’s share of battery usage for that reason.

@zacwest - thanks. I will experiment with disabling local push. I should still get notifications from Home Assistant through the cloud right?

Also, sorry to ask again, but if something on the order of 15 minutes per hour of background activity is is the norm with local push, is not seeing that indicative that the background pings to keep the local push connection alive isn’t working correctly?

(Sure would be nice if Apple allowed us to get screen time, background activity, and battery usage all in one screen…)

So right now, 4-5 hours after I posted the screen shots this morning, the past 24 hour stats for the companion app on my phone is:

  • 22% battery (2nd highest app usage)
  • 1 minute on screen
  • 5h 38m background time.
  • 3 different SSIDs / BSSIDs in 24 hours (when viewed from Home Assistant recorder), with a total of 5 transitions between those 3 in 24 hours.

How did you guys sort this out?

Because I have a massive negative effect using (or NOT using) the iOS HA Companion app on my iDevices on battery life.

Details:

This issue isn’t fully solved and has started to rise on my list again.

Way back when I turned off push notification as was suggested at the time. I also wound up noticing misbehaving integrations like the builtin threshold sensor that was generating tons of unnecessary updates in the database. When I eliminated or clamped down on noisy integrations/sensors things got better for a long period of time.

I’ll also chime in on the other thread you highlighted, since it seems to have people talking about recent issues.

I suspect I need to dig into what causes the most updates in home assistant and how that relates to what it is sending to the companion app keeping it awake.

1 Like