(Not so) simple motion rule with scenes

Your question made me curious so I looked in rule machine, there is a capture and restore action so you could do away with the making of the global variables and just use that.

1 Like

I think that with testing, I was in too much of a hurry so that the HE didn't have time to sync the scene with Hue bridge... Or I just made a mistake somewhere...

The capture restore in RM is just for the switch capability. What you want to do is create an actual scene with the devices and enable the capture device within the scene.

image

Then, when motion is detected, you first want to turn on the switch that will be label with the scene's name plus "capture". This will capture the state of the lights to that scene. Then go ahead and enable the scene that you want.

Then, after the two minutes of inactivity you'll just activate the scene you captured earlier.

1 Like

Thank you, Ryan. This was exactly what I was looking for!

This isn't quite right. The action Capture Devices uses the switch capability to select the devices to capture, just as Scene does. But the action itself captures all possible states of the devices, including color, color temperature, level, etc. And Restore Devices restores all of them.

So, Capture Devices and Restore Devices can be used, in effect, to capture a scene on the fly, and restore it later, without having to use Scene. In fact it uses the exact same code that Scene does to accomplish this.

But there was an issue you investigated related to this function within HSM. Was that also worked into RM? Because I was seeing inconsistent behavior in RM, that's why I was using the Groups and Scenes.

That was some time ago. All of those bugs were resolved.

Okay, that's good. I knew they'd been fixed in HSM but I wasn't aware that it was working in RM too.
It's tough to know what's still a bug and what's been fixed sometime. :slight_smile: Thanks!!

The captures of the light states are working fine. Both capturing scenes and capturing devices. Unfortunately it only works well if the motion trigger is activated once. If it happens a second time, the capture is done again, which leads to the "daylight scene" overwriting the "temp scene". :frowning:

I still have to figure out how I can achieve what I want. I can't imagine that I'm the only one wanting this... Any suggestions, anybody?

Okay, now I've changed the Rule into a Triggered Rule. Capturing the first time only works now, but the rest not. When single motion, the "Daylight scene" stays on. With multiple motion, the FALSE part is used, but only for the first minute, the lights go off, regardless of motion after one minute...

Is there a way to gracefully shut down the "Actions for True" section? Or a way to just force the "Actions for False" to execute, after the "Actions for True" part? (I'm using a Hue motion sensor, it is set to 10 sec)

And with consecutive motion, just keep the (false) actions going...

I'm not a programmer and I can see my lack of programming skills. Please be patient with me...

I think you've gone astray.

Is what you want to happen that when the Keuken Sensor becomes active, that you capture the state of some lights, then set the Scene Keuken_Scene_Daglicht; then when the sensor becomes inactive restore the lights to the way they were before?

Yes! :slight_smile: Should be easy... or not? Sorry for the strange language! keuken=kitchen daglicht=daylight :slight_smile:

You should use Capture and Restore in a Rule, like this:

Condition: Keuken Sensor Active
Rule: Keuken Sensor Active (autofills)
Actions for True: Capture [select all lights to capture], Activate Scene: Keuken_Scene_Daglicht
Actions for False: Restore after a delay of 0:01:00

I've done this now. Problem is that when there is a second motion trigger (in the minute, before false is registered) , the lights are captured a second time in "daylight" scene.

That is why I recommended using the scene instead. That way, you can have the lights on event being a trigger:

Trigger event: motion Active
Condition: Some condition that is different from the scene your are activating. Either a dimmer level or CT...something that will distinguish itself form when the scene Keuken_Daglicht is active. The intention is that if the motion trigger event happens again the condition will be false causing the rule to not re-capture.
True: Turn on capture device
Activate scene

Then for lights off you have a rule:
Condition: Motion inactive
True: Activate Captured Scene with delay of 1 min with cancel on Truth change.

This way, there will be no re-capturing.

I'm going to have a look at that.
CT, is that color temperature? I was looking for a place where I could use color temperature as a condition, but I couldn't find it (I didn't look into Global Variables...)

I will be home in a few hours, then I'll test and report back.

Yes, that stands for color temp. You're right, color temp isn't available as a condition but dimmer level is.

@bravenel is there any way that color and color temp could be added as conditions to Rule Machine?

Thank you, thank you, thank you!!! I've used dimmer values for two lights to minimize the chances of accidentally making a scene with the same values.

I just have one more question: will the false (second) rule not be running all day, every day? Is that a bad thing? Should I make the second rule a triggered rule as well?

Color would not be so easy to add, since it is a compound device with multiple attributes. There would have to be Hue and Saturation as separate conditions. You'd have to show me a convincing use case that needs this and that overcomes the compound problem -- you couldn't just say "red". Color Temperature would be more straight forward, but again, what is the compelling use case?

I will leave that to you @pietsnot. I have been able to use dimmer level for all of my use-cases. Then again, I don't have all that many color or color temp bulbs either.