RGB Color in Date Template

I’ve tried every which way to get this to work

  action:
   service: light.lifx_set_state
   entity_id:
    - light.couch
    - light.entry
   data_template:
    rgb_color: >
     {%- if (states.light.kitchen_2.attributes.rgb_color) != (167, 167, 167) -%}
      [167,167,167]
     {%- else -%}
     {%- endif -%}

And I keep getting the following error:

2018-01-12 13:19:23 ERROR (MainThread) [homeassistant.core] Invalid service data for light.lifx_set_state: None for dictionary value @ data[‘rgb_color’]. Got ‘[167,167,167]’

What’s weird is that this seems to work just fine:

  action:
   service: light.lifx_set_state
   entity_id:
   - light.couch
   - light.entry
  brightness_pct: 10
  rgb_color: [218,190,160]

As does this:

  action:
   service: light.lifx_set_state
   entity_id:
    - light.Kitchen_1
    - light.Kitchen_2
    - light.Kitchen_3
    - light.couch
    - light.entry
   data_template:
    brightness: >
     {%- if (states.light.kitchen_2.attributes.brightness) < 255 -%}
      255
     {%- else -%}
      60
     {%- endif -%}

Any thoughts?

This does not work, the array is only recognized as such if it is at the beginning of the template (that is probably a bug but here we are).

A workaround was posted here.

Thanks for the link. That’s clever and I may integrate it. I went a slightly more complicated direction, but it works:

The Automation:

action:
service: scene.turn_on
data_template:
entity_id: >
{%- if is_state(“group.my_house”, “off”) -%}
scene.NightLights
{%- elif (states.light.kitchen_2.attributes.brightness) < 255 -%}
scene.SwitchLightsFromLow
{%- else -%}
scene.NightLights
{%- endif -%}

The Scene:

scene:

  • name: NightLights
    entities:
    group.kitchen:
    state: on
    brightness: 60
    rgb_color: [218,190,160]
    light.entry:
    state: on
    brightness: 60
    rgb_color: [218,190,160]
    light.couch:
    state: off
  • name: SwitchLightsFromLow
    entities:
    group.kitchen:
    state: on
    transition: 2
    brightness: 255
    rgb_color: [218,190,160]