Well… step by step ![:sweat_smile: :sweat_smile:](https://community.home-assistant.io/images/emoji/twitter/sweat_smile.png?v=9)
I could change the color of de icon, so I think I have got something
In my /config/customize.yaml I have:
sensor.sensor_digital_input_1_on_off:
friendly_name: MOTOR DE RIEGO
This part works perfectly
If I add this as a third line:
icon_color: 'red'
also works perfectly, but the icon is always red.
What I need is the color of the icon change when the state of the virtual sensor change (just 2 different states: ON or OFF).
I have tried a lot of different options from the examples, but no one works… I think my problem is the syntax.
Please, I need help with this.
I’ll paste the different ways I have followed just in case…
OPTION 1
sensor.sensor_digital_input_1_on_off:
friendly_name: MOTOR DE RIEGO
icon_color: 'red'
#this is the option which works, but always red
OPTION 2
sensor.sensor_digital_input_1_on_off:
friendly_name: MOTOR DE RIEGO
icon_color: >
if (state === 'OFF') return [255,255,0];
return [255,0,0];
OPTION 3
sensor.sensor_digital_input_1_on_off:
friendly_name: MOTOR DE RIEGO
icon_color: >
{% if state = OFF) %}
'yellow'
{% else %}
'red'
{% endif %}
OPTION 4
sensor.sensor_digital_input_1_on_off:
friendly_name: MOTOR DE RIEGO
icon_color: >
{% if state == OFF) %}
'yellow'
{% else %}
'red'
{% endif %}
OPTION 5
sensor.sensor_digital_input_1_on_off:
friendly_name: MOTOR DE RIEGO
icon_color: >
{% if state = 'OFF') %}
'yellow'
{% else %}
'red'
{% endif %}
OPTION 6
sensor.sensor_digital_input_1_on_off:
friendly_name: MOTOR DE RIEGO
icon_color: >
{% if state == 'OFF') %}
'yellow'
{% else %}
'red'
{% endif %}
ANY OTHER OPTIONS I HAVE TRIED, ALWAYS AS A THIRD LINE
if (state = OFF) return 'red';
if (state = 'OFF') return 'red';
if (state == OFF) return 'red';
if (state == 'OFF') return 'red';
if (state = OFF) return 'rgb(255,0,0)';
if (state = 'OFF') return 'rgb(255,0,0)';
if (state == OFF) return 'rgb(255,0,0)';
if (state == 'OFF') return 'rgb(255,0,0)';