I’m close to having my automation figured out for sending notifications when a battery is getting low on a device. The one thing I am unable to figure out is how to get the battery_level to get passed into the data_template. The friendly_name is available, so some attributes are there but for some reason this one is not.
Here is the automation:
- id: low_battery_notification
alias: low battery notification
trigger:
platform: numeric_state
entity_id:
- sensor.battery_back_bedroom_motion_sensor
- sensor.battery_entry_motion_sensor
- sensor.battery_doorbell
- sensor.battery_front_bedroom_motion_sensor
- sensor.battery_front_door
- sensor.battery_garage_entry_door
- sensor.battery_garage_motion_sensor
- sensor.battery_kitchen_door
- sensor.battery_nursery_motion_sensor
- sensor.battery_rooftop_door
- sensor.battery_rooftop_motion_sensor
- sensor.battery_thermostat
- sensor.battery_deadbolt
- sensor.battery_garage_deadbolt
below: 51
condition: []
action:
service: notify.dave_sms
data_template:
title: "Low battery notification"
message: "{{ trigger.to_state.attributes.friendly_name }} is at {{ trigger.to_state.attributes.battery_level | default(0) }}%"
The notification I receive says “doorbell battery is at 0%” (when I set the value to 49 or 50).