Newbie: Rules Firing when should be cancelled

Hi All,

I'm a Hubitat newbie and can't figure out why this isn't working. Lights are turning off randomly when there is recent motion which should have triggered the cancel.

Please help and thank you!

app:452020-11-24 12:17:47.401 pm infoAction: Delay 1:00:00 (cancelable)

app:452020-11-24 12:17:47.398 pm infoAction: IF (Backyard Light inactive(T) [TRUE]) THEN

app:452020-11-24 12:17:47.357 pm infoGreat Room Inactivity Triggered

app:452020-11-24 12:17:47.350 pm infoGreat Room Inactivity: Backyard Light motion inactive

app:452020-11-24 12:15:04.162 pm errorjava.util.NoSuchElementException: Cannot pop() an empty List on line 6839 (delayedActsCancel)

app:452020-11-24 12:15:04.132 pm infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 12:15:04.130 pm infoAction: ELSE (skipping)

app:452020-11-24 12:15:04.077 pm infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 12:15:04.060 pm infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 12:10:17.652 pm infoAction: END-IF

app:452020-11-24 12:10:17.650 pm infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 12:10:17.647 pm infoAction: ELSE (skipping)

app:452020-11-24 12:10:17.487 pm infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 12:10:17.469 pm infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 12:09:33.734 pm infoAction: Delay 1:00:00 (cancelable)

app:452020-11-24 12:09:33.731 pm infoAction: IF (Backyard Light inactive(T) [TRUE]) THEN

app:452020-11-24 12:09:33.631 pm infoGreat Room Inactivity Triggered

app:452020-11-24 12:09:33.612 pm infoGreat Room Inactivity: Backyard Light motion inactive

app:452020-11-24 12:09:22.528 pm errorjava.util.NoSuchElementException: Cannot pop() an empty List on line 6839 (delayedActsCancel)

app:452020-11-24 12:09:22.522 pm infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 12:09:22.519 pm infoAction: ELSE (skipping)

app:452020-11-24 12:09:22.461 pm infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 12:09:22.443 pm infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 12:03:05.861 pm errorjava.util.NoSuchElementException: Cannot pop() an empty List on line 6839 (delayedActsCancel)

app:452020-11-24 12:03:05.854 pm infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 12:03:05.851 pm infoAction: ELSE (skipping)

app:452020-11-24 12:03:05.793 pm infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 12:03:05.715 pm infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 12:02:25.775 pm errorjava.util.NoSuchElementException: Cannot pop() an empty List on line 6839 (delayedActsCancel)

app:452020-11-24 12:02:25.768 pm infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 12:02:25.766 pm infoAction: ELSE (skipping)

app:452020-11-24 12:02:25.710 pm infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 12:02:25.693 pm infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 12:01:48.736 pm errorjava.util.NoSuchElementException: Cannot pop() an empty List on line 6839 (delayedActsCancel)

app:452020-11-24 12:01:48.730 pm infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 12:01:48.728 pm infoAction: ELSE (skipping)

app:452020-11-24 12:01:48.674 pm infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 12:01:48.657 pm infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 12:00:22.665 pm infoAction: END-IF

app:452020-11-24 12:00:22.663 pm infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 12:00:22.661 pm infoAction: ELSE (skipping)

app:452020-11-24 12:00:22.506 pm infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 12:00:22.487 pm infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 11:59:52.809 am infoAction: Delay 1:00:00 (cancelable)

app:452020-11-24 11:59:52.806 am infoAction: IF (Backyard Light inactive(T) [TRUE]) THEN

app:452020-11-24 11:59:52.702 am infoGreat Room Inactivity Triggered

app:452020-11-24 11:59:52.687 am infoGreat Room Inactivity: Backyard Light motion inactive

app:452020-11-24 11:58:08.359 am errorjava.util.NoSuchElementException: Cannot pop() an empty List on line 6839 (delayedActsCancel)

app:452020-11-24 11:58:08.327 am infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 11:58:08.324 am infoAction: ELSE (skipping)

app:452020-11-24 11:58:08.265 am infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 11:58:08.247 am infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 11:55:30.245 am infoAction: END-IF

app:452020-11-24 11:55:30.242 am infoAction: Cancel Delayed Actions (skipped)

app:452020-11-24 11:55:30.240 am infoAction: ELSE (skipping)

app:452020-11-24 11:55:30.187 am infoAction: Off: Great Room Fan, Dining Room Light, Great Room Light, Great Room Fireplace Light

app:452020-11-24 11:55:30.170 am infoDelay Over: Delay 1:00:00 (cancelable)

app:452020-11-24 11:53:26.900 am infoAction: Delay 1:00:00 (cancelable)

app:452020-11-24 11:53:26.896 am infoAction: IF (Backyard Light inactive(T) [TRUE]) THEN

I would put cancel as the first thing, so any event resets the timer
I'd remove the delay on its own and edit off action and put the delay time against that

1 Like

Right, what Mark said is spot on. The first thing in actions should be to cancel delayed actions. You can then get rid of the ELSE and the other one.

1 Like

Thank you! I'll give that a shot!

Did you by chance have this rule without "Cancel Delayed Actions" at one point? If so, it's possible the old delays were catching up to you and still executing what came after (clicking "Done" or "Update Rule" should erase anything previously scheduled, but it's possible to simply add or edit rule actions without doing that).

While the above can't hurt, what you have now really looks like it should work too. Most of the examples in the docs use the conditionals opposite of what you have, but it would be logically equivalent and should function the same way:

Trigger: Motion changed

Actions:

IF (Motion active) THEN
  Cancel Delayed Actions
ELSE
  Delay 0:01:00 (cancelable)
  Off: Lights
END-IF

Additionally, a separate "Delay" action vs. a delay on an action are different in general but not in any way that would matter here. (A "Delay" action stops execution, then resumes with the next action when the delay is up. A delay on an action schedules that particular action for that time in the future. If it's the last action, as it is in all of these, the resulting behavior wouldn't be different.)

So, basically, unless the rule previously existed like this in a different form, I don't see any reason this shouldn't work. That being said, I'd use the built-in Simple Automation Rules (formerly Simple Lighting) or Motion Lighting apps for this particular case instead--they're smaller and likely to run faster, plus they're easier to set up--but if you need the flexibility of RM (Simple Automation Rules can definitely handle just turning off lights without turning them on, if that's the reasoning) or are just trying to learn, I again still don't see any reason this wouldn't work.

Finally, staff have begun suggesting the use of a new paradigm with the same outcome as the above for these situations. Again, what you have should still work, but if you want to see that method, here is one way you could do it:

Trigger: Motion active

Actions:

Cancel Delayed Actions
Wait for event: motion inactive
Delay 1:00:00 (cancelable)
Off: Lights

...except normally you'd have an "On" action for the lights either right before or after the "Cancel Delayed Actions" (in either this or the other example). But again, I don't see any reason either way wouldn't work here...

1 Like

Bert,

For whatever reason putting cancel at the top has worked. I don't sit with 6+ uncancelled event sittings out there. I can't grasp why the else statement wasn't working, but the previous posters advice has worked great.

I thought similar to you, so I let it sit overnight after the rule was updated (1 hour wait time) and in the morning retested and within an hour it was doing same thing, lights turning off randomly because Cancel wasn't happening. shrug

Would still like to understand because this was just POC for much more complicated things I am trying to do. In my smartthings environment with webcore I had everything in the house automated, with locks, garage doors, blinds, water, A/C, outlets, lights, etc. With ST drop of EchoSpeak I have migrated everything over to HE. Trying to understand delay events better and start simple before I make things complicated.

Thanks again!

It would turn it off randomly because if the light went on it set the delay and then the next action was an OFF. So now someone turns OFF the backyard light and the delay is canceled and right away the lights will turn off. You probably would have been okay with your rule if you didn't have the delay command but had a wait 1 hour and a cancelable on the actual OFF command.

To say it another way with the delay by itself it holds up everything below it until it expires but once the time runs out or it is canceled everything below it will fire.

Tivo, thank you. To help my understanding (as a software developer) I'm not understanding.

in pseudo code
If (A = TRUE) {
DELAY 60
RUN SOME ACTION
} ELSE {
CANCEL ALL OTHER DELAYS
}

What doesn't make sense to me is why the DELAY 60 would stop the cancel action, because in some cases A should evaluate as false (motion in this case). If A=False then the sub shouldn't even be evaluated, or does HE follow a different set of rules?

Thank you!

No, this will only happen if the time runs out. A "Cancel Delayed Actions" cancels both the "standalone" delay itself and anything after it that has not yet run (or the action itself in the case of a "delay" on an action, given that--as you state--this doesn't hold up anything after it). This is why I can't think of a reason that the rule shouldn't work as written.

Really? Huh, I was sure it worked that way sorry for any confusion!