Low Battery and Unavailable Device Notification Blueprint

Hi everyone, I have been searching for awhile to find an easy to install and easy to use notification service that would tell me when my devices get low on battery AS WELL AS when they go unavailable, probably due to a dead battery, some devices even though they will show like 40% battery could very well die the next day.

So this is my attempt at combining a few bits of code from others on Github.

Here is the link to the Blueprint, this is my first attempt at this so not sure how to create a cool import link like others :wink:

low-battery-and-unavailable-check.yaml

Let me know what you think if you try it out.

Last but not least… HA, get with the program. This should be built in functionality from DAY ONE!!!

8 Likes

Insane, omw home and figured I’d check if there’s a blueprint that would improve on my already implemented “availability monitor” and here you are, creating one no more than five hours ago :smiley:
Thank you, I will try this out :slight_smile:

1 Like

Incredible, this is what I was looking for!
It allows me to have the battery level of my door open sensors, motion detector ?

It will report battery levels if it finds they are lower then your threshold… if its unavailable obviously no battery level will be reported :wink:

Also I just made an update, I removed the entity selection for battery only devices. I had a outlet/switch I only use during Christmas time unplugged so it kept saying unavailable obviously. Now you can select any entity to exclude, not just devices with a battery type. Check the github for the latest update.

Thank you for the nice Blueprint

Does this go out and find all sensors with batteries or do I have to input them? Thanks.

This looks promising!

How would you set up actions for this?
Ideally I’d only want to e.g. receive a mobile notification once one of the sensors drops below the threshhold or becomes unavailable. I only managed to set up a “generic” notification where the {{sensors}} is empty if none are low/missing.

It will find them all yes, then you can exclude any as needed

I create an automation using the blueprint then in the Actions section at the bottom of the automation I just have it email me once a day if it finds any. Works well for me :slight_smile:

I do this by using the following:

    actions:
      - service: notify.mobile_app_imac
        data:
          title: Low Battery
          message: "{{ sensors }}"
      - service: notify.mobile_app_andys_iphone
        data:
          title: Low Battery
          message: "{{ sensors }}"

I get:

1 Like

Hey fellow coders.
I am using this blueprint as well.
But I also have Battery Notes Integration installed. This integration knows which battery types I have in which device.
My goal was to not only get a notification of which device needs a battery replacement, but also what batteries I need to purchase and how many.

For this to work, I have changed one line in the blueprint:
low_battery_notification.yaml
line 95:


sensors: "{% set result = namespace(sensors=[]) %}{% set batteries = namespace(battery=[]) %}{% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}{% if 0 <= state.state | int(-1) < threshold | int and not state.entity_id in exclude.entity_id %}{% for object in states.sensor %}{% if object.attributes.friendly_name == (state.name + ' type')  %}{% set result.sensors = result.sensors + [state.name ~ ' (' ~ object.state ~ ' -> ' ~ state.state ~ ' %)'] %}{% set batteries.battery = batteries.battery + [object.state] %}{% endif %}{% endfor %}{% endif %}{% endfor %}{{result.sensors|join(', ')}}"

Thought I want to share this.
What I also still want to create is an automation that adds the required battery to my Home Assistant Shopping list, but only if it is not already on the list (to avoid filling up the shopping list until I actually have purchased the specific battery).

Happy coding

3 Likes

I use this in an automation and send the notification to my phone. It runs daily. Does anyone know what I should put in my automation to have it not notify me if there are not any sensors with low batteries?

Currently I get the notification with the title (the following devices are at or below 20% battery levels:) and of course there is no data. It does work properly when a battery is low but I don’t want notified if there are not any low batteries.

Thanks in advance.

1 Like