Howto create battery alert without creating a template for every device


Done. Thanks for the suggestion.

I haven’t heard of custom_updater before. A cursory look at their docs on GitHub, it doesn’t appear to support packages and it requires Lovelace.

All you have to do is wait for each battery powered device to update. If you don’t want to wait, force a state change for each of your battery powered devices.


Ok, then i will have patience :slight_smile:


Release 1.2.1 is available now that addresses the breaking change in 0.86.0.



Looks like I have some problems with 0.86.2 and the 1.2.1 package. How do I get the "Battery Alert setup" and "Battery status overview" in Lovelace!

I have tried using the Enteties Card using group.battery_alert, group.battery_status and group.battery_view, but all I get is this. If I click on them, I get the expected display. How do I get the overview displayed as default?


I’m not sure what’s causing that. I’ve upgraded to 0.86.2 and it’s working fine for me. I’m not using any custom cards. It works just like the old ui for me without needing to customize Lovelace.

The only difference I see with Lovelace is that changes aren’t automatic any more. They require a browser refresh to see them.


Odd, question what “value” do you use if you want to exclude a battery sensor. I have ios: and owntrack enabled so I’m getting a duplicate battery instance from ios (“iphone 8 battery”, “aram535 Battery”).

I tried putting in the device_tracker.xxxx_60f1_4038_b62c_1218a3890a4d, aram535 Battery. Haven’t been able to exclude it.

I also tried adding

  battery_sensor_creation_disabled: true

in customize to disable the creation of the battery sensor for the aram535 entity, but it still shows up.

BTW, owntrack is using HTTP and not MQTT.


I reinstalled the package code, reinstalled the Mosquitto broker, restarted HA. Nothings shows up in the GUI.

And I am getting enters in the HA error log. Any ideas what’s making the error?

The strange thing is that when i go to my //, the battery-GUIs are displays as expected.


battery_sensor_creation_disabled should be set under customize for the entity that has the battery attribute. Check the entity on your states page to make sure you see battery_sensor_creation_disabled: true. Once you’ve confirmed it’s there, you’ll need to delete the battery sensor. To do that, just copy the value of the delete_battery_sensor attribute and paste it into the Delete a Battery Sensor input text box.

It looks like the package is working fine, but there is something wrong with your Lovelace config. Have you tried deleting your lovelace config file to revert back to system managed UI?

I don’t see a way to programmatically control the UI with Lovelace like there was with the legacy UI. If you want to customize the Lovelace UI, it looks like a side effect is the management of the cards for batteries and the entities in this package will be user’s responsibility. Lovelace is still pretty new and I have almost no experience with it so far. I’m sure some options will present themselves in the future :slight_smile:.


Hah! Sorry about that … now that I actually read the sensor line quietly to myself I have to giggle that I copied-n-pasted that one in.


You need to add something like this:

  - type: entities
    title: Battery Status
    show_header_toggle: false
      - sensor.fibaro_system_fgt001_heat_controller_battery
      - Add your sensors here

  - type: entities
    title: Battery Alert
    show_header_toggle: false
      - input_boolean.low_batteries
      - input_number.battery_alert_threshold_min
      - input_number.battery_alert_threshold_max
      - input_text.delete_battery_sensor
      - input_text.notifier_name
      - input_select.notifier_format
      - automation.battery_persistent_notification
      - automation.battery_persistent_notification_clear
      - automation.battery_notification_default
      - automation.battery_notification_slack
      - automation.battery_sensor_from_attributes
      - automation.update_battery_status_group_members
      - automation.delete_battery_sensor


Aha…got it! Thanks!


I watch this thread and it amazed me how difficult people make battery management out to be. The thought of pumping this all via MQTT just feels so inefficient and dirty.

I have the below script; which I use time_pattern to run every couple of hours and a 2nd trigger if the threshold slider is changed that handles it all. All you need is the input_slider to set the threshold; or you can hard code it. No pre-defined groups and such.

  alias: Battery battery_check

    - condition: template
      value_template: >-
        {%- set battery_alert_threshold = states('input_number.battery_alert_threshold') | int -%}
        {{ states.zwave | selectattr('attributes.battery_level', 'defined') | selectattr('attributes.battery_level','<', battery_alert_threshold ) | list | length >= 1 }}
    - wait_template: "{{ is_state('script.notify_all_engines' , 'off') }}"
    - service: script.notify_all_engines
        title: "Low Battery"
        who: "john"
        message: >-
          {%- set battery_alert_threshold = states('input_number.battery_alert_threshold') | int -%}
          {%- set low_batteries = states.zwave | selectattr('attributes.battery_level', 'defined') | selectattr('attributes.battery_level','<', battery_alert_threshold ) | map(attribute='name') | list | join(', ') -%}
          Low batteries in the following devices: {{ low_batteries }}


I agree that monitoring batteries with Home Assistant is way more difficult and complex than it should be. The issue is that each component has their own unique way of reporting battery levels. There are no standards and no consistency. Your example only handles zwave, while this package handles all variations that I’ve encountered and have been reported in this thread by others.


True, but if you change the states.zwave to states.sensor this will parse all sensors; I just limited it to save a couple CPU cycles.


Yes, that’ll handle a different format, but there a many more variations that it would miss, including zwave devices.


If you use the custom card “group-card”

You only need this code for lovelace.

title: Battery
icon: mdi:battery
  - type: custom:group-card
      type: entities
      title: Battery Status
      show_header_toggle: false
    group: group.battery_status
  - type: custom:group-card
      type: entities
      title: Battery Alert
      show_header_toggle: false
    group: group.battery_alert

And then you dont have to edit the code if you have more entities.


That looks like a really nice simple solution.


Just perfect!


I’m hoping someone can point me in the right direction on the following. For some reason I cannot get the notifier working for my iOS group that works for all other automations tied to it.

The notify group is set correctly under the Notifier name input field but I only receive updates for low battery alerts via the native web notifications.


Perhaps you’re using a notifier component that needs a special format. Which notifier component are you using? Do you have an example of the format needed?