How to Save and Restore Switch/Dimmer States for Motion Lighting

I’ve been experimenting with motion sensors to control outdoor lighting, and I’m trying to figure out the best way to save and restore the states of my switches and dimmers. Here’s my setup: I have five motion sensors and four switches/dimmers. My goal is to turn on a few lights outside for a few minutes when motion is detected, and then restore them to their previous state (on/off/dimmed).

I’ve tried a few different approaches, but I’m not entirely sure if I’m doing it the cleanest way. For example, I’ve used the Rule Machine to trigger the lights when motion is detected, but I’m struggling with how to remember and restore the previous state. I’ve heard that some devices support scene automation, but I’m not sure if that’s the right path.

Another idea I had was to use a virtual switch to track the state, but I’m not sure how to integrate that with the motion sensors. I’ve also looked into using the Hubitat app to manually save the states, but that feels a bit clunky.

If anyone has successfully implemented something like this, I’d love to hear about your setup and any tips you have! Maybe there’s a feature or integration I’m missing that could simplify this process.

In the meantime, I’ll keep experimenting with different automation rules and see if I can find a reliable way to save and restore these states. It would be great to have a seamless solution that doesn’t require too much manual intervention.

Let me know if you have any suggestions or if you’ve tackled a similar project!