Rule Machine - Execute rule based on condition staying the same

Hi,

New to HE, 2nd day.

I'm trying to migrate my pistons from WebCoRE to Rule Machine and for the most part I've had a good degree of success, however I am struggling to replicate the attached piston in Rule Machine.

Basically this is a lighting automation that turns on the bedroom lights on motion, but not if the bed has been occupied in the last 3 hours. The 'Occupancy' sensor is driven by a Sleep Sensor that turns a virtual switch 'On' when there is someone in the bed, and then 'Off' when the bed is unoccupied. The reason I have a 3 hour timeout is that sometimes if one person gets out of the bed you wouldn't want the lights triggering immediately, and if you move around during the night sometimes the sensor can toggle.

In Rule Machine I'd like to be able to set the trigger as the motion sensor detecting motion, but a condition would be that the 'Master Bedroom Bed Occupancy' switch has been 'Off' for at least 3 hours, otherwise the rule shouldn't run.

Does anyone have any advice please?

I did look at this thread - although it seems to refer to an action happening if a sensor has been open for longer than x, rather than action 'not' happening because a sensor has stayed the same for x.

Thanks
Guy

You'd probably use one rule just to deal with the 'Master Bedroom Bed Occupancy' switch timing. You could have a rule triggered by it turning off, and delays by 3 hours setting a global variable to true (set to false by the switch being turned on, perhaps). Then the motion rule just tests the state of that variable. If false, exit the rule.

4 Likes

Excellent - thanks I've now set this up in Rule Machine to have a virtual slave switch which acts on a 3 hour delay on the master switch. I'm liking how fast everything is with Hubitat, not looking forward to the eventual exclude/remove and then re-add from ST to Hubitat!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.