How do I restore the state of an item to the previous one after a change through a group?

Dear openHAB-Friends,

currently I’m challenged by the following task:
I have some smart lights in the group lights and a smart smoke detector.
I want the smoke detector to trigger the group lights to blink for some time when there is smoke detected. After this, the lights should go to the previous state before the blinking.
I know how to solve everything, except the “go to the state before blinking” thing.

I already tried to get this done with persistence and .previousState(),
but did not get the excepted result:

Three switches test1, test2, test3 (member of testgroup, state OFF)
One group testgroup

rule "Test Persistence"
when Item test1 changed to ON
then
    testgroup.sendCommand(ON)
    logError("Test Persistence", "#####Testgroup switched on ######")
end

rule "Reset to previous state"
when Item test2 changed to ON
then   
        //Item reset to previous state
    test3.sendCommand(test3.previousState().state)
    logError("Test Persistence", "#####Reset to previous state ######")
end

Can you please point me in the right direction?

Thank you for helping me

How do you make the lights blink? I guess via a rule that switches them on and off a few times in sequence? Then all you have to do is store the state in a variable before the blink sequence and then sending it as a command after.

Hi Anders,
thank you for answering.
How do I save the state of every group member and also revert it back after the blinking?
Thanks

If you want to save the states of all members in a group I believe you can use the storeStates and restoreStates actions: Actions | openHAB. According to the documentation, restoreStates should automatically send commands for most types.