Help Troubleshooting Low Battery Alert Notification Automation

I tried creating a pretty “simple” automation that notifies me when the battery on my door locks is below 20%. I tested and it is sending an email, however I’m trying to include the specific door lock that triggered the alert (and therefore has the low battery) in the message, however it’s not including that device name in the email.

alias: Door Lock Low Battery Level Notification
description: Send an email when a door lock has a low battery below 20%.
trigger:
  - type: battery_level
    platform: device
    device_id: c7ee199eda59e1ab6e30bfd2758e584c
    entity_id: 0f111ab2e54d7e8513a11c1b2897b1d2
    domain: sensor
    below: 20
    id: lock_fd
  - type: battery_level
    platform: device
    device_id: a52759b6c9c6ade3a730cd1e9ce1e11f
    entity_id: 9f07fd2747b4a2a6bec872dccca5f278
    domain: sensor
    below: 20
    id: lock_igd
condition: []
action:
  - service: notify.<my email address>
    data:
      target: <my email address>
      title: Door Lock Low Battery Alert
      message: >
        Check door lock battery levels, one of the doors is has a low battery!
        {{ trigger.notification }} 
mode: single

I’m sure I’m missing some key code, but, this is my first time attempting this type of automation. I did create the above using the visual editor, which seemed like it would work to me.

Any advice on where I’ve gone wrong?

Thanks,

Where’d you get this? Far from an expert, but I haven’t ever seen that syntax before. Here’s what I have for my own low battery notification:

The {{ trigger.from_state.attributes.friendly_name }} is at {{ trigger.to_state.state }}% and needs to be replenished.

Thanks, let me play with your example tomorrow when I have some time.

As for what I did, I have the Google Mail integration installed and use it for my email notifications. I created the automation to notify me when the device has a battery level below 20% using the visual editor, then added the option for trigger id’s, followed by the {{ trigger.notification }} . I got this entry from the HA documentation but apparently I didn’t understand what I was doing.

I guess I was going by some sheer luck it would work. :grinning:

Presumably your doors aren’t the only devices with batteries, so may I suggest a more holistic approach to monitoring?

1 Like

This video was great, and led me to a nice set of code, thanks for the pointer!

1 Like