Sensors
Which sensor battery dies next? A 5-minute trick
How I track the battery drain of about 25 sensors in Home Assistant, what it caught (some leak sensors that drained very fast), and a step-by-step guide to doing it yourself.
A smart home is only as reliable as its batteries. Around 80 things in my house report a battery level, from phones and tablets to sensors, blinds and curtains. When one of them quietly dies, something stops working, and you usually find out at the worst moment. A blind that won’t move or a sensor that has gone silent is a small problem, but it’s annoying. A smoke alarm or a leak sensor with a flat battery is a much bigger one.
So I decided to be proactive. I wanted to know which battery would die next, long before it did.
Want to do it yourself? Skip straight to how to set it up.
Why one battery number isn’t enough
Every battery sensor reports a percentage. But a single percentage doesn’t tell you much. A sensor at 40% that loses 1% a month is fine for years. One at 70% that loses 10% a month will be flat by summer.
What you really want is how fast each battery is draining. Home Assistant can work that out for you, using a built-in tool called a Statistics helper.
The trick in one sentence
For each battery, ask Home Assistant: “how much has this changed over the last 30 days?” A result of -4 means the battery lost 4 percentage points in a month.
Put the current level next to that number and you can see at a glance which batteries need attention first. A rough rule: divide the battery level by the monthly loss to get the months left. A sensor at 60% losing 5 points a month has about a year to go.
What it has caught so far
I bought some IKEA leak sensors that run on AAA batteries. In my house they drained extremely fast. I could see it in the numbers quickly, and I replaced them with Sonoff sensors, which last much longer. Your results may differ, but without the numbers I’d have been changing batteries in sensors I wasn’t even watching.
I’m tracking about 25 devices this way, a mix of Aqara and Sonoff. They include smoke detectors, temperature and humidity sensors, a water sensor, a motion sensor and several curtain motors. I set the helpers up only a short while ago, so when I wrote this most of them hadn’t yet filled a full 30 days. The picture gets more reliable every day.
My motorised blinds have their own simple alert: they run on rechargeable batteries, and I get a phone notification when one drops below 15%. There’s one for a wall remote too. You’ll find that alert, with my details removed, further down.
How to set it up yourself
Each helper takes a few minutes and needs no code, because you set it up entirely in Home Assistant’s settings. The alert at the end is optional.
What you need
- A working Home Assistant with at least one battery-powered device. Check that the device shows a Battery entity.
- A phone with the Home Assistant app, if you also want alerts.
Start a Statistics helper
Go to Settings, then Devices & services, then the Helpers tab, press Create helper, and choose Statistics. You’ll find it under “Calculations”. Give it a clear name, such as “Smoke detector battery drain 30d”, and pick the device’s Battery entity.
Be careful when picking the entity: search results can show both the real battery sensor and any helper you made earlier. You want the one simply called Battery.

The first two screens. Choose the sensor’s Battery entity (I’ve left it blank here), then set the statistic to Change.
Choose “Change”
On the next screen, set Statistic characteristic to Change. It’s in the list, a few items down. This gives you the difference between the oldest and newest battery reading in the time window, which is exactly the number of points the battery has lost.
Set the window to 30 days
On the last screen, set Max age to 720 hours, which is 30 days. Leave Sampling size empty and Keep last sample switched off, then press Submit.

The final screen. 720 hours is 30 days.
Repeat for every battery
Do the same for each device you care about. Creating a couple dozen by hand is slow, so I had a lot of help from Claude and OpenCode with the repetitive part. I came up with the idea, and they did the typing.
Read the numbers
Give it time. A new helper has little to go on, and each day it becomes more accurate.
- A negative number is the battery losing charge. The bigger the number, the faster the drain.
- A positive number means the battery went up, which usually means you replaced or recharged it.
- “Unknown” means the device hasn’t reported a battery level within the 30 days, or the helper is brand new.
To see how much of the 30 days a helper has covered, open Developer tools, then States, find the helper, and look at its age_coverage_ratio attribute. A value of 1.0 means a full 30 days.
Get a warning before it dies
Numbers are useful, but an alert is better. This automation sends a notification when a battery drops below 15%. It fires once, when the level crosses the line, and each device has its own tag so a repeat for the same device replaces the old message instead of piling up.
This is my version with the details removed:
alias: Battery low alert
triggers:
- trigger: numeric_state
entity_id:
- sensor.blind_1_battery
- sensor.blind_2_battery
- sensor.remote_battery
below: 15
actions:
- variables:
device: "{{ state_attr(trigger.entity_id, 'friendly_name') | replace(' Battery', '') }}"
level: "{{ trigger.to_state.state | int(0) }}"
- action: notify.mobile_app_your_phone
data:
title: "Battery low"
message: "{{ device }} battery is at {{ level }}%."
data:
tag: "battery-low-{{ trigger.entity_id | replace('.', '-') }}"
importance: high
mode: queued
Swap in your own battery entities and your own phone’s notify service. I use a small script of my own that notifies both our phones, so yours will look slightly different.
See every battery in one place (optional)
The numbers are most useful on a dashboard, so I made a Batteries tab. Each device gets a card with its battery level and, once the battery has been tracked for a few days and has started to drop, an estimate of when to replace it. Here’s part of mine, with the names replaced:

Part of my Batteries tab. The green dates are batteries with plenty of life left. A card turns amber when one has less than two weeks to go, and red when it needs replacing now.
It’s built with a popular community card called button-card, which you install through HACS. Every card points at a battery sensor and its 30-day helper. The card looks at how much the battery has lost over the days it has been tracked, then estimates when it will reach 10%. Until a battery starts dropping, the card just says “Gathering data” and how many days it has been watching. Phones, tablets and my rechargeable blinds show their charging status instead.
This is more setup than the rest of this guide, so treat it as a bonus. A plain Entities card showing each battery level next to its helper gets you most of the way there.
If something goes wrong
- The helper shows 0 or “unknown”. It’s probably new. Check its age_coverage_ratio and give it more time.
- A big positive number. That’s a replaced or recharged battery, not a fault.
- “Unknown” for a long time. The device may not be reporting its battery level often enough. Check the Battery entity’s history to see how often it updates.
- You picked the wrong entity. Delete the helper and make it again with the plain Battery entity.
That’s all there is to it. Start with the sensors you’d least like to lose, and let the numbers build up.