#Chip Card state color

1 messages · Page 1 of 1 (latest)

thorn raven
#

I accidently forgot to save what you showed me but it did the same thing regardless

golden cairn
#

So this code matches the screenshot?

thorn raven
#

Yep. Other than the front door dection is now missing instead of teh random cirlce to the right

golden cairn
#

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

thorn raven
#

That worked!

#

Sorry Im such an idiot. Trying to learn this the best I can.

golden cairn
#
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```
thorn raven
#

Thank you so much for your help

golden cairn
#

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.

thorn raven
#

This is awesome. I think I am getting it now.

golden cairn
#

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.

thorn raven
#

That's good to know

golden cairn
#

So, I just learned something new...

thorn raven
#

Oh?

golden cairn
#

managed to change the color of the background and text. Though, at this point is doesn't react to state. ...Yet.

thorn raven
#

That's pretty cool.

golden cairn
#
      - 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 %};
            }```
thorn raven
#

Im stealing this lol