#Automation running when already on

1 messages · Page 1 of 1 (latest)

uncut meteor
#

Not sure if anyone can help me work this out.

Got an automation I made with the help of some people here with the choose blocks.

It’s a combination of the motion lights blueprint and a bunch of choose options

This works great and activates my scenes as planned when I walk into the kitchen and turns off after there has been no motion in the kitchen for 2 minutes.

But if I’m in the kitchen with the lights already on the automation sometimes fires again.

Which when the scene in question is single colour lights is not a problem, but when the scene includes changing/fading lights it runs and fires the command to change scene and the lights then click to the first colour or scene and start fading again.

I figured ok - add a condition that it will only run if the kitchen lights are off. So it won’t run twice but when I do this it indeed doesn’t run again if already on, but then the logic surrounding waiting for 2 minutes of motion is ignored and the lights go off an then actually ignores new motion for a bit.

Below is the yaml for the automation as it stands which seems to run again whilst already in the room

Any advice on what I could at to achieve a point where it won’t try and turn the scene on multiple times

https://pastebin.com/hVr7Xkuh

spice oak
#

My default answer is to avoid stateful automations. Which, in your case, would mean eliminating the 120 second delay and the “wait for trigger” and instead adding another trigger that fires after the light and/or motion sensor has been in a certain state for 120 seconds.

All that said, if you really want to keep this automation as-is, the simple solution is to change the mode from restart to single. That way it can’t fire again until the wait for trigger and the 120 seconds have expired.

uncut meteor
#

Do you mean a second automation altogether with trigger or no motion after x ?

Doesn’t necessarily have to stay as is, I’m fairly new to the automation side and trying to find useful things I can do with it currently always something new to learn

#

Will give these both a go

Thanks

astral knot
#

I think @spice oak means the former as in a separate automation. This is my preference as well so you have more automations that run for shorter amount of time rather than less automations which run for longer.

spice oak
#

Whether it’s one big automation or multiple separate ones is really a matter of personal preference in how you want to organize and manage/troubleshoot your automations. My comments is just that you should strive for your automations to start and end within fractions of a second. If you have automations that are partially executed and waiting around for minutes or hours for something else to happen, then I would consider that “stateful” and thus bad practice.