Conflict between one Scene's Actions, and Another Scene's Triggers

Good day.

So I’ve got one scene that when triggered, will cause a Z-Wave lock to lock itself amongst other things. Another scene is triggered by manually locking said lock. My issue is the first scene will trigger the second. So one scene locks the door, which then satisfies the trigger condition for the second scene, and hence both go off.

Another situation I have, is that I have a light switch turned on and then off by a certain scene… yet I also want a scene to be triggered by turning off the switch. The first scene will cause both scenes to occur.

Am I asking too much here? Must I be careful not to have an action on a device the same as a trigger on the same device? Is there a way to do this sort of thing more intelligently?

I’m trying to work with the Variable Container mod for example. I want to do automatic lighting control, or have the automation scenes ignore the lights when someone manually uses the light switch. So I flag a variable as “1” when someone manually enables the switch, and “0” again when it’s manually turned off. I have this working properly. Problem is, any scene that turns on or off the light, also sets the flags. This breaks the discrimination between automatic and manual control that I have in mind.

Thanks for any help any of you very smart and generous people might provide.

You can’t detected manual operation directly …
What you can do is make sure it’s not caused by any of the automation scenes.

When every you turn on anything via automation … set a flag.
Them if something comes on … and the flag is set … you know that it was done via automation.
Then you are left with … when to clear the flag … maybe when the device is turned off …

I find putting all of this logic in PLEG much easier to master.
Then I use sequence expressions with short timeouts to handle ignoring automation triggers.
i.e.

AutomationTrigger     .... Some Logic
LightOnTrigger           ... Light is on

ManualLightOn             LightOnTrigger and (AutmationTrigger; LightOnTrigger > 10)

This indicates the light was manually turned on … because the Light was turned on more than 10 seconds after the automation trigger, so it’s not a side effect of automation.