hi guys, is it possible to change state-label color based from some hex code color i templated before?
im planning to use it at my house plan.
currently i used:
- type: state-label
entity: climate.master_bedroom_1pk
attribute: current_temperature
suffix: °C
style:
top: 40%
left: 82%
'-webkit-text-stroke': 1px green
here’s my template code:
sensor:
- platform: template
sensors:
mb1pkcolor:
friendly_name: master bedroom 1 PK color
value_template: >
{% set min = 18 | float %}
{% set max = 35 | float %}
{% set a = state_attr('climate.master_bedroom_1pk', 'current_temperature') | float %}
{% set b = (max - min) %}
{% set c = (a - min) %}
{% set red = ((c * 100) / b) | round(0) %}
{% set redhexdecimal = (red * 255 / 100) | round(0) %}
{% set redhex = '%0x' % redhexdecimal %}
{% set green = (100 - ((c * 100) / b)) | round(0) %}
{% set greenhexdecimal = (green * 255 / 100) | round(0) %}
{% set greenhex = '%0x' % greenhexdecimal %}
{% if a > max %}
red
{% elif a < min %}
green
{% else %}
'#{{ redhex }}{{ greenhex }}00'
{% endif %}
and heres the entity value at developers tools
i’ve tried to change
‘-webkit-text-stroke’: 1px green
into
‘-webkit-text-stroke’: {{ states.sensor.mb1pkcolor.state }}
but it doesn’t work
any suggestion?
thanks in advance!