Previous state lights (hue)

pulling my hair out…

I red a couple of forum topics about the previous state of lights. But can’t find a correct answer or solution to my config.

I have a trigger which needs to flash/colorloop a light for 30 seconds.
I have this working. But how can I set the light to its previous state after it is finished?

Lets say the light was on… with color red.
After the trigger is triggered an automation start the flashing program which set the lamp to green flashing.
After the automation is ended is should return to the begin state --> state:on, color:red

Could someone point me in the right direction how to script this ?

Thank you all :wink: