Howto create battery alert without creating a template for every device

Just installed it on 0.96.4 and before I restarted hass I ran the config test which reported an error. Doe anyone know how to fix it?

Invalid config for [automation]: required key not provided @ data['action']. Got None
required key not provided @ data['trigger']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/

Check your automations for errors.

Sorry but there are no automatons yet because hass complains about the config before the initial restart after installing the package

Did you modify the package?

No. I followed the installation instructions by downloading the battery_alert.yaml to CONFFOLDER/packages and then added the packages section to the configuration.yaml and then I checked the configuration.

And you haven’t created any other automations at all?

Do you mean for this battery checker or for other things? For other things I have a lot. I am quite fluent in home assistant and have some custom components of my own so I would say that the error lies in the way this is setup in conjunction with release 0.96.x (saw a bug report on the repo about 0.96 so I’m not alone)

Mind linking the bug? I don’t like surprises myself. Just haven’t run into any issues with 0.96.x yet.

https://github.com/notoriousbdg/Home-AssistantConfig/issues/20

I decided to write my own much smaller python_script though if anyone else is interested.

First of all a huge thank you to @NotoriousBDG et al for the awesome work.

A question:
I’m seeing an issue with my customizations. In particular it seems that ‘packages: !include_dir_named packages’ section interferes with ‘!include customize.yaml’ for whatever reason. As soon as I add ‘packages: !include_dir_named packages’ to configuration.yaml I start getting “It seems that your configuration.yaml doesn’t properly include customize.yaml” error when customizing entities and all customizations are ignored. The 2 entries work separately without issues. Am I the only one experiencing this?

My entry is as follows:

homeassistant:
  packages: !include_dir_named packages
  customize: !include customize.yaml

Hey guys.

I have many devices now the the “Battery Alert” and “Battery Status” groups are taking a lot of realestate in my “states” ui.

I tried “Customize” to hide them but they keep coming back.
Any ideas?

The best solution I’ve found is to not make battery sensors at all. Instead, use python_script, automation, AppDaemon, or Node Red to check them all and offer a report that is either sent via notifiy or persistent_notification.

A question:
I’m seeing an issue with my customizations. In particular it seems that ‘packages: !include_dir_named packages section interferes with ‘!include customize.yaml’ for whatever reason. As soon as I add ‘packages: !include_dir_named packages’ to configuration.yaml I start getting “It seems that your configuration.yaml doesn’t properly include customize.yaml” error when customizing entities and all customizations are ignored. The 2 entries work separately without issues. Am I the only one experiencing this?

Using packages you need to define each package as they are named objects. In each package yaml file within the directory, are they named?

If you split it into the normal package configuration like below, does it work?

homeassistant:
  packages:
    pack_1: !include my_package.yaml

Thank’s a lot for this Package is perfect!!!:slight_smile:
I have two question,
There is a way to add more than one notify service?
I don’t know why but i have some devices that are duplicated:

Low Battery Levels
Pulsante Faro Lago (87)
Pulsante Faro Parcheggio (87)
Pulsante Faro Posteriore (74)
Battery Level (87)
Battery Level (94) (I Think iPhone di Micol)
Battery Level (60) (I Think iPhone di Stefano)
iPhone di Stefano Battery (60)
Micol Battery (94)
Pulsante Faro Lago Battery (87)
Pulsante Faro Lago Battery (87)
Pulsante Faro Parcheggio Battery (87)
Pulsante Faro Parcheggio Battery (87)
Pulsante Faro Posteriore Battery (74)
Pulsante Faro Posteriore Battery (74)
Stefano Battery (87)

That’s what I’m beginning to think as well because this is becoming cumbersome and I feel like it’s jamming the mqtt a little.
Do you have any links to good scripts/automations?
Would an automation pick up new devices or do I have to add them manually?

I use an AppDaemon app I borrowed from somewhere and modified for my needs.

However, this could be done with any number of tools.

The automation (or whatever you use) will pick up all new devices if written correctly. Because, when it runs, it needs to go through every entity in all of Home Assistant and look for “battery” type attributes. My version looks for sensors and binary_sensors of device_type “battery” as well as the attributes “battery”, “battery_level” and “battery_low” because this suits the devices I use. More than likely, my AppDaemon app will work for anyone, but, someone may have devices that present battery in a different way that it doesn’t detect.

3 Likes

Thanks very much, I don’t know much about appdaemon at all but I’m assuming the app you linked above does what you described as in it searches all sensors and binary sensors?
I didn’t find any mention of sensors in the code you linked :slight_smile:

In the code I shared the line that says “self.get_state()” gets the state and attributes of every entity in all of Home Assistant. The rest of the code flips through them looking for battery attributes and such.

1 Like

That sounds great, very keen to try it out.
Now for the fun part, how on earth do I batch delete this component and all the battery sensors it’s created?

I tried deleting the package but all that does is ungroup all the sensors and everything becomes a mess…

What I did to uninstall:

  1. Remove package
  2. Using MQTTExplorer, delete all retained messages
  3. Edit Lovelace and remove battery related entities

Not sure if this is all that’s needed though?

1 Like