Rule machine : trigger sequence

Hi, is there a way to make a trigger sequence in RM ?

What I am trying to do :

Example : front door is unlocked, then front door contact is opened, then entrance motion detector is activated -> turn on the light

Garage door is opened, then garage-kitchen lock is unlocked, then garage-kitchen contact sensor is opened -> turn on the light

Thanks !

i dont think so triggers are stateless
two ideas

  1. setup virtual switches for each event and multiple rules.. pain in the butt.

rule
trigger: front door unlocked
action:
wait for event contact opened timeout = xxx
wait for event motion timeout =xxx
turn on light.

only issue is how you still may need some switches as settings or else after it times out it will goto next wait and still eventually turn on light

Thanks ! I was thinking about virtual momentary switch. I will try your second point.

this looks better nested ifs

trigger: front door unlocked
action:

wait for event contact opened timeout = xxx

if door unlocked and contact open
wait for event motion timeout =xxx

 if motion active 
  turn on light
end if

end if

1 Like

Just don't set a timeout, then it will only move on if the event actually happens. This is what I was going to suggest. You're correct that you can't handle this with triggers alone, but if you trigger on the "first" action, then "Waits" will create the necessary subscriptions and get you where you need to go (if the events happen).

1 Like

that doesnt sound good. if it waits forever..., although i assume re-entry will cancel any old waits?

Yes, all waits get cancelled when a trigger event happens, so that isn't a problem. Nor is waiting "forever" per se since a wait just creates a subscription--same as a trigger would do--and then the app/rule sleeps until an actual event wakes it up. But it does bring up a related issue for complicated sequences like the poster's second example: is there ever a time when that sequence could happen, even with a bunch of time passing in between, and then you wouldn't want this rule to do anything since it's been "too long" since the initial event/trigger? I assume the idea is that these events usually happen in this order and you just want to wait until the last one so the light doesn't get turned on "early," for example, but my idea would not handle stipulations like this as-is.

ya the timeouts allow you some control to specify how long is too long, i assume it would still work ok with the timeouts and the extra if's if you want to have a little finer control. but you are right if you don't care than they are not needed.

Thanks a lot to both of you. It is the first time I use the wait condition. I tried without delay and It works perfectly.

Create a local string variable (i.e. Timeout) then after each Wait add the following:

Set Timeout to %device%
IF (Timeout = 'timeout') Exit Rule

Org post talking about this technique [2.2.4.158 C7] Need a way to detect/act on wait timeouts - #3 by bravenel

Better just to check the device with the if.. doing the same thing and less intensive. If it exited the wait and the device is not in the desired state it means it timed out. But f
Good to know how to check directly.

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