Script syntax help please

I have the below script to turn one light off and three others on to different colours but when config checking it results in errors.

I’m not sure what I’ve done wrong or what to do to correct it. Can someone please advise?


sunset_master_bedroom:
  alias: Sunset Master Bedroom
  icon: "mdi:weather-sunset-down"
  sequence:
    - service: light.turn_on
      data:
        - entity_id: light.headboard
          brightness: 80
          rgb_color:
          - 131
          - 50
          - 168
          transition: 120
    - service: light.turn_on
      data:
        - entity_id: light.m_bedside
          brightness: 80
          rgb_color:
          - 219
          - 57
          - 63
          transition: 120
    - service: light.turn_on
      data:
        - entity_id: light.r_bedside
          brightness: 80
          rgb_color:
          - 209
          - 96
          - 158
          transition: 120
    - service: light.turn_off
      data:
        entity_id: light.bedroom_light

Try this instead… :slight_smile:

sunset_master_bedroom:
  alias: Sunset Master Bedroom
  icon: "mdi:weather-sunset-down"
  sequence:
    - service: light.turn_on
      data:
        entity_id: light.headboard
        brightness: 80
        rgb_color:
          - 131
          - 50
          - 168
        transition: 120
    - service: light.turn_on
      data:
        entity_id: light.m_bedside
        brightness: 80
        rgb_color:
          - 219
          - 57
          - 63
        transition: 120
    - service: light.turn_on
      data:
        entity_id: light.r_bedside
        brightness: 80
        rgb_color:
          - 209
          - 96
          - 158
        transition: 120
    - service: light.turn_off
      entity_id: light.bedroom_light

The elements within the data: block are not a list -, but a dictionary of key: value.

Also, entity_id is one of those “special” keys that can be defined outside the data: block even if you have a data: block.

1 Like

That sorted it.

Thanks for your help, Tony, it’s much appreciated.

1 Like

Unfortunately, this is a bit inconsistent. See this issue:

1 Like

Fair point, I forgot about that pain… :frowning:

I have avoided it for the most part or had a WTH moment when it happens…

Thanks, I’ll bear that in mind but, in this case, the code works for my Hue lights.

It’s confusing and I wasn’t aware of this conflict but I’ll try and remember to move the entity_id if I encounter future issues and see how it goes.