Cats need help with repeating rule

I've put a contact sensor on a robot cat litterbox - the goal is to reboot the litterbox if it gets stuck, wait a few minutes then keep rebooting it every few minutes until the contact sensor is closed.

The logic should be: when contact is open, wait 4 minutes for a cycle to complete then check sensor status. If the sensor is still open, reboot a smart plug, wait 3 minutes, reboot if sensor is still open and repeat this until the sensor is closed.

I'm having issues canceling the repeating and think I'm missing something simple here. I've watched the live logs and it looks like after the 4 minute delay, it just jumps back to the repeating block without checking the contact sensor status.

Any help would be appreciated. Thanks!

Change the trigger to changed, right now your rule will only trigger when the sensor becomes open.

I just changed the trigger and it's still not working right. I've looked at the logs and don't know why it's behaving this way.

Try moving the Delay 0:04:00 (cancelable) inside the first IF statement before the Repeat

2 things:

  1. remove the second if/endif, it isn't needed. It won't hurt anything, but to keep it simple
  2. hit the gear icon and go all the way down to the bottom, see if there are multiple future actions scheduled.

when you power cycle, does the box reset itself and move something that would re-trigger the sensor? If so, you can gave the reset triggering itself to reset again and again...

@napalmcsr When I reboot a plug, the litterbox will run through a cycle which will open the contact sensor.

Here's my edited rule:

Here's the log where it keeps looping:

I checked and there are no scheduled jobs for the rule.

I've been fighting with this a while now. It's super annoying to deal with because each cycle takes a while to complete!

I think you might need to put a latch in there, so the rule only runs once after the repeat starts.
if litterbox open and private boolean(PB) is false
set PB to true
Do actions
else
set PB to false
Do actions
end if

I just created this from scratch and it seems to be working for me:


Obviously not exactly the same things going on since I have to simulate the cat box sensor with a door, but it seems to work how you're expecting. I even tried "bouncing" the sensor and everything seemed to work right: so long as the contact closed, pending actions were cancelled and repeating actions were stopped. Maybe it's not reliably ending in a closed state? Bouncing a bit and packets received out of order?

@mitchp Hmm, you might be onto something with packets being out of order - one thing I didn't see in the log for this rule was that the contact sensor registering as closed. The device page for the sensor showed it as closed so its status is not making it to the rule for some reason.

Are you using a real contact sensor or are you simulating one for testing? Because the logs your posted appear to have two Open events in a row, which shouldn't be possible. I would turn debug logging on for the contact sensor and repeat the test.

@Ryan780 I'm using a real contact sensor.

@mitchp Your words "created this from scratch" made me create a new rule from scratch and it appears to be working now! I still have to test the rebooting logic but at least it isn't endlessly looping anymore. I don't really understand why this would be the case but it seems that all the editing/pausing/resuming I did to the original rule messed something up.

Thank you for the help everyone. The next time I run into something like this I'll try creating the rule from scratch :grinning:

1 Like