Error in showing Entity battery % - how to know if it has been fixed

I got this error, and I think I fixed it, by adding “unit of measurement”. how can I ask HA to check if the error has been fixed. will I only know by checking the error logs?

First occurred: May 11, 2023 at 12:24:46 PM (11 occurrences)
Last logged: May 11, 2023 at 12:24:46 PM

  • Entity sensor.door_room6_exit_batt_low (<class ‘homeassistant.components.template.sensor.SensorTemplate’>) is using native unit of measurement ‘None’ which is not a valid unit for the device class (‘battery’) it is using; expected one of [’%’]; Please update your configuration if your entity is manually configured,…
# Battery sensors to show batt_low on AD building map
 - platform: template
   sensors:
     door_room6_exit_batt_low:
       friendly_name: "Door Room 6 Exit Batt Low"
       value_template: "{{ states('sensor.door_room6_exit_battery') | int <= 15 }}"
       device_class: battery
       unit_of_measurement: '%'

That template returns true or false. You can not add a unit of measurement. You can not use the battery device class. Both require a numeric value.

You should be using a binary template sensor.

1 Like

Could I remove device class and unit of measurement? I only used this template for my picture entity dashboard to show a low battery symbol. I just added unit_of_measurement because I was getting an error in the logs.

You got the error because you used device_class: battery for an entity that is not showing a number. Why not just use the sensor.door_room6_exit_battery on your dashboard?

Alternatively,

template:
  - binary_sensor:
      - name: "Door Room 6 Exit Batt Low"
        state: "{{ states('sensor.door_room6_exit_battery') | int(0) <= 15 }}"
        icon: "{{ mdi:battery-alert-variant-outline if states('sensor.door_room6_exit_battery') | int(0) <= 15 else mdi:battery-50 }}"

Because I needed a true or false to show the low battery symbol. I’m sure there is a better way of doing this. This is just what I stumbled upon.

      - type: image
        entity: sensor.window_acad_boys_rr_batt_low
        image: /local/batt_low_blank.png
        state_image:
          'True': /local/batt_low.png
        style:
          left: 56.6%
          top: 5%
          width: 3%