Help with my rule

I have a scene that I want to do and I got most of it except for an exception that I can’t seem to figure out. I have a schlage zwave lock on my front door and I want to control my zwave light next to it with the lock. So I have a scene that does the following:

When the lock is opened, it turns the lamp on and when locked is locked it turns it off. I use it to illuminate entrance after sunset. Problem is that its also my living room lamp that I use to watch tv. so the exception that I’m trying to fix is the following:

if the lamp is already on prior to unlock, then after the lock is locked, leave the lamp on. Any ideas how to do it?

in the app i have the following:

To Turn on:
Smart lighting --> Turn on living room light when unlocked
turn on when Unlocked. Only during sunset to sunrise.

To turn off:
smart lighting --> Turn off when locked
Turn off when door is locked

Any ideas how i can do what I want it to do?

thanks

Alex

Two ways I know of to accomplish what you want, both courtesy of @bravenel.
The first would be to add a virtual switch and this smartapp. Configure the app to link the virtual switch to your physical lamp switch. Then, in Smart Lighting, configure it to turn on/off the virtual switch instead of the real one.

The second way is to just abandon Smart Lighting altogether, and use Rule Machine (no virtual switch required). The choice comes down to your personal preference (i.e., do you prefer a building block, modular approach or an all-in-one solution).

Thanks. I think I’ll do the Rule Machine, Read about it few days ago

Think I got it. will test tonight after sunset

Update - tested it and works fine.