Rule fails on a first run but runs OK every next time

Here is my very simple rule for resetting Hampton Bay Zigbee Fan Controller:

And here is a related log:

This rule always fails on a first run (after few min delay) but runs just fine on every sequential
attempt if delay between runs is less than 30sec. The behavior is very consistent and 100%
repeatable. On a first run the repeat loop is executed only once (please check the log above)
but every other time loop is executed the expected 4 times. This rule was created about
3 years ago on a C7 hub and migrated to the C8. On C7 the rule was running flawlessly.
But this is very first time when I had to run this rule on the C8.

What is this about?
Is it a problem with a DELAY statement inside the REPEAT loop?
(Is this something similar to the problem using a DELAY inside IF-THAN?)

It is possible you have two instances of the rule "running" at the same time. Since this rule has no triggers, presumably you are invoking it via some other means, perhaps running the actions from another rule. Nothing in this rule prevents re-entry into the actions (what I really mean with the above), and perhaps nothing in your other rules do either. I could see that causing unexpected results with timed actions like delays and repeats.

Enabling all logging, not just action logging, could help show more if you haven't done so already. (I'm actually not sure what this will show in the above case, but it can't hurt.) Otherwise, if you know when you started running the actions--assuming your logs show more than one such time--noting that may help at least make the logs clearer.

There shouldn't be any problem with delays inside repeats. However, if you want them to be cancelled upon re-entry into your actions, marking them as "cancelable?" and using "Cancel Delayed Actions" at the start of your actions is one way to do that. That is an easy fix, assuming that this is also the behavior you'd want in such a case.

No, this is a triggerless rule and the intention is to run it manually only by clicking on
"run Actions" buttons. This way it is 100% guarantied only single instance is running.
I replaced a DELAY inside REPEAT loop with "Wait for Event -> Elapsed Time" and the
behavior is exactly the same. All logs for rule are enabled. I am not sure what else
I should look for. The only good news - this problem is very easy to reproduce.

I would suggest hitting Update Rule (or Done; same thing except that takes you away from the Rule page) before trying again. This will re-initialize everything and erase schedules (from delays, repeats, etc.), which could help.

If this still happens, can you note in the log screenshot any time you hit Run Actions? It seems your original screenshot must have at least two executions, though it's not clear when they started. It is true that you will not see anything in Logs from hitting this button.

OK, I tried this suggestion but it did not work.
Here is a clean log:

As you can see REPEAT was running only once.

Here is a normal log for the run after about 3 min delay between runs:

Now if I wait a bit longer (10 min or so) the problem will come back.

Just a thought - test that using a new Virtual momentary switch as the trigger, instead of using the app itself. See what that does.

...bob t

Since this rule is small and simple, consider just re-creating it to see if the problem still happens then.

I have two the same rules. And now both are doing the same thing.
Both came from C7 and never had a problem running on C7.
OK, I will re-create one and try it as a fresh creation.

Notice you are using repeat N number of times. See the known issues with the latest release:

I have a rule that fails too and had to rework it until the next release is available


Oh, OK. And Thank you.
This is a known problem ...
I did not use this rule for a long time and missed this issue.

1 Like

Download the Hubitat app