Hello everyone,
based on the video from the great content creator Smart Home Junkie (HOW TO create your own Low Battery Warning Sensor In Home Assistant - TUTORIAL - YouTube) I´ve created a simplified version, for all of us that have devices without battery percentage (only battery voltage).
For this you only need a single number helper
And the following markdown card:
type: markdown
content: >-
{% for state in states
| selectattr('domain', 'in', ['sensor'])
| rejectattr('attributes.battery_voltage', 'undefined')
| selectattr('attributes.battery_voltage', 'lessthan', states('input_number.battery_threshold') | int / 10)
| sort(attribute='attributes.battery_voltage', reverse = True)
%}
{{
'* <ha-alert alert-type="error"><ha-icon
icon="mdi:battery-alert-variant-outline"></ha-icon> '
+ "(" + state.attributes.battery_voltage|string + "V)"
+ " [" + state.state + "%] "
+ state.name | replace(' battery', '') | replace(' Battery', '')| replace('
power', '') | replace(' Power', '')
+ "</ha-alert>"
}}
{%- endfor -%}
title: To Charge
This allows you to define the threshold value, for the voltage you “think” it´s worth charging/replacing the batteries on your device.
NOTE: For the calculation, the value is divided by 10, in order to have decimal values for the voltage (this is currently not available for the number helper)