Hi,
I have a question that after hours of searching I still can’t seem to find an answer to. I have a decluttering template and within it I’m using a multiple-entity-row, whose value I’d like to color-code based on its own value.
The portion of interest is this:
color: |
[[[
if (entity.'[[container_resource]]' |float > 50) return "red";
if (entity.'[[container_resource]]' |float >= 30) return "orange";
else return "lime";
]]]
from the following template
#Template about used HDD MB/GB in %
drive_resource_percentage_template:
default:
- icon: mdi:docker
card:
type: custom:multiple-entity-row
entity: '[[container_resource]]'
name: '[[container_name]]'
icon: '[[icon]]'
styles:
width: 70px
text-align: right
color: |
[[[
if (entity.'[[container_resource]]' |float > 50) return "red";
if (entity.'[[container_resource]]' |float >= 30) return "orange";
else return "lime";
]]]
secondary_info: last-changed
entities:
- entity: '[[container_resource_stats]]'
attribute: min_value
name: min
styles:
width: 50px
- entity: '[[container_resource_stats]]'
attribute: max_value
name: max
styles:
width: 50px
- entity: '[[container_resource_stats]]'
attribute: mean
name: mean
styles:
width: 50px
Naturally it doesn’t work. If I set a static color, it works, but ofc that’s not what I’m after.
I have also tried to use the lovelace-card-mod, where you can define custom colors, which are styled by reading sensor states/values. However, for my purposes I’d like to use the decluttering template aliases instead. Maybe I’m missing something here.