Howto create battery alert without creating a template for every device

It will get triggered any time there is a state change for an entity that has an attribute named “battery_level”. When you see it happen 10-15 times in a row, is it for the same entity or different ones? Which component(s) generated the entities that you are seeing this issue?

@NotoriousBDG

Thank you so much for this awesome package. I installed V1.0.7 about a week ago and I like it.

Just two things I wanted to share with you.
I have a few Xiaomi Dorr and Window Sensors, those are working great and they get detected as % as it should be.
But I also have Window Sensors from Homematic and also Thermostats from Homematic and those two devices are showing up a bit wierd.

The Thermostat is reporting its battery in V (Volts) of the actual battery that inside the device. That gets picked up by your script and gets rounded to a whole number to make it a % battery sensor. So the reportet 2.6V from the device become a battery sensor of 2%.

The Window Sensor from Homeatic reports its battery as High, Medium or Low. But it somehow comes out as 0%.

I attached 4 screenshots so that you might be able to understand.
Any help would be great

I’m working on a feature that should be able to help with this one if you know how to create a template that converts 2.6V to % or if you know what voltage represents low battery. If you know, it would help me if you could share that info so I can validate whether it will work with the feature I’m working on.

I see the issue with this one. I’ll work on a fix.

Awesome package. For sensors that do not report about battery level directly but do a check in periodically (e.g., 24 hours) can you add a template to trigger if something has failed to check in within a certain period?

Thanks! That might be possible, but I’m not sure how to identify which devices are battery powered if they don’t have a battery attribute. Do you have any examples you can share? It would be helpful to see a screenshot of them from the /dev-state page so I can see their attributes.

Version 1.0.8 is now available at Home-AssistantConfig/packages/battery_alert.yaml at master · notoriousbdg/Home-AssistantConfig · GitHub

Added

  • Add support for defining battery_template attibute to
    allow manipulation of value of battery sensor
  • Support battery attributes that contain strings

Removed

  • Cleaned up notifications by removing object id

Try using the new battery_template feature in this release to either convert volts to % or “Low” when it’s less than a certain voltage. There are some examples in the documentation section that should help.

This should be fixed in this release.

Any idea to make this excellent code as an Addon?
This way HA will display when a new version is published and the update is done with a button.

Just some wishful thinking.
Cheers.

1 Like

I like the way you’re thinking. That’s an awesome idea. It should be pretty easy to do.

Its normally genereated by the same entity, but its not the same entity every time.
It seems its related to zwave battery powered devices.
Example:

Thanks for the very fast update.
I will get that integrated during the next days.
Will let you know how it works out.

The automations only trigger on state changes. There must be reason why that device is updating it’s state so often. Can you look to see why that z-wave device is sending so many state changes?

Release 1.0.9 is available now. I finally figured out how to automatically create a group that contains all battery entities. If you created a Battery Status group manually, you can remove that from your config.

Installed version 1.0.10 (Hassio 0.71.0) and I am not getting a “group.update_battery_status_group_members” in my DT-Sates overview.
Should I?

I can see the “Update Battery Status Group Members” option in the “group.battery_alert”-view in my HA.

The group should have an entity_id of group.battery_status and friendly name of “Battery Status”.

My bad!

I had named my prevoius (version 1.0.8) group for the battery level sesnor
“group.battery_status”. And this mixed up my setup. All smile now.

1 Like

I installed your package and it seems working good except the customize section.
I want to disable the creation of some sensors and added the customize section regarding this in this way:

homeassistant:
  customize:
    sensor.sensore_illuminazione_corridoio_battery:
      battery_sensor_creation_disabled: true
    sensor.sensore_illuminazione_studio_battery:
      battery_sensor_creation_disabled: true
    sensor.fha_zanzito_battery:
      battery_sensor_creation_disabled: true
    sensor.maurizio_zanzito_battery:
      battery_sensor_creation_disabled: true
    sensor.umidita_balcone_battery:
      battery_sensor_creation_disabled: true
    sensor.umidita_camera_letto_battery:
      battery_sensor_creation_disabled: true
    sensor.umidita_salotto_battery:
      battery_sensor_creation_disabled: true
    sensor.presa_1_battery:
      battery_sensor_creation_disabled: true
    sensor.presa_2_battery:
      battery_sensor_creation_disabled: true
    sensor.presa_3_battery:
      battery_sensor_creation_disabled: true
    sensor.pressione_balcone_battery:
      battery_sensor_creation_disabled: true
    sensor.pressione_camera_letto_battery:
      battery_sensor_creation_disabled: true

I added this firstly to my customize.yaml and it did not work, then i added these entries directly to the package, but it seems not working the same as those sensors i want to not be created are still on my battery status group. How to not have those sensors displayed in that group and where to put that customize section?

battery_sensor_creation_disabled should be applied to the entity that has the battery attribute. Since you already have the battery sensors created, you’ll need to clear those retained mqtt topics after you update your customize section to the right entities.

Hmmm… Can you tell me how to do what you advice me? How to clear the mqtt topics? Sorry but really newbie here…

The easiest option is to uninstall and reinstall the Mosquitto add-on.

Too complicated for me… I give up…:rofl: