On motion, save light settings and set to 100%... after motion then restore settings


One of my first pistons.

Motion will save the current light settings (Brightness, On/Off)
Then the light will switch ON at 100%

When motion is inactive the light will be restored to saved settings.

Any advice on making this more efficient would be appreciated.


Instead of capturing the values to variables, just use the “Capture attributes to local store” feature. You can also use the “Restore attributes from local store” to set the brightness/color back to its original state.
Here’s a quick example of capturing attributes, logging their values, performing an action, and restoring back to normal: