question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minimal version persistent notification with 'Always' enabled, causes SEVERE battery drain

See original GitHub issue

Home Assistant Android version: 2022.9.1-minimal (also happened on 2022.8.0-minimal)

Android version: 10

Phone model: Oneplus 6T

Home Assistant version: 2022.8.7

Last working Home Assistant release (if known):

Description of problem:

Whenever i set the persistent connection to Always, after hours of leaving it that way, my battery would have drained significantly. If i set it back to Never, all is back to normal again. Ive been wanting to report this right from the beginning when this feature for notifications on the minimal app became available, however ive been trying to find the most optimal settings to be able to use this feature without it draining my battery but unfortunately its still draining.

I have other apps, such as Linphone or Syncthing, that also have a persistent notification and do the same thing to keep the connections alive and would run also for the same amount of hrs as this minimal version, but the right side (percentage) in the screenshots is what counts as draining battery, their percentage is close to 0% or up to 1% but Home-Assistant Companion would show 6% or 9% as you can see below(even though its not open or actively used), meaning something is wrong. Maybe it would help to look at the code for Linphone’s or Syncthing’s persistent notification? Would really appreciate a fix for this as i really want to use the notification’s feature for this minimal version without it affecting battery life.

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


Screenshot of problem: Screenshot_20220928-1 Screenshot_20220929-1

Additional information:

Please note, i have completely disabled updating sensors as part of my attempt to find the optimal settings for this. So updating sensors is not at fault. As i have had sensors update before enabling persistent notification and never had this battery drain from the minimal version before.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jpelgromcommented, Sep 30, 2022

I don’t have anything specific in mind, it was just a general remark as I can’t imagine the app being perfect.

1reaction
jpelgromcommented, Sep 29, 2022

There’s probably room for improvement with regards to battery usage, but unfortunately it isn’t as easy as “look at the code for [other app]”. They probably have very different architectures and complex backends that make it hard to compare. While they might show a persistent notification the behavior can be very different. If you can provide a more specific pointer that is always welcome ☺️

So if i force “Optimize Battery” to be enabled, its fine, however then i get an error from the app saying that it needs access to the background, otherwise it kills the app after a while. This should be optional to the user, not forced to have both Background Access AND Persistent Connection. Or at least why should it disable “Optimize Battery”?

FYI while the app strongly recommends disabling battery optimizations when using the persistent connection it won’t actually block it from working, it will always try and only stops if it receives an exception while trying to open the connection as a foreground service. So if you’re getting the notification saying this, the app tried to (re)start the persistent connection in the background but was unable to do so because of an exception (limitation). More technical info here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[APP][2.2+][11 Dec. 2022 - V3.1] BetterBatteryStats | Page 1929
I'm allowed to swipe away the persistent notification? ... In app settings of better battery stats need to choose fallback option.
Read more >
Battery Drain with face unlock - OnePlus Community
When face unlock is enabled, the phone uses an extreme amount of battery, the device only gets about 4 hours SOT with face...
Read more >
Android 13 will alert you when an app is draining your phone's ...
The upcoming version of the OS will display a notification whenever an app drains excessive battery within 24 hours (via 9to5Google), ...
Read more >
Why is my phone's battery draining so fast? - Android Authority
Wondering what's killing your smartphone's battery life? Let's fix that! These are the four reasons why your battery is draining so fast.
Read more >
What's your iOS 16 Battery Drain Story? : r/apple - Reddit
Go to the battery page in settings on both phones, compare apps usage in background. Im guessing you have something she doesnt that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found