šŸŖ« Low Battery Notifications & Actions

Just checking, is it still not possible to use wildcards?

Hi, congratulations on the project, Iā€™m using custom actions to receive notifications on Telegram, it only reports sensors with battery below the threshold but not unavailable sensors. on UI Notification are reported regularly. this yaml custom actions

if:
  - condition: template
    value_template: "{{ not all_sensors == '' }}"
then:
  - action: notify.telegram
    metadata: {}
    data:
      title: šŸŖ«Batterie Scariche
      message: |-
        ā€¢ {{all_sensors|replace(', ', '
        ā€¢ ')}}
else:
  - action: notify.telegram
    metadata: {}
    data:
      message: Tutte le Batterie sono OK
enabled: true

@asalvatico

Welcome to the community and thanks for your kind words.

I cant see what you have selected but maybe you need to select the option to use it :thinking:

If this is not it then could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on ā€œ</>ā€ and paste code in there.

Blacky :smiley:

No still not possible.

Blacky :smiley:

@tux

Thanks for kind wordsā€¦ try the code below.

if:
  - condition: template
    value_template: "{{ all_sensors == '' }}"
then:
  - action: notify.telegram
    metadata: {}
    data:
      message: Tutte le Batterie sono OK
else:
  - action: notify.telegram
    metadata: {}
    data:
      title: šŸŖ«Batterie Scariche
      message: |-
        ā€¢ {{all_sensors|replace(', ', '
        ā€¢ ')}}

Blacky :smiley:

@Blacky
thanks for your quick response.
I had already tried without the not, tried again with the code you sent but nothing. even the sensors with battery below the set threshold do not arrive. if I send to Google ad it works regularly. Even with simple:

action: notify.telegram
data:
  message: ...Battery "{{all_sensors}}".

or

action: notify.telegram
data:
  title: Low Battery Notification
  message: "{{all_sensors}}"

I only receive a messageā€¦ Battery without the names of the sensors.
I believe that ā€œ{{all_sensors}}ā€ is not valued in the telegram in other automations I receive values ā€‹ā€‹of a single sensor in the telegram with

  message: >-
    Alert Temperatura Acqua {{
    states.sensor.sonoff_acquario_ds18b20_temperature.state }} CĀ°

@tux

Maybe try it without the bullet point.

if:
  - condition: template
    value_template: "{{ all_sensors == '' }}"
then:
  - action: notify.telegram
    metadata: {}
    data:
      message: Tutte le Batterie sono OK
else:
  - action: notify.telegram
    metadata: {}
    data:
      title: šŸŖ«Batterie Scariche
      message: |-
        {{all_sensors|replace(', ', '
        ')}}

or the emoji

if:
  - condition: template
    value_template: "{{ all_sensors == '' }}"
then:
  - action: notify.telegram
    metadata: {}
    data:
      message: Tutte le Batterie sono OK
else:
  - action: notify.telegram
    metadata: {}
    data:
      title: Batterie Scariche
      message: |-
        ā€¢ {{all_sensors|replace(', ', '
        ā€¢ ')}}

or both

if:
  - condition: template
    value_template: "{{ all_sensors == '' }}"
then:
  - action: notify.telegram
    metadata: {}
    data:
      message: Tutte le Batterie sono OK
else:
  - action: notify.telegram
    metadata: {}
    data:
      title: Batterie Scariche
      message: |-
        {{all_sensors|replace(', ', '
        ')}}

or this one :crossed_fingers:

"{{all_sensors|replace("_"," ")}}"

Let us know if any work as I donā€™t have telegram and once we work it out I will put it into the FAQ.

Blacky :smiley:

:smiley:ok by modifying code you sent I was able to make it work with code

if:
  - condition: template
    value_template: "{{ all_sensors == '' }}"
then:
  - action: notify.telegram
    metadata: {}
    data:
      message: Tutte le Batterie sono OK
else:
  - action: notify.telegram
    metadata: {}
    data:
      title: šŸŖ«Batterie Scariche
      message: |
        ā€¢"{{all_sensors|replace("_"," 
        ā€¢ ")}}"

but I canā€™t fix the lines these are sensors in the Notification UI
Schermata del 2024-12-01 15-14-14

this is what I see on telegram
Schermata del 2024-12-01 15-14-49

@tux

We are getting there. Could you try this as it not really listing them correctly.

message: "{{ all_sensors|replace(\"_\", \" \")|replace(\",\", \"\\n\") }}"

If you go into a sensor you will find your friendly names have all the ā€œ_ā€. If you look at this post you can edit the names that suits you better and you just may find that it works better. Try one that is in the notification and see if it works better.

Blacky :smiley:

@Blacky
by entering this

message: "{{ all_sensors|replace(\"_\", \" \")|replace(\",\", \"\\n\") }}"

mi da errore "template value should be a string for dictionary value @ data[0][ā€˜dataā€™] " quindi modificato come segue

  message: >
    "{{ all_sensors|replace("_", " ")|replace(",", "n") }}"

this is how I get it now
Schermata del 2024-12-02 14-21-41

I also changed the names of the sensors by shortening them even if they didnā€™t have ā€œā€

@tux

Try this.

message: >
    {{ all_sensors|replace("_", " ")|replace(",", "\n") }}

And also this

      message: |
        ā€¢ {{all_sensors|replace("_"," ")|replace(",", "
        ā€¢ ")}}

@Blacky

:smiley: ok here we go but with this code

  message: |
    "{{ all_sensors|replace("_", " ")|replace(",", "\n") }}"

the " " beginning and end of the instruction are necessarily required otherwise they will cause an error
this is the result
Schermata del 2024-12-02 15-40-40

while this works better and without touching anything

message: |
        ā€¢ {{all_sensors|replace("_"," ")|replace(",", "
        ā€¢ ")}}

this is the result
Schermata del 2024-12-02 15-54-39

now it works correctly with telegram
here is the complete code

if:
  - condition: template
    value_template: "{{ all_sensors == '' }}"
then:
  - action: notify.telegram
    metadata: {}
    data:
      message: šŸ”‹Tutte le Batterie sono OK
else:
  - action: notify.telegram
    metadata: {}
    data:
      title: šŸŖ«Batterie Scariche
      message: |
        ā€¢ {{all_sensors|replace("_"," ")|replace(",", "
        ā€¢ ")}}

action notify.telegram it must be replaced with the name of your Telegram notification
It would be interesting to insert directly into to-do from Instagram with Telegramā€™s callback function. Iā€™ll do some tests for this.
Thank you for the work you do and for your help

@tux

Nice one, glad you got it working, your welcome.

I will make a FAQ on this tomorrow so everyone can get the info.

Thanks for doing all the testing.

Blacky :smiley:

It was a pleasure to have been of help even if only with simple tests

Hi,

I have zero coding experience and I am very new HA user. I just found this out and thought that this would be easy way to maintain batteries. Unfortunately I got stuck and I have no idea what to do, if someone could help I would be very thankful.

@4ufons

Welcome to the community.

Could you please update your Home Assistant and it should work.

Let us know how you go.

Blacky :smiley:

Quick question and confirmation for my sanityā€¦ As new devices get added with batteries, will the existing configured blueprint auto inherit them or do we have to add them or re-configure it?

@Gurulee

Hi Lee, as you add devices or remove devices form HA, the blueprint will look for all your current devices with batteries as long as the device has a battery entity.

Blacky :smiley:

1 Like

New Update 2.7

Stay Charged, Stay Smart! Customize it your way and letā€™s automate your battery maintenance! :battery::zap:

:apple: New Feature For iOS

  • Notification Sound - The Home Assistant app for iOS includes built-in notification sounds, and you can import sounds from your iOS device into the app. Custom sounds can also be added via iTunes or from your cloud storage.

For more information on using sounds in the Home Assistant app, click here.

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:

Enjoy

Blacky :grinning:

Hi thank you for this blueprint. It was exactly what i was looking for.
Just a problem on my side. it is not notify me if a battery is in ā€œUnknowā€ status.
It work with anavailable, but not with unknow.
Is there a waz of solving this ?
Regards.