Use Light to show some alarm and than go back to last state

I use my hue lights to show alarms. For example co2 level too high. In this case it blinks in orange for a few times and than turns off.

If the light was on before this alarm will turn off my light.

Is there a way to save the last state before the alarm and than go back to this state after it?

Any ideas on how to do this?

Just as a quick idea that would probably work is to create an input boolean to track the state of the light. Then if the boolean is on run a script that ends with the light on and if it’s off run a script that ends up with the light off.

Thanks nice idea.

But this won’t save the brightness and the color of the light.

I use orange and red as alarm colors. The script than would turn it on in this color (red or orange).