Conditional trigger using previous device state

I want to switch a light on/off using a door contact sensor (open/closed). However, the light must go back to whatever state is was in when the door closes. In other words, the rule needs to remember the light's state when the door first opened in order to decide whether to turn off the light when the door closes.

I think I can do this with a local boolean, but is there a simpler way that I'm missing?

You can do that, especially if on/off is all you need (otherwise you'll need more variables), but the "Capture" and "Restore" actions built in to Rule Machine sound more like what you want. Have you tried these to see if they work for you?


You might try motion lighting. There is an option to not turn off if already on.

Got it working with your suggestion. Thanks!