#Chip Card state color
1 messages · Page 1 of 1 (latest)
So this code matches the screenshot?
Yep. Other than the front door dection is now missing instead of teh random cirlce to the right
Line 13, change content to name.
I'm not familiar with content_info from line 18. (doesn't appear to do anything though).
add icon: mdi:door
type: horizontal-stack
cards:
- type: custom:mushroom-chips-card
chips:
- type: template
entity: binary_sensor.living_room_door_on_off
icon_color: |-
{% if is_state (entity, 'on') %}
green
{% else %}
red
{% endif %}
content: Front Door
tap_action:
action: toggle
hold_action:
action: more-info
icon: mdi:door```
Now that that is working, let's condense the color and make the icon, color, and name work together.
content: |
{{ ((states(entity)) == 'on') | iif("open", "closed") }}
icon: |
{{ ((states(entity)) == 'on') | iif("mdi:door-open",
"mdi:door-closed") }}
icon_color: |
{{ ((states(entity)) == 'on') | iif('red', 'green') }}```
You can leave out content: if you don't want it to change and just keep the Front Door.
This is awesome. I think I am getting it now.
with some cards, such as Mushroom and custom:button-cards, if you define an entity:, you can reference the variable entity without having to repeat the actual entity name.
That's good to know
So, I just learned something new...
Oh?
managed to change the color of the background and text. Though, at this point is doesn't react to state. ...Yet.
That's pretty cool.
- type: template
entity: binary_sensor.living_room_door_on_off
icon_color: |
{{ ((states(entity)) == 'on') | iif("green","red") }}
icon: |
{{ ((states(entity)) == 'on') | iif("mdi:door-closed","mdi:door-open") }}
content: Front Door
tap_action:
action: toggle
hold_action:
action: more-info
card_mod:
style: |
ha-card {
{% set entity = 'binary_sensor.living_room_door_on_off' %}
--text-color:
{% if is_state (entity, 'on') %} green
{% else %} red
{% endif %};
--chip-background:
{% if is_state (entity, 'on') %} none
{% else %} rgba(255,0,0,0.1)
{% endif %};
}```
Im stealing this lol