Howto create battery alert without creating a template for every device

Now that i look further into it, it seems i never had the components correctly that saved the items after an update. So it was my bad, i can recall a long long time ago i always ‘edited’ it to set in my ios but that can be easilly changed by setting the value which is saved.

That said, i am also looking into cleaning my logs/history more. Might be nice if we could remove the triggers from the log in the battery package it self too. To give an example, this is in my db:

When it comes to size, this is looks to be a big one…

Oh, thanks for letting me know. I’ll make note to fix that in the next release.

AFAIK, that’s not something that can be controlled from within a package. All you should have to do is add the automations to the exclude section of your history config.

history:
  exclude:
    entities:
      - 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.update_battery_low_group_members
      - automation.remove_battery_low_group
      - automation.delete_battery_sensor

Thanks for the info, i was not sure if it was even possible to have history/recorder stuff in a package… now i know that too :slight_smile: might be a nice feature in the future (from HA itself that is)

Hi, I have a suggestion. Please look at the last sensor in my screenshot.
Since battery cannot be negative (:smiley:) I think it’s advisable to take the absolute value of the battery reading, so it doesn’t create silly negative values as eCozy smart radiator valves do.

Good work, your plugin is very precious.

You can use the battery_template feature to do that. See the example below. Just replace sensor.ecozy_entityid with your valve entityid (not the battery sensor entityid). After making the change and restarting Home Assistant, delete the battery sensor and once it gets recreated, it’ll show you the absolute value.

homeassistant:
  customize:
    sensor.ecozy_entityid*:
      battery_template: "{{ value_json.value|abs() }}"

I really love the battery alert thing, but it is giving me a hard time.
I have had a few, very odd duplicate sensors, and some that I wasn’t sure was real, so I deleted them, and waited for them to be recreated.
Some of them has been recreated, a few has not.
Looking through my setup, I can see two IKEA dampers in the bedroom that were added at the same time, one has a battery sensor, the other has not.
An IKEA controller in the kitchen is missing, the damper is there.
In the livingroom the two chained controllers are both missing, though one of them doesn’t even appear in HA.

This one from the bedroom doesn’t have a battery sensor


The other from the bedroom, does have one
.
Then, there is the one from the kitchen, that does not have a battery sensor

Not sure if its worth it to anyone but made a few local changes I could submit a pull request for.

  • Added mqtt discovery topic so you can choose what you want. I can’t spell so i like to abbreviate to “hass”
  • Notifier name can just be the literal name and no longer needs preceded by “notify”. Its best practice to name all your notify platforms but will still fail over to notify.notify
  • I added a few more notification integrations. So far I have only tested the HTML5 push notifications since I don’t have telegram, slack, pushover or join setup.

I added all of this to an older version of this package and completely forgot I did that until I upgraded HA and everything broke.

The only one of my battery sensors I can’t figure out is the ups battery sensor. It gets pulled in from the apcupsd component and this package picks it up by (item.name | lower).endswith('_bat'). It reads it just fine but it being a float when everything else is an int annoys me.

Here is what it looks like when i open it up from the battery card:
ups%20battery

My customize for that sensor looks like:

sensor.ups_battery:
  battery_template: "{{ value_json.value | int }}"

I’ve tried adding `device_class: “battery” but that hasn’t solved anything either. I think it has to do with the sensor itself but I’m running out of ideas. Here is what HA has listed for that sensor:

Everything seems to work fine but the error log after install is immense. My main concern is with the components/yr/sensor.py (ERROR)

Log Details (ERROR)

Sun Jun 30 2019 17:44:36 GMT-0300 (Horário Padrão de Brasília)

Retrying in 15 minutes:

Setup of hassio is taking over 10 seconds.

18:03 main.py (WARNING)

Retrying in 17 minutes:

18:03 components/yr/sensor.py (ERROR)

Setup of platform yr is taking over 10 seconds.

18:03 main.py (WARNING)

Setup of platform dht is taking over 10 seconds.

18:03 main.py (WARNING)

Setup of xiaomi_aqara is taking over 10 seconds.

18:03 main.py (WARNING)

Setup of group is taking over 10 seconds.

18:03 main.py (WARNING)

Setup of input_text is taking over 10 seconds.

18:03 main.py (WARNING)

Setup of input_boolean is taking over 10 seconds.

18:03 main.py (WARNING)

hello , i have a question. I have tried your package,it is very good. But i have change the name of many of my sensor and now i have old sensor battery i want to delete.I would like to restart from zero.It is possible to delete all the sensor to restart from zero ? not one by one .

1 Like

funny, I was literally about to ask this same question and found this :slight_smile:

I dont think this is related to batteries - yr is this - https://www.home-assistant.io/components/yr/

@NotoriousBDG

just noticed - using lovelace, the group update trigger to include new batteries doesn’t update the gui list itself?

ignore my bit about lovelace…

Yes, you can. Just reinstall MQTT and all values ​​will be exclude.

Did you mean reinstall or restart mqtt?

How does this work now with .96 that just came out, I haven’t updated yet, but in breaking changes it says it’s going to make battery sensors now automatically

Looks like just for zha

Reinstall. When you reinstall all topics are deleted. There are other ways but I think this is the easiest.

I updated HA and this solution is no longer working as it should.

@NotoriousBDG this package mixed with the bar-card makes a great battery overview:

image

Thanks again for your efforts!

1 Like

could you share you lovelace code plz

Sure thing here you go:

entities:
  - entity: sensor.bedroom_3_temperature_battery
    title: Girls Room Sensor
  - entity: sensor.loft_temperature_battery
    title: Loft Sensor
  - entity: sensor.master_bedroom_temperature_battery
    title: Master Sensor
  - entity: sensor.front_door_lock_battery
    title: Front Door Lock
  - entity: sensor.house_siren_battery
    title: Siren Battery
  - charge_entity: sensor.robot_vacuum_robot_cleaner_movement
    entity: sensor.robot_vacuum_battery
height: 25px
severity:
  - color: var(--label-badge-red)
    value: 40
  - color: var(--label-badge-yellow)
    value: 65
  - color: var(--label-badge-green)
    value: 100
type: 'custom:bar-card'
5 Likes