Is it possible to produce an RGB array using a template?

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

I don’t think it will work (I have seen an older post about this):

However, you could use an workaround and instead of rgb_color use color_name. The choice list is quite long and needs some testing to find one that is suits you as, being for showing on a screen, most of these colors won’t be properly rendered by a light bulb (some are directly translated to white light): CSS Color Module Level 3

    color_name: >
      {% set color_values=['magenta','yellow','green'] %}