Changing Light Color

Hi,

I am having this block in an automation and just want to know if there are simpler ways to achieve the same result or if I have it done all right:

  action:
  - service: light.turn_on
    entity_id: light.light_1
    data_template:
      hs_color:
        - 120
        - 100
      brightness: 255
      transition: 1
  - delay: 00:00:01
  - service: light.turn_on
    entity_id: light.light_1
    data_template:
      hs_color:
        - 240
        - 100
      brightness: 255
      transition: 1
  - delay: 00:00:01
  - service: light.turn_on
    entity_id: light.light_1
    data_template:
      hs_color:
        - 0
        - 100
      brightness: 255
      transition: 1
  - delay: 00:00:03
  - service: light.turn_on
    entity_id: light.light_1
    data_template:
      hs_color:
        - 44.941
        - 100
      brightness: 115
      transition: 1
  - service: light.turn_off
    entity_id: light.light_1
action:
  - service: light.turn_on
    data: &change
      entity_id: light.light_1
      hs_color:
        - 120
        - 100
      brightness: 255
      transition: 1
  - delay: 00:00:01
  - service: light.turn_on
    data:
      <<: *change
      hs_color:
        - 240
        - 100
  - delay: 00:00:01
  - service: light.turn_on
    data:
      <<: *change
      hs_color:
        - 0
        - 100
  - delay: 00:00:03
  - service: light.turn_on
    data:
      <<: *change
      hs_color:
        - 44.941
        - 100
  - service: light.turn_off
    entity_id: light.light_1

Thanks, working good and its a bit shorter :slight_smile:

-edit-

Actually it is not as good as I thought. Using this will result in Errors in log so I will stick with my way:
ERROR (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/automations.yaml contains duplicate key “hs_color”. Check lines 134 and 143.

That error is actually a fault with the homeassistant config checker, it has been reported before but never fixed. The configuration is valid :slightly_smiling_face: