Mushroom chips card (conditional) wont display chosen color when off

Hi!

I’m trying to set up a mushroom chips card with coditional logic to show if our livingroom tv is on or not.

This is the yaml fort it:

type: custom:mushroom-chips-card
chips:
  - type: conditional
    conditions:
      - entity: input_boolean.v_rum_tv_state
        state: 'on'
    chip:
      type: entity
      entity: input_boolean.v_rum_tv_state
      icon_color: green
      tap_action:
        action: none
      hold_action:
        action: none
      double_tap_action:
        action: none
  - type: conditional
    conditions:
      - entity: input_boolean.v_rum_tv_state
        state: 'off'
    chip:
      type: entity
      entity: input_boolean.v_rum_tv_state
      icon_color: red
      tap_action:
        action: none
      hold_action:
        action: none
      double_tap_action:
        action: none
alignment: center

It works when the state is “on”, then the icon becomes green but when state is “off” the icon becomes white.

Cant understand why it doesnt want to go red like ive set it up to be.

Please help…

For Entity it’s depended on the state I believe, so colored if it’s ‘on’ and else not showing the color. Depended on the type of entity you use. You could use a template card and set the color based on the state manually and gain full control.

{% if is_state('binary_sensor.deur_tuin_sensor_open', 'on') %}
  red
{% else %} 
  grey
{% endif %}

Actually can be used to also change the icon basd on the state. For example I use a open icon when the door is open vs when it is closed.

{% if is_state('binary_sensor.deur_tuin_sensor_open', 'on') %}
  mdi:door-sliding-open
{% else %} 
  mdi:door-sliding
{% endif %}

Full yaml (not of a chip, but you can also do this for a chip, pick the template one).

type: custom:mushroom-template-card
primary: Tuindeur
secondary: |-
  {% if is_state('binary_sensor.deur_tuin_sensor_open', 'on') %}
    Open
  {% else %} 
    Dicht
  {% endif %}
icon: |-
  {% if is_state('binary_sensor.deur_tuin_sensor_open', 'on') %}
    mdi:door-sliding-open
  {% else %} 
    mdi:door-sliding
  {% endif %}
entity: binary_sensor.deur_tuin_sensor_open
icon_color: |-
  {% if is_state('binary_sensor.deur_tuin_sensor_open', 'on') %}
    red
  {% else %} 
    grey
  {% endif %}
badge_icon: |-
  {% if is_state('binary_sensor.tuin_global_motion_sensor', 'on')
  or is_state('binary_sensor.schuur_sensor_motion', 'on')
  %}
  mdi:motion-sensor
  {% endif %}
badge_color: light-green

1 Like

Cool!

Thanks for your quick answer, I’m gonna try that :+1::+1:

1 Like

I’m trying to do the same thing and have the following code:

  - type: custom:mushroom-chips-card
    chips:
      - type: entity
        entity: binary_sensor.badezimmer_fenster
        name: Fenster
        icon: |-
          {% if is_state('binary_sensor.badezimmer_fenster', 'on') %}
            mdi:window-open-variant
          {% else %} 
            mdi:window-closed-variant
          {% endif %}

The dashboard does not show any icon when using the code. Can anyone help me figuring out what is wrong?

Anyone who can help me here?

Try using the template chip in mushroom. Here’s an example of mine:

type: custom:mushroom-chips-card
chips:
  - type: entity
    entity: binary_sensor.aqara_lumi_motion_ac01_occupancy_3
    content_info: none
  - type: entity
    entity: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
    content_info: none
  - type: entity
    entity: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
    content_info: none
  - type: template
    icon: |-
      {% if is_state('switch.innr_sp_222_switch', 'on') %}
        mdi:wall-sconce
      {% else %} 
        mdi:wall-sconce-outline
      {% endif %}
    entity: switch.innr_sp_222_switch
    tap_action:
      action: toggle
  - type: template
    icon: |-
      {% if is_state('automation.bedroom_heating', 'on') %}
        mdi:thermometer-auto
      {% else %} 
        mdi:thermometer-off
      {% endif %}
    entity: automation.bedroom_heating
    tap_action:
      action: toggle
alignment: justify

note the last two items. For example the lamp icon looks like this:


1 Like