RM is still canceling/restarting delay on truth change, regardless of setting

Hello there, I've got a rule that is evaluated on whether or not my dryer is vibrating.

Vibration inactive: FALSE

  • delay 3 minutes.
  • notify "Detected cycle!"

Vibration inactive: TRUE

  • delay 5 minutes,
  • notify "Cycle not detected"

I've tried removing the cancel on truth change completely, etc, but it still resets the timer every single time the rule goes from true to false.

app:5522019-02-15 05:29:30.658 pm infoBack Porch Dryer 2 Start Vibration Rule is now False
app:5522019-02-15 05:29:30.640 pm infoBack Porch Dryer 2 Start Vibration Rule is False, but delayed by 5 minutes
app:5522019-02-15 05:29:30.593 pm infoBack Porch Dryer 2 Start Vibration Rule: Back Porch Dryer Sensor acceleration active
app:5522019-02-15 05:29:23.464 pm infoBack Porch Dryer 2 Start Vibration Rule is now True
app:5522019-02-15 05:29:23.452 pm infoBack Porch Dryer 2 Start Vibration Rule is True, but delayed by 3 minutes
app:5522019-02-15 05:29:23.402 pm infoBack Porch Dryer 2 Start Vibration Rule: Back Porch Dryer Sensor acceleration inactive
app:5522019-02-15 05:29:20.326 pm infoBack Porch Dryer 2 Start Vibration Rule is now False
app:5522019-02-15 05:29:20.309 pm infoBack Porch Dryer 2 Start Vibration Rule is False, but delayed by 5 minutes
app:5522019-02-15 05:29:20.248 pm infoBack Porch Dryer 2 Start Vibration Rule: Back Porch Dryer Sensor acceleration active
app:5522019-02-15 05:29:15.057 pm infoBack Porch Dryer 2 Start Vibration Rule is now True
app:5522019-02-15 05:29:15.042 pm infoBack Porch Dryer 2 Start Vibration Rule is True, but delayed by 3 minutes
app:5522019-02-15 05:29:15.003 pm infoBack Porch Dryer 2 Start Vibration Rule: Back Porch Dryer Sensor acceleration inactive
app:5522019-02-15 05:29:11.766 pm infoBack Porch Dryer 2 Start Vibration Rule is now False
app:5522019-02-15 05:29:11.749 pm infoBack Porch Dryer 2 Start Vibration Rule is False, but delayed by 5 minutes
app:5522019-02-15 05:29:11.704 pm infoBack Porch Dryer 2 Start Vibration Rule: Back Porch Dryer Sensor acceleration active
app:5522019-02-15 05:29:05.466 pm infoBack Porch Dryer 2 Start Vibration Rule is now True

I'm essentially trying to do a cumulative timer after the first event starts. Vibration detected? If it detected several times over many minutes, then clearly the dryer is running, then we enable another rule for cycle-end-detection. Obviously I could do this easily with a custom groovy app or WebCore, but I'm trying to play by the rules and have a stable system.

If I am not using "cancel on truth change," why is the timer restarting every time? How exactly does this mechanism work?

Thanks!

Could you show a screenshot of your rule?

So originally I thought I would have a rule where either true or false delay WOULD have cancel on truth change, so I'd have cumulative timer on true, and have it purposefully reset on false. That didn't work either. Just resets the timer as seen on the logs.

Neither delay has Cancel on Truth Change selected.

Here is what a rule with a delay with Cancel looks like, notice no Cancel on the True action, but with Cancel on the False action:

Correct, so currently the rule has no cancel configured, so why is it resetting the timer every time truth changes? I would think that no-cancel would generate a cumulative timer, of sorts. It appears that every time a rule is flipped to true/false, all the variables are reset, including the timer on delay.

How would one accomplish what I am seeking, if the delay w/o cancel does not behave the way I expect?

Because the action runs, and the action says to delay by x minutes. There is no cumulative timer.

I had a rule for a dryer (turn on a fan while it is running), and it was like this:

Condition: acceleration sensor active
Rule: ditto
Action for true: turn on fan
Action for false: turn off fan after 1 minute (cancel)

Suppose what you want is a notification when the dryer is done. Modifying that rule would be:

Condition: acceleration sensor active
Rule: ditto
Action for true: (nothing)
Action for false: Delay 1 minute [Cancel], send notification

So what happens is dryer starts, rule becomes true, nothing happens. Dryer stops, and there is no vibration for 1 minute, send notification. If the dryer simply paused for 30 seconds, or the vibration wasn't detected long enough for the sensor to go inactive, as long as it becomes active again within the 1 minute, no notification would be sent.

I noticed that my dryer sensor would go on and off active/inactive during the cycle.

Yeah I think I will have to get real creative on this. I need a buffer rule to trigger the detection rule to avoid false notifications. Anyhow thanks for helping me understand the mechanics of the timer!

It sounds like you need to have a rule that determines that the dryer is actually running, and only then allow the notification rule to run. This is tricky to pull off if the sensor is going inactive at times when running, as mine did.

Rule 1: Determine that dryer is running
Condition: vibration active
Rule: ditto
Action for true: set PB of rule 2 to true after 30 seconds, with cancel on truth change
Action for false: nothing

Rule 2: Notify when dryer stops, but only if it was running
Conditions: vibration inactive
Rule: ditto
Actions for true: delay by 1 minute [cancel] send notification, set PB to false
Action for false: nothing
Restriction: Disable with Private Boolean

This assumes that the vibration sensor will stay active for 30 seconds when the dryer is actually running. You might need to play with that time. The point is to filter out active events from the dryer being banged during loading and unloading, door opening and closing.

The first rule determines that the dryer is actually running, and then enables the second rule. Before then, the second rule is disabled. When the dryer stops, vibration being inactive for a full minute, if enabled from the first rule, the second rule sends the notification, and disables itself again.

This whole thing depends on the second rule being disabled by PB. PB starts out true, so we need to get it set to false. Bang on the dryer, second rule runs because it's initial PB state is true. Nothing happens for one minute, it sends the notification and sets PB to false. The pump is now primed. After that initial step, the normal state for Rule 2's PB is false. It will only be set to true by the first rule running -- that is by the dryer being on and vibration active for 30 seconds. Then, when the dryer stops, everything happens as you want and the PB gets reset for the next cycle.

It seems to me the 30 seconds is the key parameter for this to work. You can look at the logs for the vibration sensor to see how long the thing stays active when the dryer starts running.

I am using @bravenel 's example above to setup notification for a dryer. I'm lost on Rule 2, how to set Restriction: Disable on Private Boolean. I'm using RM4.0 ... was that switch(?) deprecated or am I looking in the wrong place?? Thanks...

Restrictions were removed from RM4.0. If you need to use a switch as a restriction, just wrap the whole action in a conditional action based on the switch status.

I'm very new to RM, I appreciate the help. In the above example, So what I tried was to add "Private Boolean becomes True" to the existing condition "vibration inactive" for Rule 2. But RM makes these "or" conditions, but I need "and" since I want both to be true before the rule runs. Am I going about this the wrong way? How to get the rule to run when multiple conditions are true and not just one from a list?

You will have to display the rule but what I suspect you are doing is adding it as a trigger instead of a condition.

Your suspicions were suspiciously correct :slight_smile: This is what I had for Rule 2 ...

I removed Private Boolean becomes true from Trigger events and that left it under the conditions section. So the triggers cause the rule to fire, and the conditions allow the actions within the rule to run? All conditions must be true for the actions to be run?

The dryer just finished and I got two announcements on my echos, so something must be working...

Once you've added it to the conditions list, you then have to add a conditional action to the rule. So, above the first action in your rule, you will add a conditional action where the condition is the PB being true. Then at the end you have an END-IF to close out the conditional action.

Also, your rule doesn't make a whole lot of sense. You have a cancelable delay but nowhere within the rule are you canceling it. So, why bother having it at all? Also, you are setting the PB to false at the end of the rule? Are you setting it back to try somewhere in a different rule?

I'm trying to take the logic that @bravenel had mentioned above (2 Rules) and translate that into RM 4.0. The first rule determines if the dryer is running and the second rule sends a notification when the dryer has stopped running.

The cancel-able delay was my attempt to translate this part of the logic:

What should those steps look like?

The PB at the end of rule 2 is set in rule 1.

At least part of my problem is that I'm using examples (like the one above and from other posts) from earlier versions of RM that had options like cancel on truth change and restrictions, which don't exist now.

Let me start over and rephrase what I'm trying to do:

When the vibration sensor becomes active, I want to wait for it to be active for at least 2 minutes, then I want to wait until it has been inactive for 1 minute.
After it has been inactive for a minute, then send a message that laundry is dry
If it doesn't stay active for at least 2 minutes, then I don't want to do anything.

I've found examples of doing this with time limits (a max) but not with minimum times. If someone could help me get started with an example I'd appreciate it.

The only way to do this is with cancels on your delays.

Create Local boolean variable"Running"

TRIGGER:  VIBRATION changes

Action: 
If Vibration is ACTIVE Then
     Cancel delayed actions
     Delay Actions by 2 minutes (cancelable)
     Set Variable Running to True
Else
     Cancel Delayed Actions
     IF Running is True
          Delay actions by 1 minute (cancelable)
          Send your notification that its done
          Set Variable Running to False
     End-If
End-IF

Now, i see what you are trying to do with this...however, what happen if you stop the dryer and then want it to restart. It would be possible that it would be stopped for the full minute and therefore would not reset the variable to false. So you would get the notification the next time when you didn't really want it. The only way to prevent that is to have a contact sensor on the door of dryer as well.

Thank you! I rarely ever stop the dryer mid-cycle, but if I were to do that (maybe to add something that I missed from the washer) the dryer wouldn't be still for more than a minute. But I assume that I could adjust that second delay if I wanted to allow for more time?
I have been reading as much information as I can find on how "cancel" works but the bulb still hasn't gone off (pun intended). In your example, what happens when the state of the trigger changes (becomes inactive) while you're still in the first delay? Does the state change cancel all actions? What is executed next? That is my main point of confusion, trying to understand the execution order. Thanks again!

If it goes inactive before the 2 min delay, it will cancel the delay (and all actions after it).