Icon template not showing correct icon

kinda like the floor/ceiling from yesterday :rofl::joy:

Haha! Exactly. :smile:

Anyway, it was an opportunity to satisfy my morning fix for solving a puzzle … even though it didn’t really need any ‘solving’!

Ha, thanks @petro we live and learn!

edit: never mind, figured it out.

I’ve replaced the template for one of my sensors with @petro suggestion and will see which ones works out the best.

The race is on!

Hi!

I share my template for a battery sensor:

sensors:
   battery_XYZ:
     friendly_name: 'Battery XYZ'
     value_template: "{{ state_attr('device_tracker.XYZ','battery_level') }}"
     unit_of_measurement: "%"
    icon_template: >-
       {% if states('sensor.battery_XYZ')|int >= 10 %}
         {{ 'mdi:battery-' ~ (states('sensor.battery_XYZ')|float / 10)|int ~ '0' }}
       {% else %}
         {{ 'mdi:battery-off-outline' }}
       {% endif %}

Thanks.

1 Like