Automate Color Changing Bulbs?

I’m kinda new to automations in Home Assistant.

I’m trying to find a way to automate color changing bulbs for Christmas.
To change them from Red to Green on repeat every 2-3 seconds.

Any help would be appreciated.

Thank you

alias: Christmas Color Change
description: ""
trigger:
  - platform: time_pattern
    seconds: /3
action:
  - service: light.turn_on
    data:
      color_name: red
    target:
      entity_id: light.aqara_hub_51a1
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: light.turn_on
    data:
      color_name: green
    target:
      entity_id: light.aqara_hub_51a1
1 Like

I am new to HA and want to thank you for that. I was able to expand on your code and make it run during certain times of the day as well as randomize between red, blue and green for each light… full disclosure, with the help of ChatGPT.

Here is my version based on yours:

  alias: Christmas Color Change
  description: ""
  variables:
    start_time: "08:00:00"
    end_time: "22:00:00"
  trigger:
    - platform: time_pattern
      seconds: "/3"
  action:
    - choose:
      - conditions: "{{ start_time <= now().strftime('%H:%M:%S') <= end_time }}"
        sequence:
          - service: light.turn_on
            data_template:
              color_name: "{{ ['red', 'blue', 'green'] | random }}"
            target:
              entity_id: light.lamp
          - delay:
              hours: 0
              minutes: 0
              seconds: 1
              milliseconds: 0
          - service: light.turn_on
            data_template:
              color_name: "{{ ['red', 'blue', 'green'] | random }}"
            target:
              entity_id: light.table_lamp
      default:
        - service: light.turn_off
          target:
            entity_id: light.lamp, light.table_lamp

For future users that search and find your thread, it may be helpful to share your solution and the working YAML code that came out of ChatGPT :slight_smile:

EDIT: Well I’ll be damned, you added it just as I refreshed the page! Thanks :slight_smile:

1 Like

Yeah, sorry… still figuring out this forum functionality stuff.

1 Like

thank you both for the reply…

where do I input this code?

You paste it within the automations.yaml file. You should watch a tutorial on editing the yaml files first though.