Battery Level Persistent Notification Help

I am trying to create an automation that will fire a Persistent Notification when our phones or my watch drop below 20% battery level remaining. I have created the following but it doesn’t work. Any help would be appreciated.

  - alias: 'Battery Warnings'
    initial_state: 'on'
      platform: numeric_state
        - sensor.ring_front_door_battery
        - sensor.wear_pixel_xl_ariela_battery_sensor
        - sensor.pixel_xl_ariela_battery_sensor
        - sensor.iphone_battery_level
        - sensor.emmys_galaxys7
        - sensor.lolas_lgstylo3plus
      below: 20
      - service: persistent_notification.create
          message: >
            {{ state_attr(, 'friendly_name') }} is below 20%
    initial_state: true

Also, try this if the message is not formatting correctly.

          message: >
            {{trigger.to_state.attributes.friendly_name}} is below 20%

I’m not getting any kind of notification from the automation and the “switch” was showing “on” for it.


The automation may be on but initial state was still configured incorrectly.

You battery levels have to drop below 20 to trigger. If they are already below 20 the automation won’t trigger.

I let my watch drop below the threshold but no automation when it hit 19

Weird. I have a very similar automation that works as intended:

- id: fridge_compressor_alert
  alias: 'Fridge Compressor Alert'
  initial_state: true
    platform: numeric_state
      - sensor.bar_fridge_power
      - sensor.fridge_power
    below: 50
      hours: 2
  - service: notify.telegram_system
      title: '*ALERT*'
      message: "The {{trigger.to_state.attributes.friendly_name}} compressor has not turned on in the last 2 hours."
  - service: persistent_notification.create
      message: "{{ now().strftime('%H:%M %A %d %B %Y') }} - The {{trigger.to_state.attributes.friendly_name}} compressor has not turned on in the last 2 hours."
      title: "ALERT"

Have a look in the dev tools states menu. Are the battery levels actually numbers?

Or are they strings like, ‘30%’

Numbers, no % signs or anything else. I’ll play with it some more.

Do you get the notification if you trigger the automation from the developer tools services menu (service = automation trigger or something like that)?

I believe it may be working now. I may a few changes to make it more like yours and when I rebooted I had a notification that the only device currently below 20% was below 20%. We’ll see what happens when one of the others moves below 20.

1 Like

That statement is not correct.

‘on’ is a valid option for “initial_state:”. I use it exclusively.