Hi!
I’m trying to create a script that would turn on my lights with a color depending on the current weather (cloud coverage to be exact).
My problem is that rgb_color
is supposed to be an array, and it looks like templates can only produce strings as output.
I have tried the following as a test
weather_lights:
alias: Weather lights
sequence:
- service: light.turn_on
data_template:
entity_id: light.desk_lamp
brightness: 255
rgb_color: >
{% set color_values=[[255,0,0],[0,255,0],[0,0,255]] %}
{%- if states('sensor.dark_sky_cloud_coverage') | float <= 5 -%}{{color_values[0]}}{%- elif states('sensor.dark_sky_cloud_coverage') | float <= 20 -%}{{color_values[1]}}{%- else -%}{{color_values[2]}}{%- endif %}
But I have that kind of error:
Invalid service data for light.turn_on: None for dictionary value @ data['rgb_color']. Got '[0, 0, 255]'
Even with this simple template
rgb_color: "{{ [0, 0, 255] }}"
, the error is the same.
Would anyone know how I could use a color computed by a template?
Thanks a lot