Switch: previous state

Hi :wave:t3:, I have the following challenge:
I’m using a switch and by pressing once I activate a scene and by pressing again I deactivate the scene. So far all is working fine :slight_smile: but what I want to achieve is that 2 lights in that group should check if they were on and if they were, they should switch back to that “on state” and if they were off, they should turn off.

How can I do that? Kind regards and thanks for reading,