Hi, i want to change the color of a LED-Strip according to the energy balance of my house and photovoltaik plant: green - Energy suplus / red - Energy deficit
If i hardcode the color into my Template it works fine. So something seems to be off with my IF condition. I just don’t see it. Here is my Code. Help is very much appreciated!
#------------------------------------------------
# Change Color to Green when PV Productrion
# exceeds consumption. To red if negative.
#------------------------------------------------
- alias: Change LED Color Inhouse Balance
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.aktuelle_leistungsbilanz
action:
- service: light.turn_on
entity_id: light.led_streifen_01
data:
brightness_pct: 20
color_name: >
{% if states.sensor.aktuelle_leistungsbilanz.state|int < 0 %}
red
{% else %}
green
{% endif %}
i have also tried without success:
{% if states.sensor.aktuelle_leistungsbilanz|int < 0 %}
and
{% if states.sensor.aktuelle_leistungsbilanz < 0 %}