Template Card Badge Icon template #1059
Unanswered
SteveDockar
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder if anyone can help me here? 😃 I'm struggling to select/set the badge icon of my mushroom template card with a template.
I have a "number of people home" card which currently has my sensor.people_home_count in the secondary information field in an {% if/elif/else/endif %} for "nobody home", "one person home or "'n' people home" strings.
I'm trying to add the number in a badge. I can set the badge color with a similar if/else flow, but can't set the icon. I'm trying to use mdi:numeric-X icons for the number(s). The Mushroom docs say the field should support templates but I can't get it to work.
Ideally I'd like to have a single {{ "mdi:numeric-" + states('sensor.people_home_count') }} to select the appropriate icon, but that doesn't seem to work. The Dev-Tools template page suggests it is outputting the correct string for the icon but I wondered if this just won't work in the way I'd hoped. So, I switched to an if/else flow to select the icon name based on the sensor value, but that doesn't seem to work either. If I remove all the logic and just leave the mdi:numeric-0 icon (or whichever) name it pops up, statically of course, as expected. I'm not sure if I hit a bug, or I'm just doing something wrong.
Any help, gratefully received.
Beta Was this translation helpful? Give feedback.
All reactions