Hi and many thanks for sharing this blue print.
I tested it and it works very well with the usual devices with a corresponding battery display in %.
But now Iām facing a problem because I also have devices that donāt use the device_class ābatteryā but āvoltageāā¦ and they are devices with different voltage levels.
This means, for example, some devices work with a 1.5V battery and others with 3V or 9V and therefore all of these device/battery types reach their alarm value at a different voltage level.
For 1.5V devices this could be 1.2V, for 3V devices it could be 2.5V etcā¦
Now Iām asking myself whether I may have overlooked something that I could use to implement this with this blue print or whether it would be possible to integrate this function into this template?
Or are there other approaches for this?
I would be very happy about any help.
regards,
@c64 my suggestion would be to find a way to update those devicesā integrations so that they do use the device_class ābatteryā. I donāt see a reason why they should not do this. If the designer of the device or maintainer of the integration knows what the full battery voltage is, then they can define some logic to work out the percentage battery remaining.
Without this you will probably end up with some guesswork, but you could create a template sensor, set the device class to battery, the unit of measurement to %, then use the following template, to linearly create a % battery sensor based on the voltage reading.
{% set vmax = 9.0 %}
{% set vmin = 8.0 %}
{% set v = states('sensor.your_sensor_here') | float %}
{% if v > vmax -%}
100.0
{%- else -%}
{{(v-vmin)/(vmax-vmin)*100}}
{%- endif %}
Youāll need to define vmax, vmin and the sensor entity to suit your sensor.
This should generate a new sensor that the blueprint can see.
I should add, youāll need to do this for each sensor that you want to generate a battery % for.
Hello @dave_t_uk
Thanks for answering here and for the tip with example code.
As a workaround solution, this could effectively work, but it would be a hassle for every single sensor and wouldnāt be a particularly smart solution
Letās see how many sensors are affected in the end and whether I will solve it with a template sensor.
A battery control panel in HA or an add-on that would be dedicated to battery monitoring would be a great and certainly useful thing, because there are likely to be a lot of battery-operated devices in every smart home.
best regards
I came across this post almost by accident and compared the template I had written some time ago for battery control. Instead of individually excluding entities from automation (generally mobile devices with companion app installed) I directly excluded the āmobile_appā integration.
{% set class = states.sensor | selectattr('attributes.device_class', 'defined') | selectattr('attributes.device_class', 'eq', 'battery') | rejectattr('state','in',['unavailable','unknown']) %}
{% set low_battery_sensors = namespace(sensors=[]) %}
{% for battery in class %}
{% if not battery.entity_id in integration_entities('mobile_app') and battery.state | int (0) <= states('input_number.low_battery') | int and battery.state | int (0) != 0 %}
{% set low_battery_sensors.sensors = low_battery_sensors.sensors + [ battery.name + ' ' + battery.state + '%' ] %}
{% endif %}
{% endfor %}
{{ low_battery_sensors.sensors }}
this the template I use with helper input_number.low_battery. I hope it can be useful
Now that To-Do List are a thing I want to add all the batteries below 20% to my shopping cart but the problem is that ii will keep adding the same item over and over everyday, also, Itāll be nice to be able to add each battery as an individual item to the list.
How do I know which version I have installed of this Blueprint, it doesnāt say anywhere and I donāt know how to update it. The Github page doesnāt show it either in the code.
Also not sure what the ACTION section is used for? I get the notification on my mobile with correct batteries listed, but I have nothing in my ACTION section.
Is there a way to get a list of devices shown in the dashboard?
I rather see it in the dashboard, then getting notified every week (to much notifications already).
I have a set of sensors - plenty of them, all packed in one automation based on this great blueprint. Three of them need a lower Battery warning level threshold, as the one used in the automation is a bit too high for those - triggering the notification unnecessarily.
Trying to avoid excluding those 3 and creating another automation for them. Is there a way in the Actions section to handle such cases? Maybe by using and rejecting the specific entities in the sensor with a bit of templating?
Like āif only sensors a, b or c are low, do nothing. Otherwise, do the regular stuff (send notification etc.)ā:
Thanks for a great blueprint! I had originally looked at doing something similar with a binary sensor with attribute list of the battery sensors below the threshold (with an automation triggered by that binary sensor) but I like the idea of only checking on a regular schedule instead of having code evaluated every time any of dozens of battery sensors change state.
But the reason I am posting here is that Iām cleaning up my HA configuration and I realized that I forked your code almost a year ago and created my own custom blueprint with various modifications but I never shared that with you. You can see my code in this git.
Here are the mods I made:
- changed results list delimiter from comma to newlines
- added persistent notification action (but still support additional actions)
- excludes mobile device battery sensors (adapted from blueprint by Marck)
@codechimp Thank you for jumping in! I did not realize that may of my devices had battery_size as an attribute before installing Battery Notes! Iāll update my previous post.
This is OUTSTANDING. I use UI-Minimalist, and have a screen for battery levels which hase them grouped by room and animated icons for cell phones that are charging and the like. It is very convenient, and I am sure to add to it whenever I get any new sensors that is battery-based, but it is tedious - and i only have to do it once however. So I love the idea of automating it and only showing items that have low battery levels, but then you always think in the back of your mind what about the other ones (even if offline)ā¦ iād really like to always see all of them et ceteraā¦ Keep up the great work however this works best for me. It would be great to automate building a ui minimalist screen like what I am doing but once itās set up then you donāt need to bother signing it up again so the idea of automating it is getting diminishing returns for your effortsā¦