Consolidated battery level view and notifications

A standard built infeature to show all battery powered devices battery level and the abillity to send notifications on battery low event.

Today this is only possible by “brute force” by either config (one per sensor) or looping all attributes.

A suggestion would be to use the battery_level attribute that is already available in the UI to avoid extra resource use.

There will be some components that need updating for this, since the likes of OwnTracks and GPS Logger report it as battery. That said, a native capability for all devices that report a battery level would be a really powerful thing, rather than each component having to develop their own functionality.

This would be a great feature!

Maybe battery_level would be more suited then?

Check out the thread linked below. It requires the least amount of effort to monitor batteries.

Thanks for the suggestion @NotoriousBDG, however this feature request is to make a native standard battery monitoring that all components should be compatible without any configuration from the user.

1 Like

We already have the attribute battery_level for entities that support it. The problem is that many entities only provide a flag for battery_low. It is easy to create a simple sensor like this. and use it in an automation like this to create a persistent notification.

I had an entity that didn’t give a percentage but a voltage level. Once I knew the bounds I could convert this to a battery level with a template sensor. Perhaps it will help someone. Change the float values to your own bounds.

fridge_battery_level:
      friendly_name: 'Battery Level'
      unit_of_measurement: '%'
      value_template: >
            {% set battery_level = states.sensor.fridge_tempf.attributes.voltage | default(0) | float %}
            {% set margin = 2.95 - 2.45 %}
            {% set level = battery_level - 2.45 %}
            {% set battery_round = ((level / margin) * 10) | round * 10 %}
            {{ battery_round }}
      icon_template: >
            {% set battery_level = states.sensor.fridge_tempf.attributes.voltage | default(0) | float %}
            {% set margin = 2.95 - 2.45 %}
            {% set level = battery_level - 2.45 %}
            {% set battery_round = ((level / margin) * 10) | round * 10 %}
            {% if battery_round >= 100 %}
              mdi:battery
            {% elif battery_round > 10 %}
              mdi:battery-{{ battery_round }}
            {% else %}
              mdi:battery-alert
            {% endif %}
      entity_id:
        - sensor.fridge_tempf
1 Like

Is this in the Home Assistant Configuration.yaml or device the sensor settings. I am trying to measure the Battery percentage based on voltage for my UPS. I am using a esp8266 with esphome to get the voltage values. I am trying to achieve the same as you

home assistant config, its a template sensor.

1 Like