Rule Machine 5.1 Wait not working as expected

Hi there,

I cannot get something seemingly simple to work.

I have a Meross plug (triggered via IFTTT) that turns on Christmas tree lights and an audio track that plays when motion is detected on a sensor - I only want the track to play every 30 minutes if motion is detected and also for the plug to turn off after 30 minutes if no motion.

Here is the rule;

The problem is that the track plays every time motion is detected, but the light turns on and then off perfectly at 30 minutes.

Any idea how to fix this? I have tried time out, duration plus condition instead of expression and ever a simple wait with no luck.

Any ideas please?

I think what you want to do is to put the playTrack and Wait inside of a stoppable loop that repeats every 30 minutes. I've not tried the wait inside the repeat but I believe I read that this should work.

Actions to Run
On: Christmas Tree On
Repeat every 0:30:00 (stoppable)
    PlayTrack...
    Wait for Expression... -->duration: 0:30:00
    Stop Repeating Actions
END-REP
On: Christmas Tree Off

Yes every time the sensor goes active it will trigger the rule again. A wait is stopped by a rule trigger

Another approach would be to use the private Boolean True as a required expression. Then set it false as the first action of your rule. Then back true as the last action in your rule. Then once the rule is triggered it can't trigger again until it has completed.

1 Like

The suggestion I made sort of works. Every time the loop repeats the Wait is overwritten and the duration begins again. Depending upon when the motion goes inactive, the desired off action could take almost an hour to happen. I think I would approach this with two rules. The first rule would trigger on motion, turn on the tree, and loop the track every 30 minutes. The second rule would trigger on the inactive duration, stop the repeating actions of the first rule, and turn off the tree.

Rule 1

Trigger Events
Motion active

Actions to Run
On: Christmas Tree On
Repeat every 0:30:00
    PlayTrack...
END-REP

Rule 2


Trigger Events
Motion inactive and stays that way for: 0:30:00

Actions to Run
Cancel Timed Actions: Rule 1
On: Christmas Tree Off

That seems to work - thank you!

Download the Hubitat app