Problem restoring light state

I'm using lights as an alert - 2 bulbs flash, another changes color. Stopping the flashing works as expected almost all the time. However, the color bulb that I'm setting as blue for the alert often doesn't return to the previous state. It seems to have better luck if the bulb was already on and it only has to change back to white. But when the bulb was previously off, it often remains on in the blue state.
This is the rule I'm using...

The variable Light.state records the on/off state before the alert in my attempt to fix the capture/restore not working. The variable PRun is my attempt to only have one instance of this rule running at a time.
Any thoughts on where I messed up the code?

The rule should properly restore the on/off state, but if it was off and you changed the color, it will not "pre-stage" the old color back. The restore stops after simply restoring the previous state, which was just off. So, to turn it back on next time, one solution to this problem is to just set a specific color/CT. Alternatively, you can track the on/off state yourself, then make sure it's on before capturing, restore, then manually turn it back off (based on what you captured) if needed. This ensures the full gamut of states are saved if that matters for you. I described this approach in this thread and likely several others:

But your problem sounds like more than that. The bulb also isn't responding to "Off" at all, apparently? Or maybe the state was reported wrong and thus restored wrong (to on)? Looking at the device detail page may help, either verifying that it really reports off/on correctly, specifically at the time of capture, and verfying that manually running on/off commands always works as expected. (You can also look at the rule's App Status page/application state to see what was captured, with a bit of effort to interpret.) Logs can help a bit. Without more information, either could be the issue, though the latter seems like a more common issue if I had to guess...

My problem is as you describe as the second issue. I'm not concerned about the color state of the bulb when off as I do pre-stage the CT for my normal usage.
I was about to type that the bulb (Can 1) does respond to manual on/off commands just fine, but now that I think of it, after the last run of this rule, I had to do another configure in the driver before it would respond. Normally I can just turn it off manually after the rule leaves it on incorrectly.
I turned the debug log on for Can 1 so I can check it after the rule is triggered next.

Download the Hubitat app