I’m using the custom-banner-card in for my tablet dashboard. I’ve got a lights-on-counter which is displayed within this card. But I would like to have the light counter in front of the icon.
It’s like this now:
I want it to look like this:
The counter for the lights obviously works:
lightson_kantoor:
friendly_name: lightson_kantoor
value_template: >
{% set ns = namespace(res=0) %}
{% for light in state_attr('group.Kantoor', 'entity_id') if is_state(light, 'on') %}
{% set ns.res = ns.res + 1 %}
{%endfor%}
{{ ns.res }}
Now I’ve created a second sensor as a test to combine this number with icon like this:
Can you think of a work-around to get the same result? Because you stated:
Home Assistant won’t convert the mdi icon code into an icon character for a Template Sensor’s value_template .
But it actually does do that, only not when I want to combine it with the sensor, but it does show the icon perfectly when that’s the only result defined.
In that case, you can’t combine the name of an mdi icon with other text and expect each part of the resulting text string to be interpreted separately. The entire string is interpreted by Home Assistant.
I’ve never tried this (and I suspect it won’t work) but you can try to add the icon code to the Template Sensor’s unit_of_measurement. Most cards display an entity’s state value followed by its unit of measurement.