Is it possible to change icon and color when the entity state is "unavailable"? #340
Replies: 6 comments 4 replies
-
You might want to take a look at icon conditions
…On Thu, Jul 25, 2024, 09:55 diegofrances ***@***.***> wrote:
Hello All,
I have some Sonoff S60TPF Smart Plugs that I would like to monitor using
the "info_entities:" option. I would like to know when the microwave is
idle, working and when there is an energy cut.
I came up with an idea and I have tried the below but does not seem to
recognize the "unavailable" state of the entity.
type: custom:room-card
title: Kitchen
info_entities:
- entity: sensor.sonoff_microwave_power
show_icon: true
icon:
template:
styles: >
if (entity.state == 'unavailable') return 'color: rgb(255, 0, 0)';
else if (entity.state > 90) return 'color: rgb(255, 165, 0)';
else if (entity.state < 90) return 'color: rgb(255, 0, 0)';
icon: >
if (entity.state == 'unavailable') return 'mdi:microwave-off';
else return 'mdi:microwave';
Is the "unavailable" state not part of "room-card" customization? If this
is the case, is there any other option?
Thank you in advance.
Regards,
Diego
—
Reply to this email directly, view it on GitHub
<#340>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOAAPNVRWOM3PYO27VRZUDZOCVQNAVCNFSM6AAAAABLN7NFCWVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWHE3TKNBVGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hello @marcokreeft87, Thank you for your quick answer and your suggestion. I have been able to change the icon based on the status of the entity; tested and works as expected. Please find what I have included on my card: type: custom:room-card
Unfortunately I am not able to combine icon type and color. Please find what I have tried. type: custom:room-card
The above shows the desired icon's color but the default entity's icon. If the entity state is "unavailable", icon has to be "mdi:microwave-off" and color red but if entity´s state is different from "unavailable" the icon has to be "mdi:microwave" and color orange if the value is above 90 and color green if the value is below 90. Can you please help me to achieve what I want/need? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
-
Tried the following but the unavailable state does not have the red color
|
Beta Was this translation helpful? Give feedback.
-
I trully believe that state is unavailable FYI: I've changed the name of the sensor on the previous posts just to make it easier |
Beta Was this translation helpful? Give feedback.
-
The card is able to identify the "unavailable" state as if I change it to something else, the icon is not changed to the right one. But sadly the color is not being honoured if the status is "unavailable". |
Beta Was this translation helpful? Give feedback.
-
No worries, I can wait until you come back from your holidays. I will keep trying. |
Beta Was this translation helpful? Give feedback.
-
Hello All,
I have some Sonoff S60TPF Smart Plugs that I would like to monitor using the "info_entities:" option. I would like to know when the microwave is idle, working and when there is an energy cut.
I came up with an idea and I have tried the below but does not seem to recognize the "unavailable" state of the entity.
type: custom:room-card
title: Kitchen
info_entities:
show_icon: true
icon:
template:
styles: >
if (entity.state == 'unavailable') return 'color: rgb(255, 0, 0)';
else if (entity.state > 90) return 'color: rgb(255, 165, 0)';
else if (entity.state < 90) return 'color: rgb(255, 0, 0)';
icon: >
if (entity.state == 'unavailable') return 'mdi:microwave-off';
else return 'mdi:microwave';
Is the "unavailable" state not part of "room-card" customization? If this is the case, is there any other option?
Thank you in advance.
Regards,
Diego
Beta Was this translation helpful? Give feedback.
All reactions