Save and restore switch/dimmer states?

I have a few motion trigger that I would like to turn on a few lights outside for a few minutes, and then restore them to their previous state (on/off/dimmed state). Five motion sensors, and four switches dimmers.

What's a clean way to do this?

There’s an app called Lights On Motion Plus which does exactly what you described.

My app actually just turns them off, dimming before as a warning. It could probably be easily modified to do that. Rule Machine should also be up to this task (it has capture and restore actions), but that could get tricky with a lot of devices.

Ahh my bad.

If you’re ok with setting specific levels instead of saving previous state, you could try my custom app. The code is in one of the last posts. I should probably just put it on GitHub some day.

Thanks for the quick replies! I'll look at that app and the 3rd paragraph was not quite clear if I could use it for my case:

  • when motion stops, remembering the on/off states (and dim level) of each bulb and only turning those that were previously on back on (and to the saved level) when motion resumes (if not prevented by restrictions configured in the app: mode, lux, time of day, etc.)

The use case is that I have some door lights, some balcony lights, some porch lights, etc. Sometimes the lights are on because of night/evening modes, sometimes the lights are on because people are there.

I'd like to blast to 100% a bunch of these lights and then return to old states after motion is gone. WAF would be low if they turned off automatically when we are sitting on the porch and the lights turn off when guests come over.

This is done quite easily in Rule Machine via the capture and restore functionality. You specify which devices you want to include in the capture command and then when you select restore, it will restore all of the previously captured devices. You can't restore part of them.

So, your rule would look like this:

Trigger:  Motion Changing

Action:
IF motion active THEN
     Cancel delayed actions 
      Capture all lights
      Set lights however you want (by mode or individually)
 ELSE 
     Delay actions for X minutes (cancelable)
     Restore devices.
END-IF

If you want to have the rule check for something specific before setting the lights to a particular level, for example if one light in the room is always off with no motion but always on when there is, then you can use this switch as a status check to see whether the lights should be set to the levels in the rule. Or you can use PB to do this. Either method will prevent any manual changes to the lights in the room from being lost when you have a repeated motion trigger. So, the PB version would look like this:

Action:
IF motion active THEN
     Cancel delayed actions 
     IF PB is True THEN
          Set PB False
          Capture all lights
          Set lights however you want (by mode or individually)
    END-IF
 ELSE 
     Delay actions for X minutes (cancelable)
     Restore the lights.
     Set PB to TRUE
END-IF
2 Likes

Okay,
Here’s a head scratcher.
I have a Zooz Zen17 multi relay. It is being used to control a 2 speed pool pump. The DC motor setting assures only a single relay is on at any one time. If relay 1 (low speed) is on and then relay 2 is turned on, then relay 1 is first set to off, then Relay 2 will turn on. And vice versa.
I want to set a rule like yours to capture the state of low speed (if low speed was already on, and high speed is turned on, return to low spreed after x amount of time).
Your setup won’t work, since, when changing the state of relay 2, before it’s state will change, the state of relay 1 is turned off. So, your rule will only capture relay 1s state as off (since relay 2s state will not change to on until after rely 1s state has changed to off).