Change colour in secondary-info entity card [multiple-entity-row]

Hey!

I just experienced that some of my temperature sensors went down, without me knowing about it - since they got stuck at the last value read.
So, to fix this - i wan’t a “panel” where u can see when they last updated and the battery state. Said and done, as the picture shows.

But here’s the problem - since it’s easy to miss if it says “1 day ago” or “1 hour ago” i wan’t the secoundary text to be red if it’s been over 12h since last update.

I have tried multiple codes getting this to work, but i can’t seem to get it working.
The last code i have tried is this one;

type: entities
entities:
  - entity: sensor.badrum_temperature
    type: custom:multiple-entity-row
    name: Tempgivare Hall
    secondary_info: last-changed
    show_state: false
    entities:
      - entity: sensor.tempgivare_hall_batteri
        name: Batteri
    style:
      '--secondary-text-color': >
        {% set last_updated = state_attr('sensor.badrum_temperature', 'last_updated') %}
        {% set time_difference = (now() - last_updated).total_seconds() / 60 %}
        {% if time_difference > 2 %}
          red
        {% else %}
          inherit
        {% endif %}

But it won’t work, i also tried just

   style:
      '--secondary-text-color': red

But it still won’t change the colour to red.

Thankful for all the help i can get!
sensors

  1. You are trying to use card-mod. Suggest to ask similar questions in the dedicated huge card-mod thread. You may attract more card-mod users & share your experience with them; also, all solutions will be kept in one place instead of being scattered in 100500 places.
  2. How to style m-e-r by card-mod: go to the mentioned card-mod thread → 1st post → link at the bottom → styles for m-e-r.

Thank you for the reply, and your clarification in the card-mod thread.
My experience with posting in large threads is that it just gets spammed away, and since i didn’t think the card used card-mod, i didn’t post there - but i will post there from now, thank you.

This is not a crime, I just expressed my opinion about organizing the Community.
In many cases users ask a question like “How can I change something” - and card-mod can be ONE of possible solutions, not always the best.
But since you expressed an intention to use card-mod - I reacted that way.
See you in card-mod thread!

1 Like

Solved, in Card-mod thread by @Ildar_Gabdullin

1 Like