I haven't read through all of the rule above, but I'm guessing it may also work for you (she has a lot of rules for pretty much any situation anyone asks for and is great about sharing!). However, if you're mostly happy with what you have now, there are two small changes that will make it work as you expect:
- On your "Delay 0:02:00" action, toggle the "Cancelable" option to on.
- In your actions for when the motion sensor is active (e.g., before your "On: ..." action), add a "Cancel Delayed Actions" action.
If you're familiar with webCoRE's Task Cancellation Policy (TCP), Rule Machine does not have anything exactly like that by default; you have to manually create the same effect yourself, which is exactly what this does for you (cancels the delay action--and everything after it--whenever "Cancel Delayed Actions" is run, which happens every time motion goes active again; otherwise, those "Off" commands won't get un-scheduled and so will run even if the sensor goes back to active).
You don't need to add the contact sensor as a trigger if you only want to verify that it's open before you turn off the lights. (If you think there's ever a chance that the motion sensor could go inactive before the contact sensor becomes open, then you might want to, but I'm guessing this is is unlikely since the sequence of actions is likely to be getting up off the couch, causing the contact sensor to open, then walking out of the room, causing the motion sensor to go active and eventually inactive, both of which will cause your rule actions to run and therefore your
IFs to be evaluated.)
Another alternative: I do something same with a pressure mat hooked up to a contact sensor under my couch (fantastic idea, by the way!), but I trick Hubitat into thinking it's a motion sensor using a virtual "motion with switch" driver. Every time the contact sensor closes, I send an
on() to that driver, which causes motion to become
active, and the opposite when it closes. Then I can use this virtual "motion" sensor device in any Hubitat automation that wants a motion sensor--opening up far more possibilities than a contact sensor generally does for lighting automations (e.g., you could use it as a "keep on" but not a "turn on" sensor in Motion Lighting). But you've pretty much got it in RM if that's what you want, so whatever works!
PS - I suppose there is more to your piston, setting specific settings based on mode. You can certainly do that in Rule Machine as well--"Set Dimmers Per Mode" will let you set
level, but you'll get a but more power if you create scenes (probably easier than specifying all these settings in the rule anyway) and use "Set Scenes Per Mode" (also available in Motion Lighting if you choose to use that instead).