Ok I have a question⦠I was searching up and down, but did not find an exampleā¦
Iād like to color the background of an entity-row (entity-card) depending on the state.
The following works like a charm: a hard-coded state value, the background changes according to the state value
type: entities
card_mod:
style:
hui-sensor-entity-row:
$: |
hui-generic-entity-row {
background-color:
{% set col = '200,200,0' %}
{% set col2 = '3,200,200' %}
{% set state = 50 %}
{% if 10 >= state %}
rgba({{col }},0.9);
{% else %}
rgba({{col2}},0.9);
{% endif %}
}
entities:
- entity: sensor.phone_battery
- entity: sensor.tablet_battery
Now if I try to bring the sensor state into play, the whole thing does not work anymore:
type: entities
card_mod:
style:
hui-sensor-entity-row:
$: |
hui-generic-entity-row {
background-color:
{% set col = '200,200,0' %}
{% set col2 = '3,200,200' %}
{% set state = int(states(config.entity)) %}
{% if 10 >= state %}
rgba({{col }},0.9);
{% else %}
rgba({{col2}},0.9);
{% endif %}
}
entities:
- entity: sensor.phone_battery
- entity: sensor.tablet_battery
The state value works again, when I apply the card-mod onto a single entity. But I would like to specify the styling only once, as I have a card with 30 entities. Is this possible? If, what am I doing wrong?
type: entities
entities:
- entity: sensor.phone_battery
- entity: sensor.tablet_battery
card_mod:
style: |
hui-generic-entity-row {
background-color:
{% set col = '200,200,0' %}
{% set col2 = '3,200,200' %}
{% set state = int(states(config.entity)) %}
{% if 30 >= state %}
rgba({{col}},0.9);
{% else %}
rgba({{col2}},0.9);
{% endif %}
}