Battery level changed
The Battery level changed trigger fires after a battery level reading changes. Battery levels drain gradually as devices are used, recharge when plugged in, or spike briefly when sensors report a fresh reading. Use the threshold type to filter which changes matter to your automation.
The threshold type controls where the new reading must land for the trigger to fire. You can require the new value to be above a level, below a level, within a range, or outside a range. You can also select Any change to fire on any change at all.
Use Battery level changed to get notified when a device starts running low, log battery drain over time, or trigger a reminder to swap out the batteries in a frequently used sensor.
Requires the Purpose-specific triggers and conditions Labs preview feature. Enable it at Settings > System > Labs.
Using this trigger from the user interface
If you prefer building automations visually, Home Assistant walks you through this trigger step by step. You pick what to watch, tweak a few options, and save. No YAML knowledge required.
To use Battery level changed in an automation:
- Go to Settings > Automations & scenes.
- Open an existing automation, or select Create automation > Create new automation.
- In the When section, select Add trigger.
- Select what you want to monitor. Under By target (see Targets), pick the area your battery-powered device is in (like your hallway or garden). You can also select a device, a specific entity, or a label. When you target multiple entities (via area, label, or multiple entity selections), the trigger fires whenever any of them changes.
- From the triggers shown for that target, select Battery level changed.
- Under Threshold type, configure what kind of change fires the trigger:
- Select Any change to fire on any change, regardless of direction or new value.
- Select Above or Below and enter a value to fire only when the new reading is above or below that value.
- Select In range and enter a lower and upper bound to fire only when the new reading falls inside the range.
- Select Outside range and enter a lower and upper bound to fire only when the new reading is outside the range.
- For each option, you can enter a fixed percentage (0–100%), pick a sensor entity, or a number helper entity as the threshold.
- If you don’t have a number helper, you can create one by selecting Create a new number helper.
- Select Save.
Options in the UI
Controls which changes fire the trigger:
- Any change: fires on any change, regardless of direction or new value.
- Above or Below (exclusive): fires only when the new reading is strictly above or below the threshold. A reading equal to the threshold does not fire the trigger.
- In range (exclusive): fires only when the new reading is strictly between the two bounds. A reading equal to either bound does not fire the trigger.
- Outside range (inclusive): fires when the new reading is at or below the lower bound, or at or above the upper bound. A reading equal to either bound fires the trigger.
For each mode you can enter a fixed percentage (0–100%), reference a sensor entity, or a number helper entity.
Using this trigger in YAML
If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.
In YAML, Battery level changed is referred to as battery.level_changed. A basic example looks like this:
trigger: battery.level_changed
target:
entity_id: sensor.front_door_sensor_battery
options:
threshold:
type: below
value:
number: 20
This fires whenever the front door sensor battery drops below 20%.
To fire only when the new reading falls within a healthy charge range after a recharge:
trigger: battery.level_changed
target:
entity_id:
- sensor.front_door_sensor_battery
- sensor.garden_camera_battery
options:
threshold:
type: between
value_min:
number: 79
value_max:
number: 100
This fires whenever either device charges back to 80% or above (up to, but not including, 100%).
To use a number helper as a dynamic threshold you can adjust without editing the automation:
trigger: battery.level_changed
target:
entity_id: sensor.front_door_sensor_battery
options:
threshold:
type: below
value:
entity: input_number.low_battery_alert_threshold
Options in YAML
YAML sometimes provides additional options for more complex use cases that are not available through the UI.
A mapping that defines which kind of change fires the trigger:
-
type: any: Fires on any change (no additional keys needed). -
type: aboveortype: below(exclusive): fires when the reading is strictly above or belowvalue. A reading equal tovaluedoes not fire the trigger. Providevaluewith anumberkey (for a literal percentage) or anentitykey (for aninput_number,number, orsensorentity). -
type: between(exclusive): fires when the reading is strictly betweenvalue_minandvalue_max. Readings equal to either bound do not fire the trigger. -
type: outside(inclusive): fires when the reading is at or belowvalue_min, or at or abovevalue_max. Readings equal to either bound fire the trigger.
For type: between and type: outside, provide value_min and value_max, each with a number key (for a literal percentage) or an entity key (for an input_number, number, or sensor entity).
Targets of the trigger
This trigger requires a target. The target is the object that Home Assistant will watch. You can select a single entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more], a device, an area, a floor, or a label as a target, and Home Assistant will watch every matching battery entity behind that target.
-
Entity: one specific battery entity, such as
battery.living_room. - Device: every battery entity that belongs to a device.
- Area: every battery entity in a room or area.
- Floor: every battery entity on a floor.
- Label: every battery entity that shares a label.
You can also select different target types in one trigger. For example, you can add a specific entity and an area as targets in the same trigger to monitor both of them at once.
Good to know
- The threshold type controls both the direction and the landing zone of the change. Use Above or Below to filter by direction, In range to fire only when the new value is inside a range, and Outside range to fire only when it escapes a range.
- Use Any change to fire on every reading update regardless of direction or where the new value lands.
- To react only when a battery level first crosses a specific value, use Battery level crossed threshold instead.
- Pair this trigger with the Battery level condition to verify the reading meets a threshold before continuing the automation.
- The trigger works with sensors that have the battery device class.
Try it yourself
Ready to test this? Go to Settings > Automations & scenes, create a new automation, and add this trigger. Save the automation, then change the state of the targeted entity to watch the trigger fire on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].
More examples
Real scenarios where this trigger fires in automations and scripts. Copy any example and adapt it to your setup.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.
Automation: notify when a door sensor battery is running low
Door sensors sit in corners and rarely get attention until they stop responding. This automation sends a notification whenever the front door sensor battery drops below 25%, so you can replace it before it fails.
-
Trigger: Battery level changed
- Target: Front door sensor battery entity
- Threshold type: Below 25%
-
Action: Send a notification message
-
Target: My Device (
notify.my_device)
-
Target: My Device (
YAML example for a low battery notification
alias: "Notify when front door sensor battery is low"
triggers:
- trigger: battery.level_changed
target:
entity_id: sensor.front_door_sensor_battery
options:
threshold:
type: below
value:
number: 25
actions:
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: "Front door sensor battery is below 25%. Time to replace it."