🔹 Card-mod - Add css styles to any lovelace card

set the color of my card manually

background: url('/local/images/aloe.png'), linear-gradient(to right, transparent, #313244 50%);


1 Like

I have no clue. I was in the same situation. I used the double editing method:

image

then

image

Then seach for style: with

card_mod:
  style:

ready in my clipboard and started the tedious replacement…

Im no good at card mod… is it possible to remove ‘Last recognised face changed to’ from here?

Not possible with card-mod.
Consider custom:logbook-card.

1 Like

I thought i may have had that wrong, thanks for the pointer

Thanks for all the help, that’s very helpful

Release note

  1. Never ever post an unformatted code. You can see yourself that your code is unreadable. Compare your post with other posts with codes.
  2. You have been already advised to read release notes. Also, check other examples on card-mod github & compare with yours. You should learn & become a card-mod guru, not just copy/paste.
1 Like

HI sorry

  - entity: alarm_control_panel.mieszkanie
    card_mod: null
    style: |
      :host {
        {% if is_state('alarm_control_panel.mieszkanie', 'disarmed') %}
          label-badge-background-color: green;
          --label-badge-red: green;
        {% else %}
          label-badge-background-color: red;
          --label-badge-red: red;
        {% endif %}
      }

Not working always showing RED

See yourself. Compare with examples. Also, “null” value is rather unusual & tells about an error which you need to fix.

I checked it before , when I remove null and save after edit showing again

Means - this “null” is set automatically because of some problems with the code. Now compare your code with examples.

I dont understand You
example

  - entity: light.kitchen_lights
    card_mod:
      style: |
        :host {
          color: blue;
        }

my code

  - entity: alarm_control_panel.mieszkanie
    card_mod: null
    style: |
      :host {
        {% if is_state('alarm_control_panel.mieszkanie', 'disarmed') %}
          label-badge-background-color: green;
          --label-badge-red: green;
        {% else %}
          label-badge-background-color: red;

and before upgrade to last version all was working

Check indentation which is important in yaml.

Really? Then compare again. Is card_mod and style in both examples in eqal places and with the same indentation?

indentation is as always important.

thx
working now

Is it right to loose every card_mod addition if editing an entry via gui and visual editor?
In the second the VE opens the card_mod is on vacation to dev/null or so.
How to prevent it?

There is an open issue for this.

Hello together,

I would like to change the color of my blind icon to orange in case my blind is not ‘closed’. Somehow I managed the code but it does not update once the status is changing, the color will stay even status changed. Only via browser refresh the color will change accordingly. Many thanks for support upfront!

My questions:

  1. In general: As I would like to change the icon color of all blinds in case not ‘closed’ is there a “smarter” way to achieve this than using card-mod where I have to add this code in every place? Maybe via theme somehow centrally?
  2. If not and card-mod is the only available option… what I’m doing wrong as a status change will not change the icon color again?

My code

type: vertical-stack
title: Rollläden
cards:
  - type: custom:mushroom-cover-card
    entity: cover.hausrollladen
    tap_action:
      action: more-info
    double_tap_action:
      action: toggle
    show_position_control: false
    show_buttons_control: false
    card_mod:
      style:
        mushroom-shape-icon$: |
          .shape {
            background: none !important;
          }
          :host {          
            {% if states('cover.hausrollladen')!='closed' %}
              --card-mod-icon-color: orange;
            {% endif %}
          }

@RkcCorian There are two methods you can use. Keep the Mushroom template card with something similar to this:

type: vertical-stack
title: Rollläden
cards:
      - type: custom:mushroom-template-card
        entity: cover.hausrollladen
        icon: mdi:blinds-horizontal
        primary: Your Device
        secondary: |
          {% if is_state(config.entity, 'open') %} Open
          {% else %}
           Closed
          {% endif %}        
        tap_action:
          action: more-info
        double_tap_action:
          action: toggle
        icon_color: >
          {% if is_state(config.entity, 'open') %}
          orange
          {% else %}
          {% endif %}
        card_mod:
          style:
            mushroom-shape-icon$: |
              .shape {
                background: none !important;
                }

or just use the Mushroom-Cover-Card like this:

      - type: custom:mushroom-cover-card
        entity: cover.pc_curtains
        show_position_control: true
        show_tilt_position_control: false
        show_buttons_control: true
        layout: horizontal
        card_mod:
          style:
           mushroom-shape-icon$: |
              .shape {
               background: none !important;
                } 
           .: |
              ha-state-icon {
               color: {% if is_state(config.entity, 'open') %} orange
               {% else %}
               {% endif %};
               background: none !important; 
                            }
              ha-card {                 
                background: none !important; 
                 }

image

1 Like