Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change color according to numeric state #52

Open
sheminasalam opened this issue Dec 17, 2022 · 3 comments
Open

Change color according to numeric state #52

sheminasalam opened this issue Dec 17, 2022 · 3 comments

Comments

@sheminasalam
Copy link

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?

@ildar170975
Copy link

ildar170975 commented Dec 19, 2022

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.

@sheminasalam
Copy link
Author

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.

@ildar170975
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants