Low battery level detection & notification for all battery sensors

this screenshot is not telling us anything of ‘not working’. What is your experience when running the automation?

Does the line break after each sensor work for you in the Telegram notification?

After last update of ha , it seems that it broke something, as i get notifications even tho the threshold is not passed?

I was able to add a condition {{ sensors != '' }} to check if the sensors was an empty string.
Not sure why the condition in the blueprint doesn’t work as it checks the same thing.

This warning is normal. Do you run an automation without your newly added condition?
Then sensors will be replaced with devices matching your defined treshhold.

@Sbyx I just wanted so say thankyou, this is a great blueprint!

I couldn’t find any great way to get notified when a Zigbee/ZWave device has dropped off the network entirely - and it was even dangerous, e.g if I didn’t know my water-leak-sensor had dropped off the network.

So, I have borrowed (very) heavily from your code here, just making a couple of modifications, and make a new blueprint to notify once a day with a list of any devices that have gone offline.

It’s my first ever time making a blueprint, and there was no way I could have done it without your code. So, thank you!

Blueprint to notify of offline battery devices

3 Likes

@Sbyx thank you for such a nice blueprint!)

Is there a way to add a custom attribute to the notification message? I have a battery_type attribute added for my battery sensors. Would be nice to see something like
Low battery warning for: bathroom temperature battery (15% CR2032)
:upside_down_face:

2 Likes

Hi @Sbyx,

Could this blueprint work with sensors that have the battery state in volts and not percentage?

Thanks.

That would also interest me.
have the same problem. For me it is even the case that 3.0V corresponds to 100% and 2.1V to 0% since the actuators already have 2.1V low bat.

Maybe a stupid question, but when I manually ran the script, then I did get a notification (without the sensor name in it because all batteries are full).

But isn’t it supposed to only send the notification when the threshold really is below 20% or is manual running supposed to send the notification anyway?

So the solution to my problem, for Homematic IP battery devices, is a separate value_template sensor for each device that converts the volts into %. So it is possible to show the sensors in a battery map.

#Fernbedienung
      fernbediehnung_bat:
        friendly_name: "Fernbedienung"
        value_template: >-
          {% set voltage = states('sensor.fernbedienung_rolladen_ug_operating_voltage') | float %}
          {% if is_state('binary_sensor.fernbedienung_rolladen_ug_low_battery', 'on') %}
            0
          {% else %}
            {{ ((voltage - 2.1) / (3 - 2.1) * 100) | round(0) }}
          {% endif %}
        unit_of_measurement: "%"                          

1 Like

Bit off topic.I find this automation so useful thanks for developing it!
Is it possible to create a blueprint like this: finds automatically DW Sensors and informs when on ore more are open for a certain time?

Manual always sends the notification, even if all batteries are above the threshold.

I guess it is more helpful to test if notifications are set up correctly than test whether HA can do basic comparison tests.

1 Like

Thanks, I figured, now I know :slight_smile:

I’ve tweaked this template to provide the friendly device name for any “low battery” binary sensor or “measurement” sensor. This means that you won’t see “SensorName Battery Level” names being returned in the notification if there is a valid device. If an entity has no device, then it should still provide a friendly-ish name:

1 Like

Hi
Thanks for sharing this blueprint

How can I send a telegram notification having the battery name and % ?

I also noticed that when excluding sensors, there is something wrong

I get

    exclude:
      exclude_entities: []
      entity_id:
        - sensor.name_1
        - sensor.name_2

and it does not work, while should be

    exclude:
      exclude_entities:
        - sensor.name_1
        - sensor.name_2

Ah yes, I see the exclusion is completely broken. I will work on that. Thanks for pointing that out!

To add the % to the notification you can change line 80 from:

{% set ns.devices = ns.devices + [{'id': id, 'name': name|trim, 'battery_level': states(entity_id)|int, 'is_entity': is_entity_only}] %}

To include the % in the name field:

{% set ns.devices = ns.devices + [{'id': id, 'name': name|trim ~ ' (' ~ states(entity_id)|int ~ '%)' , 'battery_level': states(entity_id)|int, 'is_entity': is_entity_only}] %}

I’m thinking about adding a config GUI option to allow you to show or hide the % value in the notification without having to modify the code.

2 Likes

Thanks @josephquigley

Now, in the {{names}} field I get all the names of batteries that are below the threshold.
It would be nice to have something like
name1 (n1%), name2 (n1%), …

I’m a little confused by what you are asking for, because when I make the change I posted for line 80, I see all the devices with a battery level below the threshold and their % levels:

Did you reload the Automations so that the blueprint changes take effect?

Sorry, I haven’t made the change in the automation, so if now is like you posted it’s really fantastic.

I will try as soon as I can

Thanks