thomasloven / lovelace-card-mod

🔹 Add CSS styles to (almost) any lovelace card
MIT License
1.12k stars 167 forks source link

Changing text of secondary info with card mod #166

Closed Tropaion closed 2 years ago

Tropaion commented 2 years ago

Hello, I don't if its possible or not, but I tried changing the secondary_info depending on value like this but I cant get i running:

        card_mod:
          style: |
            :host {
              secondary_info:
                {% if states('sensor.particulate_matter_2_5um_concentration') == 'unavailable' %}
                  gray
                {% elif states('sensor.particulate_matter_2_5um_concentration')|float(0) <= 12.0 %} 
                  green
                {% elif states('sensor.particulate_matter_2_5um_concentration')|float(0) > 12.0 and states('sensor.particulate_matter_2_5um_concentration')|float(0) <= 35.4 %}
                  yellow
                {% elif states('sensor.particulate_matter_2_5um_concentration')|float(0) > 35.4 and states('sensor.particulate_matter_2_5um_concentration')|float(0) <= 55.4 %}
                  orange
                {% elif states('sensor.particulate_matter_2_5um_concentration')|float(0) > 55.4 and states('sensor.particulate_matter_2_5um_concentration')|float(0) <= 150.4 %}
                  red
                {% else %}
                  black
                {% endif %}
                ;
              }
ildar170975 commented 2 years ago

I don't if its possible or not,

In 95% some feature is possible only if it is specified in docs. Changing of secondary_info w/o card-mod dependingly on some conditions is possible in cards like custom:template-entity-row & secondaryinfo-entity-row (both supports templates for secondary_info). Also, you may use card_mod for changing secondary_info in conventional entity rows by using after:: & :before pseudo-classes (see Community thread).

thomasloven commented 2 years ago

This has been answered.

Also, secondary_info is not a valid css property.