Need help with what i thought would be a simple christmas light automation - but its not

Hello all,
i could really use some help. i am trying to make an automation that will simply make my front door light bulb cycle between 3 colors for Christmas until i turn it off. sounds simple right? However i am having issues mainly with getting it to turn off. here is what i have tried so far and the frustrating results…

  1. i tried making building an automation. Trigger was when the sunsets. and the action was “repeat Until” time was 2:00am and the repeat actions were stated as Turn on light to red, wait 2 minutes, turn on light to blue, wait 2 minutes, turn on light to green
    the results were the light turns on and cycles through the 3 colors and then stopped at the last color and never cycled again. the second issue i had was that it would not turn off at 2:00am and for some odd reason my home assiswtant would get slow and unresponsive and i had to restart it to get to be usable again

  2. so after that failure i tried all of the above except i changed the “repeat until” to “state” and made the it look for the state of “off” for the front light. that worked better and the colors did indeed cycle but when the light was turned off either by an automation or even manually from the dashboard it would come back on very shortly afterwards and again, my home assistant itself became slow and unresponsive and i needed to restart it to get it to be usable again

  3. My last attempt was very similar to #2 but instead i took all the repeat until and color changes and remade all the steps into a script. i then created an automation that called the script with an automation to turn off the light. again same results as the results in #2, the light would cycle but did not turn off at 2:00am with the automation and if i turned it off manually, it would turn back on. and again Home assistant would become slow and would need a restart.

my HA is on a VM built in ESXi with 8gb RAM and 2 CPU’s given to it along with a 64GB hard drive. if anyone can assist me in getting what i thought would be a simple automation going i would appreciate it. i would like to know why the ones i tried made my HA so unresponsive but thats more for my own curiosity. i am more interested in getting this automation to work

thanks in advance
Mike

1 Like

Post the automation.

alias: Christmas Light Test
description: ""
trigger:
  - platform: sun
    event: sunset
    offset: 0
condition: []
action:
  - repeat:
      until:
        - condition: state
          entity_id: light.front_door_light
          state: "off"
      sequence:
        - service: light.turn_on
          data:
            color_name: red
          target:
            entity_id: light.front_door_light
        - delay:
            hours: 0
            minutes: 2
            seconds: 0
            milliseconds: 0
        - service: light.turn_on
          data:
            color_name: blue
          target:
            entity_id: light.front_door_light
        - delay:
            hours: 0
            minutes: 2
            seconds: 0
            milliseconds: 0
        - service: light.turn_on
          data:
            color_name: green
          target:
            entity_id: light.front_door_light
mode: single

I also tried bundling this all as a script and calling the script in the automation but still get the same bad results

here is the script i created as well to try…

alias: Front Door Light - Holiday Light Change
sequence:
  - repeat:
      until:
        - condition: state
          entity_id: light.front_door_light
          state: "off"
      sequence:
        - service: light.turn_on
          data:
            color_name: red
            brightness: 255
          target:
            entity_id: light.front_door_light
        - delay:
            hours: 0
            minutes: 2
            seconds: 0
            milliseconds: 0
        - service: light.turn_on
          data:
            color_name: blue
            brightness: 255
          target:
            entity_id: light.front_door_light
        - delay:
            hours: 0
            minutes: 2
            seconds: 0
            milliseconds: 0
        - service: light.turn_on
          data:
            color_name: green
            brightness: 255
          target:
            entity_id: light.front_door_light
mode: single
icon: mdi:string-lights

Control the looping using the state of some other entity than the light that’s being controlled by the loop.

In the following example, an Input Boolean is used to control looping. Now you can start/stop the color-changing loop, at any time, by simply turning the Input Boolean on/off.

alias: example color change
trigger:
  - platform: state
    entity_id: input_boolean.color_changer
    to: 'on'
action:
  - variables:
      colors:
        - red
        - blue
        - green
  - repeat:
      while: "{{ is_state('input_boolean.color_changer', 'on') }}"
      sequence:
        - service: light.turn_on
          target:
            entity_id: light.front_door_light
          data:
            color_name: "{{ colors[(repeat.index - 1) % 3] }}"
        - delay:
            minutes: 2
mode: single

Create a separate automation to schedule when the color-looping should start/stop.


alias: Christmas Light Test
description: ""
trigger:
  - id: 'on'
    platform: sun
    event: sunset
    offset: 0
  - id: 'off'
    platform: time
    at: '02:00:00'
condition: []
action:
  - service: "input_boolean.turn_{{ trigger.id }}"
    target:
       entity_id: input_boolean.color_changer

@123 thank you! let me ask one more question please… the first code you posted, is that a script or an automation? i am new to HA and i built everything in the UI. i do know how to change the view to YAML so i can post the code, but do not know where in YAML to post your code? i think you posted a script but wanted to be sure. apologies for the noob question but i am learning

Both examples I posted are automations.

An automation has a trigger (and an optional condition) whereas a script doesn’t.

Don’t forget to create an Input Boolean (because the examples assume that input_boolean.color_changer exists).

Sunset only happens once. Just like your automation.

@123 so yes i did forget to create input boolean and did that so now things are starting to “look” better but i feel like i still may have done something wrong. i see these possible issue when looking at everything…

in my UI for one of the automations i see this (which may be ok as i said i am still learning):


visual editor is not supported? is that ok?

also… am i supposed to put a trigger.id in there? i see that referenced in my watchman report as missing. if so, where do i find this trigger.id?

Yes.

In visual mode, the Automation Editor has no (graphical) means of displaying a template so it shows it in YAML mode.

No.

The value of trigger.id will be supplied by whichever one of the two triggers is responsible for triggering the automation. For example, refering to the automation I posted above, if it’s the Time Trigger then the value of trigger.id will be off.

@123 thank you again. i was concerned something needed to be there because i saw this in a report i saw others using to help keep there HA running better


and this
image

If you refer to my original example, there are outer double-quotes surrounding the value.

That may serve to placate Watchman. If it doesn’t then that’s Watchman’s problem.

@123 the quotes did not change it… oh well. thanks again for your help.

Then it’s a problem with Watchman; it’s reporting a false-positive. It seems Watchman doesn’t correctly evaluate a service template.

1 Like

You have to exclude this in the integration configuration under Ignored entities and services:


*.*turn_