Rule Help

Need the experts on this one. I've tried fixing it but nothing seems to work.

I keep getting this error: java.util.NoSuchElementException: Cannot pop() an empty List on line 6666 (delayedActsCancel), which I think means multiple instances of the rule is running. I have the delay in there because I don't need it running right away since first run through a repeat doesn't wait.

Thanks for any help.

What are you trying to do? Usually best to start there as often people create crazy complex rules when it's just not necessarily need. The issue is it's setting the delay then the motion sensors change state and again another instance is created and delayed. You now have 2 versions of the rule before the 1st can finish. Then again it happens and so on. What's needed is the rule to run correctly and cancel and start the delay again if needed before it runs. But need to know what it you are trying to do in plain English 1st.

1 Like

That is what I would like to know too. Wow, that is an -interesting- rule. I am not quite sure how else to describe it!

It appears you are trying to arm the alarm by motion? That seems like a weird idea in the first place if that is what you are trying to do. I am far from a security expert, but don't most people have a button or keypad or something like that to put the alarm into armed mode? And I don't think that is the correct rule structure to do so.

1 Like

could try making the delay cancellable and adding stop cancelled items along with stop repeat, but the error typically comes from a delay in progress while the rule exits

definitely would appreciate this. from looking at the rule, you have repeats of the conditional, which i a bit weird

Sorry , I forgot the plain English explanation. I am trying to arm ring after motion is detected (and stopped), doors are closed and is between a certain time. I have the conditions repeated in the repeat to make sure they are still true/false before arming. For example, rule is trigged within time frame but when delay is over it no longer is so I don’t need rule to run.

I do have keypads and the app to arm but sometimes someone lets dogs out and forgets to rearm it. One is old and takes forever which is what the delay and repeat is for.

I did try making the delay cancelable and canceling it but that didn’t work. Wouldn’t the ruleactive variable prevent multiple copies from running?

I hope all that makes sense.

Technically, your rule should work. It could definitely use some consolidation - there are ways to avoid needing that many nested ifs. But the rule should work ok - if it was a standalone app. But rule machine rules can get messed up by repeated triggers when there are nested ifs, using repeats, and/or delays. There are ways to avoid it, so you can make a rule that will work.

First a couple of suggestions. Instead of doing so many separate IF statements, you can use AND in the condition to put a whole bunch of conditions into one IF statement. For example:

IF the time is between 11 pm and 7 am AND the alarm mode=off AND the doors are all closed AND the motions sensors are all inactive THEN…

Also, you are checking conditions twice, because things might change during the delay. The only situation where the time would be out of range after the delay would be for any triggers that happen after 6:35 am. If you get a trigger at 6:34 am, after the 25 minute delay it will still be before 7 am, but a trigger at 6:35 or later will be at or beyond 7 am. So just end the time range at 6:35, then you don't need to recheck the time again after the delay.

Since, the placement of delays in conditional statements can get touchy, you might try moving the delay to before the repeat. You will get exactly the same results, with less chance of an error. It will wait 25 minutes, then do the stuff in the repeat, then repeat that stuff every 25 minutes. That way you don’t need delay inside the repeat.

Your ruleactive variable should prevent repeats of the rule, but there is currently bug in Rule Machine. “Stop Repeating Actions” takes awhile to totally stop things. If you have a 25 minute repeat, you stop repeating actions, and then get another trigger within the next 25 minutes, your repeat will be un-stopped. I had pointed this out in another thread, and Bruce Ravenel looked at it and said it there is something not working right and hopefully it will be fixed in the next release. But there are ways to make a rule that avoids that problem. Your error actually involves the delay - “(delayedActsCancel)” is mentioned in the error - but could also be a result of having the delay inside an IF statement and then repeating it - and the repeats may be caused by the bug I mentioned.

You definitely want to cancel delayed actions. Also, you really only need your motion triggers to look for Active, not changed. That can cut down on extra triggers.

Before going any further, I have a couple questions…

If the alarm is armed, will the motion sensors set off the alarm? Is that why you are waiting 25 minutes after the motion stops?

Sometimes a solution to problems like this would be to break the rule up into a couple of smaller rules. It can probably be done in one rule, but it may be simpler with more than one. A lot of people prefer to have one rule and don’t want to use a two rule solution. What is your preference on that?

Forget my question about the motion sensors and the delay. I was thinking you said that someone who lets the dog out is old and slow, so you have to wait for them to get out of the room before enabling the alarm. I just figured out one of the dogs is old and slow(DUH), and you have to open the door to let it back in, so you need a delay before turning on the alarm. Still want to know about your single vs double rule preferences.

Thank you for all the good information and suggestions @geroose and everyone else. I don't mind if it is more than one rule. With that said and your suggestions, I rewrote the rule. Testing it worked without any errors, what do you think?

Yes, it's the dog thats slow. :slight_smile:

Info: All the helper rule does is call right back to this rule.

1 Like

Yes! That's much better. And I like your roll-your-own repeat, very cool. Good job!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.