Howto create battery alert without creating a template for every device


#492

Awesome. Looking better :smile:.

Try the config topic again. If you are on 0.80 or newer, it should go away automatically without a restart. If you’re on an older version, a restart is needed.


#493

Thanks. My bad! Was publishing to the wrong config topic as lucky me, I have two ‘offices’! Sent a blank publish to homeassistant/sensor/plug_158d0001dc3a20_battery/config and it has vanished! Thank you so much :yum:


#494

I’m struggling to get the Xaiomi battery levels to report properly. If I play around in the template editor, I can easily manipulate the values using the following examples.

{{states.binary_sensor.smoke_sensor_landing.attributes.battery_level}}
gives me 55.0

{{states.binary_sensor.smoke_sensor_landing.attributes.battery_level | int * 2 }}
gives me 110

{{states.binary_sensor.smoke_sensor_landing.attributes.battery_level | multiply (1.5)}}
gives me 82.5 but shows in Battery Levels as 66.0. I can only seem to get the real value (55), 110 or 66 but nothing representing the value I believe I’m try to achieve of 82.5.

{{states.binary_sensor.smoke_sensor_landing.attributes.battery_level | int * 1.5}}
also shows 82.5 in template editor but displays in battery levels as 66%

image

Is there a tweak for that?


#495

To change the template, you have to restart, trigger a state change, restart again, then trigger another state change. Alternatively, you can restart, clear the config topic, then trigger a state change.


#496

Awesome, good to know, thank you. Wondered why it wasn’t changing.


#497

I will try your latest version next week, I am away from home right now.

One more idea: Since the thermstats report the real battery value in volts, could we transfer this information over to the battery sensor as an attribute so that I can click on the battery sensor and read the real voltage as well?

Looking at your code I thought about something like this:
starting line: 547 (action part from battery_sensor_from_attributes)

https://hastebin.com/ceqalogaxo.cs

I made changed in lines 23-29 and 75,76
They are not tested in any way and I am sure there are errors in the way I wrote the code since I am not good enough yet with all this high level yaml…
Just the general idea maybe can work…

Here is a screenshot of the original entity of one of the thermostats:

I will be back next week and then I will test you latest changes (incl. the ones from above with the battery_template_string )


#498

Seems sorted - fantastic


#499

Great idea. Adding an attribute to hold the original value definitely sounds useful, especially when using templates to manipulate them. I’ve implemented your idea in the 1.1.6 release. I removed the attribute named attribute and replaced it with the actual attribute name and value from the original entity. So, your battery sensor will now have an attibute named battery with a value of 2.5.

Since this changes the sensor definition, it will require a restart, state change, then another restart or a restart, clear mqtt topic, then state change.


#500

I got this running tonight, awesome work!

Few questions… I don’t quite understand maxthreshold, what’s it’s purpose? Min is when it falls below that number correct, how does max work?

It picked up all the battery sensors I had mapped manually except for 2, the batteries for my ring devices, do those not work? Maybe they haven’t reported yet, will wait.

It picked up my 2 phones, with those I generally don’t like alerts until like 20% or lower, but with all other devices like locks, zwave, and zigbee, I generally do something like 60% as those devices seem to stay at 100% forever, then drop once or twice then just die, anyway to have threshholds per domain?


#501

Also, names are good by default, any damage if I rename the sensors from UI? will that mess up the groups or anything?

And how does Clear work? I assume alert keeps coming, but I see a clear automation, how does that work?


#502

I did figure out that max is what I thought min was, so I set max to where I wanted and min back to -1, so it’s working now.

I noticed that I get double alerts, even though I only have one entity listed? So I will get one for my phone that says like 62.0 and another that says 62, with what appears to be for the same entity. This is with a device tracker and a zwave device, so doesn’t seem device specific


#503

I restarted home assistant and the duplicates stopped, it might have been grouping in some of my old sensors I had made manually and not the ones it had made possibly


#504

Since the package only sends notifications twice daily, it typically isn’t the best way to monitor phone batteries. Most people, myself included, use battery_alert_disabled to disable alerts for them completely. Once you do that, you can create your own automations to alert you for the phones however you wish.

I’m not sure. I haven’t tried. If you try it, let me know how it goes.

It clears the persistent notification when there are no low batteries.


#505

Thanks! What’s the use case for min threshold?


#506

Also, do I need to do anything extra to setup pushover? I have that setup and I use it with notify for all my alerts, but I waited until 10:00 today and didn’t get my initial push notification, but I’ve got them in notifications in the web app.


#507

Some users wanted to ignore devices that had battery level of 0, so you can set the min threshold to 0 to ignore them.

Currently, it assumes your notifier is named notify.pushover. If it’s not, search and replace notify.pushover with the name you use.


#508

I might have not named my pushover, so it could be defaulted to notify.notify instead of notify.pushover.

I also see in there where it says to call that between 10:00AM and 6:00PM, but where is the twice a day thing? If I clear the persistant notification from the web app, it comes back in a few minutes, is it only twice a day for things like pushover?


#509

Pushover notifications happen twice daily, but persistent notifications check every 15 minutes.


#510

@NotoriousBDG
Thanks for the update!!
I managed to install it today and test out the new features (battery_template_string, and battery value in the sensor)

Looks good to me!!

Just one question: Will the (full battery) icon change to an empty battery icon once that sensor goes from Full to Low ?


#512

No. It’s not currently possible for battery sensors with string values. MQTT sensors would need to support icon templates for that to work. If you change the template for the sensor to return a percent, the icon will change with the battery level.