If your device lacks a native battery percentage sensor, you can create one using a template. Test your template in the Home Assistant Developer Tools > Template section before applying it to the Battery Notes configuration.
Example: Linear voltage to percentage
For a sensor where 3V = 100% and 0V = 0%:
{% set v = states('sensor.my_sensor_voltage') %}
{{
(v | float / 3 * 100) | round(0)
if v not in ['unknown','unavailable'] else 'unknown'
}}
Example: Non-linear voltage to percentage
For a sensor where 3V = 100% but 2V = 10%:
{% set v = states('sensor.my_sensor_voltage') %}
{{
(((v | float - 2) / (3 - 2)) * 90 + 10) | round(0)
if v not in ['unknown','unavailable'] else 'unknown'
}}
Example: Binary low sensor
If a binary sensor indicates low battery (returning 100% or 9%):
{{ 9 if states('binary_sensor.my_sensor_low') == true else 100 }}
{% set v = states('sensor.my_sensor_voltage') %}
{{
(v | float / 3 * 100) | round(0)
if v not in ['unknown','unavailable'] else 'unknown'
}}
{% set v = states('sensor.my_sensor_voltage') %}
{{
(((v | float - 2) / (3 - 2)) * 90 + 10) | round(0)
if v not in ['unknown','unavailable'] else 'unknown'
}}
{{ 9 if states('binary_sensor.my_sensor_low') == true else 100 }}