Having issues with 'Scene: Create' in automation

I have some holiday themed lights set up in an automation, for example a creepy violet color at 50% for Halloween. Since we have a dog, when we take her outside I wanted the front door opening to trigger turning the lights to 100% brightness at a 2700K color temperature and then revert back to the Halloween colors after the door is closed. Here is the code I am using for it:

alias: Taking Dog Outside
description: ""
trigger:
 - type: opened
   platform: device
   device_id: 1e7b89193784c03855e170dcbee91b6f
   entity_id: 5253f468b6560374c1814675ef186097
   domain: binary_sensor
   id: Door Opened
 - type: not_opened
   platform: device
   device_id: 1e7b89193784c03855e170dcbee91b6f
   entity_id: 5253f468b6560374c1814675ef186097
   domain: binary_sensor
condition:
 - condition: numeric_state
   entity_id: sun.sun
   attribute: elevation
   below: -2.5
action:
 - if:
     - condition: trigger
       id:
         - Door Opened
   then:
     - service: scene.create
       data:
         scene_id: nighttime_garage_lights
         snapshot_entities:
           - light.garage_and_porch_lights
     - service: light.turn_on
       data:
         kelvin: 2500
         brightness_pct: 100
       target:
         entity_id: light.garage_and_porch_lights
   else:
     - service: scene.turn_on
       data:
         transition: 1
       target:
         entity_id: scene.nighttime_garage_lights
mode: single

This works most of the time. However, randomly one or sometimes two of the lights will NOT change to the warm white light. Instead, they remain at the violet color/brightness. They aren’t dropping off the network because I can manually change them. I originally had them as individual lights in the automation, but have since created a group for them and use it that way. I thought having them as a group would prevent this from happening, but it still happens.

I guess I am wondering why is this happening and is there a better/different way that I should be going about doing this? It is annoying to see the lights not change how they should be and my personal pride is hurt since everyone in the neighborhood can see that the automation isn’t working correctly.

Any help would be much appreciated! I know I could just have a set scene and call the scene on and call the different one, but this is supposed to work for any Halloween/Fall/Christmas/Fourth of July/etc. themes that I am going to be using.

First thing I would try is to change the device trigger to a state trigger.

Is there any hint in the automation debug trace or in the HA logs?

I don’t understand this sentence:

I will try changing the trigger to state from device. Why is this a good idea though?

And that sentence means that no matter how many times I try to open the door and close it, the automation triggers perfectly every time according to the HA logbook and the automation tree. It’s saying that it’s turning the lights back to their brightness/color but they aren’t. When that doesn’t happen, it’s like the “state” gets stuck. I can manually go into Z2MQTT/Apple Home/HA overview and change the color or brightness. So that means they are still on the network and still functioning just fine.

I am using the example from a “Smart Home Junkie” YouTube video if that helps anything.

There are many posts in the forum that describe problems with dvice triggers, so just to be sure, one should test if a state trigger solves the issue.
What would also be worth testing is (1) to change the automation mode from single to queued, (2) a delay before the scene is turned on.

I don’t know that video.

I changed it to a state trigger and that did not solve the problem. I will change the mode to queued to see if that helps anything. Would a delay of like .5 seconds (never tried one less than 1 second so not sure if that is even possible) be something that would work?

Edit: I changed it to queued and it still messed up. This is the link to the video I referenced: https://www.youtube.com/watch?v=JW9PC6ptXcM&pp=ygUYc21hcnQgaG9tZSBqdW5raWUgc2NlbmVz

I am going to add a delay, but I doubt this will work because the original trigger which is supposed to turn the lights a warm, 100% brightness only worked for 3/4 of the bulbs. Then when I closed the door 3/4 bulbs returned to the previous state, BUT then the 1 bulb changed to the warm, 100% brightness. So it’s like it was delayed or something?

I had a similar problem with Hue bulbs and mode: queued in combination with a delay solved it for me (only 500 milliseconds). What bulbs are you using?

I am also using Hue bulbs directly with my Conbee II using Z2MQTT. I changed the delay to 500 milliseconds as well earlier in the day. So far it seems to be working. I’ll give an update probably tomorrow evening after it has gone through some rounds of triggering.

After using it for a few days, it looks like the 500 millisecond delay and changing the automation to queued mode was the fix. I haven’t had any of the bulbs get stuck on a brightness or color that I don’t want. Thank you for the help!

Nice, glad to hear.