woempiej
(Woempiej)
August 14, 2022, 1:15pm
2331
Hi all,
Can someone help me to set the icon color of the Mushroom template card based on temperature value?
Something like:
Normal color = blue < 15°C
If temperature sensor is > 15°C then orange color
if temperature sensor is > 25°C then red color
Here’s an example of what I use in a mushroom template card
icon_color: >-
{% if (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'home') %} green
{% elif (state_attr('sensor.john','direction_of_travel') == 'stationary') and (states('device_tracker.sm_f926u1') == 'not_home') %} blue
{% else %} cyan
{% endif %}
You can modify that to work for you
2 Likes
image969
(James Scialdone)
August 14, 2022, 2:22pm
2334
Any idea why I can’t get the Stackin card to work? I installed it through HACS I cleared my cache restarted Home Assistant like I do every time I add something and this isn’t showing up. Is there a prerequisite that I need before this works?
KTibow
(Kendell R)
August 14, 2022, 2:23pm
2335
Could you expand on what you mean by “this isn’t showing up”? Does it say it’s not loaded in HACS? Could you send a screenshot of any relevant error messages?
image969
(James Scialdone)
August 14, 2022, 2:41pm
2336
It shows it’s installed in HACS. But when I go to add card, I cannot find this custom stack in card. Only the horizontal and vertical
KTibow
(Kendell R)
August 14, 2022, 2:42pm
2337
It’s not configurable in the UI.
image969
(James Scialdone)
August 14, 2022, 2:45pm
2338
What does that mean? I tried manually typign in type: ‘custom:stack-in-card’ and i get
Configuration errors detected:
Custom element not found: stack-in-car
KTibow
(Kendell R)
August 14, 2022, 2:47pm
2339
Keep typing and adding configuration, the error will go away.
1 Like
image969
(James Scialdone)
August 14, 2022, 2:48pm
2340
So it’w normal that I dont see it listed under “add card”
KTibow
(Kendell R)
August 14, 2022, 2:50pm
2341
Yes. It’s documented as being that way.
image969
(James Scialdone)
August 14, 2022, 2:51pm
2342
AH well apparently I should learn how to read then lol I got it working. Thank you
image969
(James Scialdone)
August 14, 2022, 3:12pm
2343
Actually Could I ask you one more that I haven’t been able to get an answer to? Ever since updating mushroom tp use climate card. This is what I get. But I’d I pull down on my phone or refresh I. My browser it works. And looks perfect . But every once and a while I get this error again and have to pull to refresh.
I’ve updated hole assistant since then I’ve cleared cache restarted etc.
KTibow
(Kendell R)
August 14, 2022, 3:14pm
2344
Not sure what causes that to happen, maybe someone else would know. It’s happened to me sometimes too.
theandouz
(Theandouz)
August 14, 2022, 3:35pm
2345
Yea definitely here you go!
type: custom:vertical-stack-in-card
cards:
- type: custom:mushroom-template-card
primary: Front Door
secondary: >-
{% if is_state('lock.front_door','unlocked') and
is_state('binary_sensor.front_door_alarm_sensor','on') %}
Open and Unlocked
{% elif is_state('binary_sensor.front_door_alarm_sensor','on') %}
Door Open
{% elif is_state('lock.front_door','unlocked') %}
Unlocked
{% else %}
Locked
{% endif%}
icon: >-
{% if is_state('lock.front_door','unlocked') and
is_state('binary_sensor.front_door_alarm_sensor','on') %}
mdi:door-open
{% elif is_state('binary_sensor.front_door_alarm_sensor','on') %}
mdi:door-open
{% elif is_state('lock.front_door','unlocked') %}
mdi:lock-open
{% else %}
mdi:lock
{% endif%}
layout: vertical
icon_color: >-
{% if is_state('lock.front_door','locked') and
is_state('binary_sensor.front_door_alarm_sensor','off') %}
green
{% else %}
red
{% endif%}
badge_icon: >-
{% set battery_level = (states('sensor.front_door_battery') | int / 10) |
round(0) | int * 10 %} {% if battery_level < 20 %}
mdi:battery-{{ battery_level }}
{% elif battery_level < 5 %}
mdi:battery-alert-variant-outline
{% else %} {% endif %}
badge_color: |-
{% set battery_level = states('sensor.front_door_battery') %}
{% if battery_level < '20' %}
orange
{% elif battery_level < '5' %}
red
{% else %}
{% endif %}
tap_action:
action: none
card_mod:
style: |
ha-card {
background: none;
box-shadow: none;
}
- type: custom:mushroom-lock-card
entity: lock.front_door
name: Laundry Room Door
primary_info: none
secondary_info: none
icon_type: none
layout: vertical
card_mod:
style: |
ha-card {
background: none;
box-shadow: none;
}
card_mod:
style: |
ha-card {
{% if is_state('lock.front_door','locked') and
is_state('binary_sensor.front_door_alarm_sensor','off') %}
background: rgba(101,170,91,0.1);
{% else %}
background: rgba(226,84,66,0.1);
{% endif %}
}
4 Likes
woempiej
(Woempiej)
August 14, 2022, 3:54pm
2346
Thanks, but I do not see the logics to use it with a temperature sensor.
I now configured below:
icon_color: >-
{% if (state_attr('sensor.woonkamer_temperature','temperature') == '> 15') %} green
{% elif (state_attr('sensor.woonkamer_temperature','temperature') == '> 20') %} blue
{% else %} cyan
{% endif %}
The temp sensor right now shows 27.8°C but the color stays cyan.
1 Like
KTibow
(Kendell R)
August 14, 2022, 3:56pm
2347
== '> 20'
is improper syntax. You probably want something like > 20
. I think you might be looking for the state, not an attribute, so you might also want to change the state_attr
part too.
2 Likes
woempiej
(Woempiej)
August 14, 2022, 4:45pm
2348
Oke I am messing around for hours but can’t get it to work
Maybe it is not possible @ all?
KTibow
(Kendell R)
August 14, 2022, 4:51pm
2351
Try adding | int
after the ) of the states
function.
2 Likes