Rule condition on state change (lock > unlock)

Trying to build a rule that turns on some exterior lights when any of my exterior doors are opened OR unlocked and then turn off once all the doors are closed BUT I don't care about lock state for turning off.

Here is what I have which works great for the door open/close:

What are some way I can trigger the true side of this rule with "lock change to unlocked" events? I don't want "lock is unlocked" to also evaluate to true, just the change to unlocked.

You should do this with two rules. One with an OR between the doors open and the locks unlocked. In the other rule, you would have the doors being closed only turning off the lights. They will not interfere because the actions only happen when the rule truth changes.

The rule seems overly complicated based on the description of what you're trying to achieve.
I'm using this simple rule.

Does capture/restore work across rules? I need the "on" even to capture the current light level and the "off" level to restore it.

Sure I'll be explicit in my requirements:

  1. I have a "Dusk to Dawn" virtual switch that is turned on when outside illuminance is below a certain threshold. Due to where I live the built in sunrise/sunset times don't correspond well to actually outdoor lighting needs. This switch has to be "on" for the automatic lights to turn on.
  2. The current state of the outside lights must be captured in the on event and restored in the off event.
  3. The lights should turn on full when any exterior doors are opened
  4. The lights should turn on full when any exterior lock is unlocked
  5. The lights should turn off 10 minutes after all exterior doors are closed

No. You must restore within the same rule as you captured.

Why do you have to capture the current state of the lights? Are you trying to override the rules? If so, you can have a condition of the lights turning on that the lights are off and use PB to enable turning the lights off oboy when they are turned on via the rule.

I too do not understand the need to capture the current state of the lights.

Something like this should do what you need. Set the illuminance to the level you need obviously. This is just an example.

I use the same lights at times at a low dim % for security lighting. I'd still like them to hit 100% when someone is coming or going and return to their previous manually set state.

I realize this may not be what everyone wants but it is a requirement I have. If Rule Machine can't do this it isn't a huge deal, I'll just write a custom app but the fewer custom apps I have to write the better.

Do you always have the same dim level or could it be anything?
If always the same, I would use a boolean variable to capture whether they should be turned off or dimmed on turning the lights "off".
If different levels, I would use a scene to capture the lights and then activate that scene to "restore".

1 Like

So back to what @Ryan780 was stating, you need two rules. In the rule example I gave you, you will set the lights to the desired level when the rule is false, instead of turning them OFF completely. Your other rule needs to set the lights to their dim level based on whatever it is you want to base that on, be it time or illuminance. The true condition of that second rule turns them on to the desired dim level, the false condition turns them off.

Oh interesting, I haven't played with scenes much yet. I can dynamically capture a scene state from a rule? If so that would let me do the capture/restore across rules.

Yes. You simply enable the capture within the scene and it will automatically create a Virtual switch for the capture. Just turn it on to capture the scene.

1 Like

Great! That sounds like exactly what I need. I'll post back with my solution tonight when I get a chance to fiddle with things again.

1 Like

I realized what I wanted was a Triggered Rule vs a Conditional Rule. My final solution for this work is documented in: Outside Automatic lights on doors/locks/presence