Help With A Rule For A Noob

Hi, I think I have this rule close, but I definitely

think I have it setup wrong. The goal is that if the printer drops below 10 watts I want it to wait 5 minutes, and if it is still that low then it shuts off.
At first I just had it shut off if it went below 10, but sometimes the printer drops that low while still printing, but then it goes back up quickly. Whereas if it is done printing it will stay low. Here is what I have, any help is appreciated.

One problem I see is that if you happen to get that dip five minutes apart you can trigger a false shutdown. It is an edge case but it could happen.

1 Like

The first thing I'd consider is that any time your trigger matches, your rule actions will start running again (from the beginning). Therefore, any time you get a new reading lower than the previous, your first action (conditional) will run again--but that delay from the old one will still be hanging around. Nothing stops those unless they are cancelled with "Cancel Delayed Actions."

I think it might be better to re-think this rule with a slightly different pattern. Here's what I'd try:

Triggers: Power > 10

Actions:

Cancel Delayed Actions
Wait for event: Power <= 10
Delay 0:05:00 (cancelable)
Off: 3D Printer Power

This takes a slightly different approach by waiting to see when the power goes above 10 W (presumably indicating that you've started to use the printer), then waiting for it to drop below and stay there for at least 5 minutes. Note that in-progress "Wait"s are cancelled any time a trigger matches, so you don't have to worry about anything beisdes the delay here.

You could also do this using the "classic" RM paradigm: a "power changed" trigger with an IF THEN/ELSE in the body to handle whether the power is above or below, but the above is a pattern that has been recommended more lately.

PS - You are missing END-IFs in your rule as written, but that won't affect the outcome in this case--just nice to know if you do in the future. :slight_smile:

3 Likes

Maybe something along these lines?

Trigger: Power level changes

IF (power < 10) THEN
   Off: 3D printer DELAYED 5:00 CANCELABLE
ELSE
   Cancel delay
ENDIF

This way it the power goes over 10 it will cancel the delayed off. The problem here is that if the power fluctuates under 10 it will reset the 5 minute wait. So that depends on what the draw is during idle. Will it continue to trip the trigger?

EDIT: @bertabcd1234's idea of tracking the high state instead of the low state is better than the above.

1 Like

Like that?

That's what I was thinking. The rule by @lairdknox is the other way I mentioned but was too lazy to write out. :slight_smile: Either way should work. Both assume that your outlet is able to report these changes (many of mine are configurable to report certain percentage or amount-of-Watts changes; I'm assuming you've verified with your device's history of reports/events that either of these is likely to work as you expect or could adjust either the rule or device if not).

1 Like

The device shows the power changes constantly.
Thank you for your help.