Conditional Icon #1051
-
Whether for the primary button or a secondary button is there a way to set the icon and color based on if statement. For instance, If temperature is less than 68 degrees show mdi:snowflake, and if temperature is greater then 74 degrees show the fire icon. Then associate a color with a similar statement |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Have a look at #927 (comment) OR even better Basicly adap this code to your needs
If this solves your question, mark it as solved and close the discussion. |
Beta Was this translation helpful? Give feedback.
-
Can you put multiple strings for each of the states if the device has multiple?
Aaron Bianucci
On Dec 15, 2024, at 17:17, MrBearPresident ***@***.***> wrote:
Have a look at #927 (comment)<#927 (comment)>
OR even better
https://github.com/Clooos/Bubble-Card?tab=readme-ov-file#examples-7
Basicly adap this code to your needs
${subButtonIcon[0].setAttribute("icon",hass.states['input_boolean.help_house_testboolean'].state === 'on' ?
'mdi:lightbulb-group' : 'mdi:lightbulb-off')}
active')}
…________________________________
If this solves your question, mark it as solved and close the discussion.
—
Reply to this email directly, view it on GitHub<#1051 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ARDUN3JUYLKHAFJ7VB7NT4L2FYEXLAVCNFSM6AAAAABTU7JDVWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNJXGUYDSNQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Were you able to get it working? |
Beta Was this translation helpful? Give feedback.
-
I have for one state, for instance changing the icon when the state is on. However if I layer states, it only picks up the last one in the group.
SO based on the issue you linked I was leveraging something along the lines of
${subButtonIcon[1].setAttribute("icon", hass.states['binary_sensor.sliding_door'].state === 'unavailable' ? 'mdi:alert' : 'mdi:door')}
If I layered multiple statements, it just picks up which ever one is last and ignores all the ones prior to it. If I try and remove the :'mdi:door' and replace it with '' or just remove it, then it provides no icon.
…________________________________
From: MrBearPresident ***@***.***>
Sent: Monday, December 16, 2024 6:25 PM
To: Clooos/Bubble-Card ***@***.***>
Cc: Aaron Bianucci ***@***.***>; Author ***@***.***>
Subject: Re: [Clooos/Bubble-Card] Conditional Icon (Discussion #1051)
Were you able to get it working?
—
Reply to this email directly, view it on GitHub<#1051 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ARDUN3PUJSSJNJY34YTGKRT2F5VQZAVCNFSM6AAAAABTU7JDVWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNJYG4YTKOI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
You should handle it in one action, like this:
If this solves your problem, mark this as the solution and close the discussion.