The Code below always worked but it stopped creating a red icon when my Fan turns to mode Perm. High.
Who can help me with this.
Sorry but forgot how to put code in the right way.
<
entity: sensor.duco_ventilation_mode
name: Mode
card_mod:
style: |
:host {
–paper-item-icon-color:
{% if states(config.entity) == ‘Perm. High’ %} red
{% else %} var(–paper-item-icon-color)
{% endif %};
}
complex1
(Frank)
December 31, 2023, 10:53am
2
Ask your question in English, then you have a better chance of getting an answer.
Please read the forum rules.
Before we begin…
This forum is not a helpdesk
The people here don’t work for Home Assistant, that’s an open source project. We are volunteering our free time to help others. Not all topics may get an answer, never mind one that helps you solve your problem.
[image]
This also isn’t a general home automation forum, this is a forum for Home Assistant and things related to it. Any question about Home Assistant, and about using things with Home Assistant, is welcome here. We can’t help you with e…
Place it into triple “`” (right below ESC).
Olivier1974
(Olivier Toussaint)
January 1, 2024, 12:33pm
7
Assuming your code is an entities card, then this is the working code with one of my sensors.
type: entities
entities:
- entity: sensor.kodi_cpu_temp
name: Mode
card_mod:
style: |
:host {
--paper-item-icon-color:
{% if states(config.entity) | float(0) <= 50 %}
var(--paper-item-icon-color);
{%else%}
red;
{% endif %}
}
If it is a different card type then this will not work obviously.
Suggest you to not use this syntax (and not advise it).
type: entities
entities:
- entity: sensor.kodi_cpu_temp
name: Mode
card_mod:
style: |
:host {
{% if ... -%}
--paper-item-icon-color: green;
{%- else -%}
--paper-item-icon-color: red;
{%- endif %}
}
More flexible. Less space in DOM.
P.S. Happy NY btw. Although it started with attacks from russians & hamas.
Olivier1974
(Olivier Toussaint)
January 1, 2024, 12:45pm
9
I know you did and I intentionally did not follow you because it is not the final code for @broekieman.and his code is formated that way so it is easier for him to compare and adjust.
1 Like
Agree. But we should “direct” beginners to better ways. As we were ourselves some time ago.
btw - this will not work.
--paper-item-icon-color: var(--paper-item-icon-color);
if no need to change the variable - just do not change.
Olivier1974
(Olivier Toussaint)
January 1, 2024, 12:58pm
12
Ildar_Gabdullin:
this will not work.
Really? It seems to work because it was the original icon color in my tests, but maybe because it is not understood
Olivier1974
(Olivier Toussaint)
January 1, 2024, 1:06pm
14
Then, indeed, you’re right, as there should be no code to keep the original color, then it is better to use the full syntax:
type: entities
entities:
- entity: sensor.duco_ventilation_mode
name: Mode
card_mod:
style: |
:host {
{% if ... -%}
--paper-item-icon-color: red;
{%- endif %}
}
right, w/o assigning the current value.
Can anyone help me to change color to Red when mode is Perm high?
Olivier1974
(Olivier Toussaint)
January 2, 2024, 1:35pm
18
Your code is unreadable, it is difficult to help you.
The solution is in front of your eyes in post #12 , you are not using the right tag.
it is
--paper-item-icon-color: red;
not
–paper-item-icon-color: red;
But might be a different issue, but impossible to tell as the indentation is screwed up not using the code formating.
Must have gone wrong with paste. I have:
--paper-item-icon-color: red;
This did not solve the problem. What can I try more?
broekieman:
What can I try more?
As it was already suggested - fix your post first.
Can’t you see yourself that it is unreadable?
1 Like