Turn plug on if motion - what am i doing wrong!?

I'm trying to turn a plug on if there is motion then turn off after 45 mins if motion is inactive however the plug stays on if motion keeps being detected. Unsure where i'm going wrong. I currently have this:

Trigger
Front Room Sensor changed

code
IF (Front Room Sensor active(T) [TRUE]) THEN
Cancel Delayed Actions
On: Sonos System --> delayed: 0:45:00 (cancelable)
ELSE
Off: Sonos System
END-IF

Any ideas?

2 things:

  1. I'd use simple lighting.

rule:
IF (Front Room Sensor active(T) [TRUE]) THEN
Cancel Delayed Actions
On: Sonos System
ELSE
Off: Sonos System--> delayed: 0:45:00 (cancelable)
END-IF

1 Like

The cancelable & delayed actions should be against the OFF action...

If
front room sensor is active then
Cancel delayed actions
On sonos system

else
off sonos system delayed 45 minutes cancelable
end-if

this one will work - leave your trigger as you have originally set up

perfect seems to be working now! Thanks

I was going to use the simple lighting however i'm trying to make it part of a larger rule where i can turn a virtual button on/off which would allow the rule to be on auto or manual override

1 Like

Looks like you've got this rule sorted out above. Hooray for the community!

You may be interested to know that there is an example exactly like what you want in the Rule 4.0 docs, which I'd recommend reading. Too late to save you some time here, but maybe for the rest of this rule or the next one, you'll discover something helpful. :slight_smile:

1 Like

This is what I’ve been looking for! Will have a read

For all your future documentation desires: the "?" icon in the upper right of any app that has one (which should include all the native ones) will take you to docs for that app:

image

(For RM that will technically take you to the docs Wiki, not the forum thread I linked to above, but the wiki page was created from that post, and I find the post with inline screenshots easier to follow.) In 2.1.9, you'll also see a new video link next to that, which in this case will take you to an RM video on Hubitat's YouTube channel (but there are more if you just go to their channel).

The docs.hubitat.com site is also good (and where most of these will take you), also accessible from the "Documentation" link on the main page in the admin UI and the footer of every page.

Good luck!

1 Like