secondaryinfo-entity-row icon indicating copy to clipboard operation
secondaryinfo-entity-row copied to clipboard

Change color according to numeric state

Open sheminasalam opened this issue 2 years ago • 3 comments

Is it possible to change color according to numeric state like in the case of a battery voltage? If above 3.2 volt green, between 2.9 and 3.2 yellow. Below 2.9 red.

Also will it be possible to round a state attribute value in this card?

sheminasalam avatar Dec 17 '22 03:12 sheminasalam

Is it possible to change color according to numeric state

card-mod. Go to card-mod community thread for info.

to round a state attribute value

Only if it is supported by the inserted row. Conventional rows (https://www.home-assistant.io/dashboards/entities/) do NOT support rounding (or any other math operations). Try to put a custom:template-entity-row inside (which allows using template for a displayed state). But in this case there is no need to use secondaryinfo-entity-row.

ildar170975 avatar Dec 19 '22 05:12 ildar170975

Thanks for the input. I tried the following

  - type: entities
    entities:
      - entity: binary_sensor.front_door
        state_color: true
        type: custom:secondaryinfo-entity-row
        secondary_info: 'Battery: [[  binary_sensor.front_door.attributes.battery ]]'
        card_mod:
          style: |
            :host {
              color: {% if state_attr('binary_sensor.front_door', 'battery')| float >= 3.1 %} green 
                     {% elif state_attr('binary_sensor.front_door', 'battery')| float > 3.1 and state_attr('binary_sensor.front_door', 'battery')| float <= 2.8  %} yellow
                     {% elif state_attr('binary_sensor.front_door', 'battery')| float < 2.8 %} red 
                     {% endif %}
                  }

This changes the color of the state and the primary row. It doesnot have an affect on secondary row. How can this be modified to change secondary row.

sheminasalam avatar Dec 19 '22 06:12 sheminasalam

Go to card-mod community thread for info. 1st post -> link at the bottom -> styles for Entities

ildar170975 avatar Dec 19 '22 06:12 ildar170975