Keeping critical devices charged is easy to forget—until they die at the worst moment. The automation below performs a daily scan of every sensor whose entity ID contains “battery” (English) or “batterie” (German). If any are below 10 %, it instantly pushes a notification to every registered mobile-app device, shows a persistent alert in the UI, and fires the general notify.notify
service so you’ll never miss the warning.
Key features
- Scheduled check (08:00) – runs once each morning.
- Automatic device discovery – no hard-coding of entity IDs.
- Multi-channel alerts – mobile push + standard notify + persistent UI banner.
- Compact battery list – shows only the devices that actually need charging.
Below is the complete YAML. Paste it into Settings → Automations & Scenes → ⋯ → Edit in YAML and save.
alias: Notify Low Battery Levels
description: >
Daily check for low battery levels and send notification to all mobile devices
and UI
triggers:
- at: "08:00:00"
trigger: time
conditions: []
actions:
- variables:
low_batteries: |
{% set low = namespace(batteries=[]) %}
{% for entity in states.sensor
if ('battery' in entity.entity_id or 'batterie' in entity.entity_id)
and entity.state not in ['unknown', 'unavailable']
and entity.state | float(default=100) < 10 %}
{% set low.batteries = low.batteries + [entity.name ~ ": " ~ entity.state ~ "%"] %}
{% endfor %}
{{ low.batteries }}
- choose:
- conditions:
- condition: template
value_template: "{{ low_batteries | length > 0 }}"
sequence:
- data:
message: |
Low battery detected:
{{ '\n' + low_batteries | join('\n') }}
action: notify.notify
- repeat:
for_each: >
{{ states.notify
| selectattr('entity_id', 'search', 'notify.mobile_app_')
| map(attribute='entity_id') | list }}
sequence:
- data:
title: Low Battery Warning
message: >
The following devices have low battery:
{{ '\n' + low_batteries | join('\n') }}
action: "{{ repeat.item }}"
- data:
title: Low Battery Warning
message: >
The following devices have low battery:
{{ '\n' + low_batteries | join('\n') }}
action: persistent_notification.create
mode: single
YAMLHow It Works
- Variable build – Jinja loops through all
sensor.*
entities, filtering out unknown or unavailable states and taking any battery below 10 %. The result is a list like[“Door Sensor: 8%”, “iPad (Office): 5%”]
. - Conditional branch – If the list is non-empty, the automation continues; otherwise it exits silently.
- Global notify – Sends one consolidated message to the default
notify.notify
group (great for e-mail, Telegram, etc.). - Per-device push – Iterates over every
notify.mobile_app_*
entity so each phone or tablet gets a native push with its own title and body. - Persistent UI alert – Adds an on-screen banner that stays until dismissed—handy if your phone is muted.
Customizing Thresholds & Schedule
Change the cutoff – Replace < 10
with your own percentage (e.g. < 20
).
Scan more often – Add extra time triggers or replace the single at:
with an hourly
pattern.
Exclude devices – Add a condition inside the Jinja loop such as and not entity.entity_id.startswith('sensor.unreliable_')
.
Troubleshooting
- No notifications? – Make sure your mobile apps are registered and their
notify.mobile_app_*
services exist. - Too many alerts? – Increase the threshold or switch to an every-other-day schedule.
- Entity IDs in German? – The loop already matches both “battery” and “batterie”.