đŸȘ« Low Battery Notifications & Actions

can you post your yaml ?

sure

service: notify.persistent_notification
metadata: {}
data:
  title: đŸȘ«Batterie schwach —
  data:
    notification_id: batterylow
  message: |-
    Folgenden GerÀte haben weniger als 10% Batterie:{{'
    '}}‱ {{sensors|replace(', ', '
    ‱ ')}}

@skort

It is possible but I can see a lot of options, like day, time, first Monday etc. The best way is to add a custom condition. The condition would be a template condition, edit in YAML and enter this code. This is for the first Monday of the month. 0 = Monday and <= 7 is the first week of the month. So if you would like it on a Friday the 0 would be 4. Then just use time option and you could also set the day to be the same to.

condition: template
value_template: "{{ now().weekday() == 0 and now().day <= 7 }}"

EDIT: I did a FAQ in this now. For more details click here.

Let us know how you go.

Blacky :smiley:

1 Like

@andyblac

This is a good way and I will do a FAQ how to for this.

Blacky :smiley:

1 Like

FAQ - How to add a Persistent Notification in the UI

In the UI you have notifications as shown below. This is called a Persistent Notification.

8

When you click on the ‘Notifications’ you will see this. You can customize it anyway you like but I will show you how to do the a emoji with a title and bullet points for the batteries in this example.

9

If you would like to add this type of notification then follow the steps below.

  1. In the custom actions, click on the ‘+ ADD ACTION’ button

  2. Then start typing ‘notifications’. You will see the notifications options pop up. Select ‘Send a persistent notification’

  3. Then click on the 3 dots and select ‘Edit in YAML’.

  4. Copy the code below and paste it in as shown below. Replace the ‘all_sensors’ with the sensor you would like to use. You can also change how you would receive this message by using a ‘If-then-else’ or a ‘If-then’ action. In another FAQ I show you how to do this, Click Here. In the FAQ link example 6 = Shows you how to receive a ‘Okay confirmation message’ and example 7 = Shows you how to receive a message if there are batteries to report. The below example will just report every time it runs.

service: notify.persistent_notification
metadata: {}
data:
  title: đŸȘ«Low Battery Notification
  message: |-
    ‱ {{all_sensors|replace(', ', '
    ‱ ')}}
  1. Click save and your done :tada:. Next time the automation runs you should receive a notification in the UI.

Enjoy

Blacky :grinning:

Back to FAQ: Click Here

FAQ - How to run the automation once a month

You can run the automation once a month by adding in a ‘Global Condition’. Below are the steps on how to do this. There are 2 examples, choose the one you would like to use.

EXAMPLE 1: This will run it once a month but you can’t use the ‘Button Helper’ follow these steps.

  1. In global conditions click ‘+ ADD CONDITION’

  2. In the search start typing ‘template’. Template will pop up and select it.

  3. Copy and pase the code provide below.

  • ‘0’ = Monday so if you would like to run it on Friday then replace the ‘0’ with ‘4’.

  • ‘7’ is for the first week of the month.

{{ now().weekday() == 0 and now().day <= 7 }}
  1. Then enable time, set the time you would like and because we used ‘0’ = Monday we also selected Monday.

  2. Click save and your done :tada:. The automation should only run on the first Monday of the month.

EXAMPLE 2: If you would like to still be able to use the ‘Button Helper’ and run it once a month follow these steps.

  1. In global conditions click ‘+ ADD BUILDING BLOCK’

  2. Then select ‘Or’.

    21

  3. Click the 3 dots and ‘Edit in YAML’

  4. Copy the code below and paste it in. Change it to the day you would like

  • ‘0’ = Monday so if you would like to run it on Friday then replace the ‘0’ with ‘4’.

  • ‘7’ is for the first week of the month.

    23

condition: or
conditions:
  - condition: trigger
    id: t0
  - condition: template
    value_template: "{{ now().weekday() == 0 and now().day <= 7}}"

  1. Then enable time, set the time you would like and because we used ‘0’ = Monday we also selected Monday.

  2. Click save and your done :tada:. The automation should only run on the first Monday of the month and allow you to also use the ‘Button Helper’.

Enjoy

Blacky :grinning:

Back to FAQ: Click Here

1 Like

i tested this a bit more and if a “Okay Confirmation Message” selected the peristent notification looks like this:

In the FAQ example 6 shows you how to receive a ‘Okay confirmation message’ in your custom actions Click Here
 your ‘then’ will be for the okay confirmation and the ‘else’ will be for the batteries to report using the persistent notification option.

Let us know how you go.

Blacky :smiley:

perfect
 Works like a charm


Nice one


Enjoy

Blacky :smiley:

Hi, very nice automation. Works great for sensors that report a specific battery percentage. However, I have a number of temperature/humidity sensors that only report battery STATE, i.e. high/medium/low. Is there any way these can be included such that if status is low they are reported?

@Richard_Fuller

Hi Richard, it is already there and you should receive the 'Low" batteries in your notification. You can select from ‘Easy Notify - Message’ options 1 or 2.

If it doesn’t do it I am keen to know more.

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.

Could you also provide a screen shot of your entity state in developer tools.

Blacky :smiley:

Thanks for the quick response. If you say it will work for these sensors then great. I don’t currently have any of these sensors where the battery state is actually “low”, so I was not aware of this and I could not find any reference in the documentation. Also, these devices do not appear when clicking the “devices” or “entities” buttons for custom and excluded sensors on the setup screen, so I assumed that they don’t work. Maybe tomorrow I will try to find some old batteries and add them to one of my sensors to verify.

Thanks for your help

O okay, thanks for letting us know.

Blacky :smiley:

Thanks for the option! I’ve added it to the automation.

I have a bunch off homematic devices but they report low battery as binary value. So when the battery is low the sensor is true. Is there any way to integrate these into your blueprint?

No problem at all :wink:

Blacky :smiley:

@stephan182730

Normally HA will see ‘true’ as ‘on’ and that is already added. Please check this and make sure you have the correct settings.

If this is not the case then could you please provide a screen shot of your entity from within the developer tools and could you also 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:

Hi,
I think I may have found a bug in the TODO description when running with confirmation disabled. When running with a custom group only, my TODO task description was empty.
Looking at your gist, I think you want this line

description: "{{all_sensors|replace(', ', '\n')}}"

to be

description: "{{to_do_message}}"

@jstys92

Firstly welcome to the community :wave:

Yep you sure have. I will fix it
 thanks for the heads up.

I will look at it

Again thanks for the heads up letting me know.

EDIT: Home Assistant has a bug in the to-do list. I am waiting for them to fix this before I can fix the blueprint. All my to-do list are gone and I have errors. I have logged a bug report with HA.

Blacky :smiley: