Program light to go back to previous state as part of a scene

I have a scene triggered by a motion detector on my front porch that turns on some dimmable lights at a set percentage. What I’d like to do is see if there’s a way to have the Vera look at the state of the lights, (on/off, dim percentage) before turning the lights to on, wait for the timed event (one minute) and instead of turning the lights off after one minute like I currently do, have the lights go back to their previous state. Any advice would be much appreciated.

I have a Vera Plus.

I’m saving the values of my Fibaro RGBW Controller and restore them after a scene with the following code:

-- save LED values
R_save = luup.variable_get( "urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget", R_Device1 )
G_save = luup.variable_get( "urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget", G_Device1 )
B_save = luup.variable_get( "urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget", B_Device1 )
W_save = luup.variable_get( "urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget", W_Device1 )

(R/G/B/W_Device1 are the IDs of the device)

Dimmable devices also implement SwitchPower1 - try turning the lights off/on (SetTarget on urn:upnp-org:serviceId:SwitchPower1) in your scene vs dimming (SetLoadLevelTarget on Service: urn:upnp-org:serviceId:Dimming1). What I have found is that using the SwitchPower1 to turn the lights on and off will not change the LoadLevel (i.e. dim level). Use the Advanced Editor in the Scene Editor to control which action to apply to a given device.

Thanks for some nice examples! I’ll try it out and let you know what worked.