Light and Fan automation help

Hi, I'm new here so bare with me, here is my rule:

IF (WC Motion Sensor active(F) [FALSE]) THEN
	On: WC Lights
	On: WC Fan --> delayed: 0:03:00(cancelable)
ELSE-IF (WC Motion Sensor inactive(T) [TRUE]) THEN
	IF (WC Fan(on) is off(F) [FALSE]) THEN
		Off: WC Lights
		Cancel Delayed Actions
		Exit Rule
	ELSE
		Off: WC Lights
		Off: WC Fan --> delayed: 0:08:00
		Exit Rule
	END-IF
END-IF

It looks its stuck on "On: WC Fan --> delay 3 min" and even the motion become inactive it doesnt turn off the light. How should be done properly.

The idea is: on motion turn on light,, 3 mins later the fan, if motion inactive in the first 3 mins turn off light and exit rule, if, motion become inactive after the 3rd min turn off light and weith another 8 min to turn off the fan.

Thanks !

First, no rule is complete without a picture of your triggers (and required expression, if used), not just the actions. But I can reasonably guess that your trigger is probably something like "motion changed." If not, that's likely part of the problem.

Back to your actions, the only thing I can see offhand is that nothing will cancel the Off: WC Fan --> delayed: 0:08:00 when motion becomes active again. Also, nothing will cancel the On: WC Fan --> delayed: 0:03:00(cancelable) action when motion becomes inactive if the fan is already on, but that seems less likely to be noticeable. You could fix the former by adding "Cancel Delayed Actions" somewhere in the IF THEN half of your rule--or just at the beginning before the IF THEN at all and remove it everywhere else, since it seems like the kind of thing you want to do all the time anyway.

A second issue is that it sounds like you want to wait for motion to remain inactive for three minutes before turning off the lights. You aren't; right now, you're doing it right away. You could add a delay on the Off: WC Lights actions to make that happen.

Also, something that isn't a problem but is good to know (and may be the reason you didn't think of the above): your "Exit Rule" actions aren't doing anything here. They simply stop the rule from performing additional actions, but that action would be the end of execution in all instances in your rule anyway. They do not unschedule, unsubscribe, etc. anything that the rule has already set in motion.

Finally, if you aren't sure what a rule is doing when, logging is a valuable tool. I'd suggest enabling at least Event and Action logging for this rule, then watch "Logs" (or look at "Past Logs" there if the page wasn't open at that particular moment), and you'll see what the rule is or isn't doing when. This can be incredibly helpful when troubleshooting a rule--or any app--that isn't working as expected.

You are completely right. First my triger wasa on sensor active (dont know why...). Now my rules like this and on initial testing its doing what i wnated :slight_smile:

IF (WC Motion Sensor active(F) [FALSE]) THEN
	Cancel Delayed Actions
	On: WC Lights
	On: WC Fan --> delayed: 0:03:00(cancelable)
ELSE-IF (WC Motion Sensor inactive(T) [TRUE]) THEN
	IF (WC Fan(on) is off(F) [FALSE]) THEN
		Off: WC Lights
		Cancel Delayed Actions
	ELSE
		Off: WC Lights
		Off: WC Fan --> delayed: 0:08:00(cancelable)
	END-IF
END-IF