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

Still, you’re missing the operator. You’re not testing the state of your binary sensor against anything. If you look at Marius’ example, he’s got != ‘home_summary’ in his code. The first statement before the question mark should return a value of true or false, yours returns the state of your binary sensor.

@CDRX2 I do appreciate your responses. Maybe I am bringing too much past coding into play, but doesn’t the binary_sensor state itself evaluate to true or false. The code works if I negate the test, and put ! in front of my object. I am just wondering if manually setting the state in dev tools flows through to the app?
I did try ‘= true’ and still got the same behavior.

No worries. A binary_sensor in HA is always ‘on’ or ‘off’, so you won’t get true or false that way. Whether setting the state manually through dev tools flows through the app, I’m not sure. In my experience, once a state is set manually, it doesn’t stay on that manual input very long (about 10 seconds or so)…

Thanks. I’ll put the test back in. The active weather alert in our area ends at 8pm local tonight, so I will see if the tap_action goes to ‘none’ after that. If not, well then I will punt.

1 Like

yields what state you want to use to fire the DOM event?
My binary_sensors normally show ‘on’ or ‘off’. Maybe test for that explicitely?

[And yes, she’s a very cute and cuddly Border Collie mix. But she gives off fluff around the year… :blush:]

1 Like
tap_action:
   action: >
      [[[ return (states['binary_sensor.template_rndrck_alrt'].state == 'on')
        ? 'fire-dom-event' : 'none'; ]]]

would do it

Can you have the JS-Button-Card-discussion in another topic, as they are completely not related to card-mod? Neither JS, nor button card.

That worked!

Yes, sorry to co-op the thread

Is there a fix for this ?

I gave you a link to the issue on Github. You may contribute your observations for other cards in this issue.

Hello. I’m looking for help.
I’m trying to change the text color in the state badge according with the sensor state but can’t find the solution.
Can anyone help me?
That’s my configuration, and I want when the window is open(aberta) the color of the letters change to green.
Thanks!



styling picture-elements - see here

Hello,

I’m a complete novice so please excuse the potentially stupid question:

What I’m trying to do: I want to use an input_text to transfer the state (content) of that Helper via a script and MQTT into our Database (not supported by HA so we use MQTT).

So in a View I added an Entities-Card with this helper, now the text field for this is very small and here is where I was wondering if it’s possible to manipulate the size of the text field via card-mod? Any experience with that or thoughts on how it could be possibly done - or not done.

1st post → link at the bottom → post for input_text

1 Like

Lifesaver! Thank you so much!

Hi all,

I want to animate (blink) the entitiy icon within an entity card. With card-mod I was able to change the color of the font and the icon according to the entity status, but I am struggeling to figure out how I can add the blinking animation to the icon when the entity status is “ON”. I am not that good in CSS and therefore thankful for any hint.

Below my code:

type: entities
entities:
  - entity: input_boolean.ferien
    card_mod:
      style: |
        :host {
          color:
           {% if is_state('input_boolean.ferien', 'on') %}
           lightgreen
           {% elif is_state('input_boolean.ferien', 'off') %}
           white
           {% endif %};   
          --paper-item-icon-color:
          {% if is_state('input_boolean.ferien', 'on') %}
            lightgreen
          {% elif is_state('input_boolean.ferien', 'off') %}
            white
          {% endif %}
              }

Thanks for the feedback,
Aleardo

  1. Animation:
    see the post above yours - may be it will give some thoughts.

  2. “if … elif … endif” - safer to use “if … else … endif” or “if … elif … else … endif”.

:smiley: sorry have not seen that one. Brilliant work from your side. Thanks IIdar!!
Will give it a try…

1 Like

Following removal of some paper items in the frontend , specifically input_select, I’ve got an issue with some dropdowns that I can’t work out.
I have 2 entities cards on 1 row to set my alarm clock time, hours and minutes, prior to the change they looked like this;

Since updating to the current 2022.3.0b0 release and after some assistance from @Mariusthvdb on Discord, I’ve got the colors and fonts working as before but the input_selects no longer fits into the entities cards and look like this;

This is the yaml

 title: Alarm Clock
path: brad-alarm-clock
icon: custom:alarm-clock
cards:
  - type: vertical-stack
    cards:
      - type: custom:decluttering-card
        template: back-header-button
        variables:
          - path: brad-bedroom
      - type: custom:decluttering-card
        template: title-2
        variables:
          - title: Alarm Clock
      - type: horizontal-stack
        cards:
          - !include ../../includes/h-space-10.yaml
          - type: entities
            style: |
              ha-card {
                background: var(--button-background-color);
                border-radius: var(--border-radius);
                box-shadow: var(--box-shadow-static);
                font-family: var(--font-family);
                font-size: var(--font-size);
              }
            entities:
              - entity: sensor.time
                name: Current Time
                icon: custom:clock
              - entity: sensor.alarm_clock_time
                name: Alarm Time
                icon: custom:alarm-clock
          - !include ../../includes/h-space-15.yaml
      - !include ../../includes/v-space-10.yaml
      - type: horizontal-stack
        cards:
          - !include ../../includes/h-space-10.yaml
          - type: entities
            style: |
              ha-card {
                background: var(--button-background-color);
                border-radius: var(--border-radius);
                box-shadow: var(--box-shadow-static);
              }
            entities:
              - entity: input_select.alarm_clock_hour
                name: Hour
          - !include ../../includes/h-space-10.yaml
          - type: entities
            style: |
              ha-card {
                background: var(--button-background-color);
                border-radius: var(--border-radius);
                box-shadow: var(--box-shadow-static);
              }
            entities:
              - entity: input_select.alarm_clock_minute
                name: Minute
          - !include ../../includes/h-space-15.yaml

Is it now necessary to manually set a size for the input_select? If so, can someone please point me in the right direction?

Thanks

UPDATE:

I’ve added padding-right: 35px to each entity which has corrected the misalignment but would still be keen to know what is different with the new mdc-select element and the potential effects as more and more paper items are replaced.