Trouble with template for rgb value

I’m trying to set the weather on an LED strip based on the rain and the temperature. Here’s the automation:

- id: '1537748897145'
  alias: Morning Weather
  trigger:
  - at: '5:45'
    platform: time
  condition: []
  action:
  - data:
      effect: "{% if states.sensor.dark_sky_daily_max_precip_intensity | float < 0.4 %}solid{% else %}glitter{% endif %}"
      entity_id: light.tori_mirror
      rgb_color: [{%- if states.sensor.dark_sky_daytime_high_temperature | float  <
        60 %}0,0,100{% elif states.sensor.dark_sky_daytime_high_temperature | float  <
        80 %}0,255,255{% else %}255,0,0{% endif %}]
    service: light.turn_on

And the error I get in the log when I trigger it:

## Log Details (ERROR)

Sun Sep 23 2018 22:05:27 GMT-0400 (Eastern Daylight Time)

Invalid service data for light.turn_on: None for dictionary value @ data['rgb_color']. Got '{% if states.sensor.dark_sky_daytime_high_temperature | float &lt; 60 %}[0,0,100]{% elif states.sensor.dark_sky_daytime_high_temperature | float &lt; 80 %}[0,255,255]{% else %}[255,0,0]{% endif %}'

change that to data template. But even after that change, your code won’t work. You’ll have to specify each line individually or use the color name instead inside the color name attribute (if that exists for your sensor).

This is what i mean by each line:

       rgb_color:
         - "{%- if states.sensor.dark_sky_daytime_high_temperature | float < 60 %}0{% elif states.sensor.dark_sky_daytime_high_temperature | float < 80 %}0{% else %}255{% endif %}"
         - "{%- if states.sensor.dark_sky_daytime_high_temperature | float < 60 %}0{% elif states.sensor.dark_sky_daytime_high_temperature | float < 80 %}255{% else %}0{% endif %}"
         - "{%- if states.sensor.dark_sky_daytime_high_temperature | float < 60 %}100{% elif states.sensor.dark_sky_daytime_high_temperature | float < 80 %}255{% else %}0{% endif %}"

Cool, thanks a ton. I’m confused because the template tester shows it fine.

The sensor code is my own wemos code, so I’ll make it take color names.

Template tester works because it supports multiple lines. Jinja in runtime only supports 1 string responses. So things like lists are not possible.