Question about rule machine repeat

@bravenel

there seems to be a bug in rule machine latest version.. according to documentation i should be able to do a repeat n times with no delay.

it will not let me do that as there is no save button that comes up unless you pick a delay time .

That's a documentation misreading. There must be a time for the repeat. You'd burn your hub up otherwise.

It's called the repeat interval, and it must be present:

1 Like

i dont want a timed repeat .. i want a for loop that was document as above just repeat n times.

i basically want to do this
delay 1 sec
turn on switch
delay 1 sec
turn off switch
repeated 10 times..

if i put any time in the repeaat loop it does not correctly delay 1 sec on 1 sec off 10 times.

i can hard code it x times without the repeat and the timing that way seems to be correct but not when i put it inside a repeat..

That's how it works. There is no loop without a repeat interval.

To get what you want, put one of the 1 second delays in the repeat interval. Like this:

Delay 1
Repeat 0:00:02  10 times
   Turn on switch
   Delay 1 second
   Turn off switch
ENDREP

The repeat interval time starts at the beginning, so if you work out the timing, every 2 seconds it will turn on the switch, delay a second, turn it off. That means that after it turns it off, it will turn it on again 1 second later, when the 2 seconds is up.

This could be simplified like this:

Delay 1
Repeat 0:00:02  10 times
   Turn on switch
   Turn off switch delayed 0:00:01
ENDREP

I'm not sure I see a problem with the docs, assuming you mean these: https://docs.hubitat.com/index.php?title=Rule-5.0#Repeat_Actions

They say:

Portions of, or all of the script of an Action [sic.] can be repeated periodically, but you must specify the time interval for the repetition.

(first sentence in the page anchor link I provided above)

However, I see where the examples don't exactly show this, but they're more of a pseudo-action in that none of the options you need for a repeat are provided. Perhaps that could be clarified.

Since you're on Rule 5.1, I might also suggest the new Rule 5.1 docs: https://docs.hubitat.com/index.php?title=Rule-5.1. These are not yet linked to from anywhere (though a user earlier today apparently managed to find them with a search) but will be when they are more complete, and they now also needed to be updated for 2.3.1. However, they are completely re-written, and I believe the explanation of repeats in these is correct.

thanks in my two tests not using the actually device yet it seems to screw up at the end.. ie see logs..



added extra delay at end see if that fixes it and i can actually reset the device

Turn on Action logging in the rule, and show that instead. That's how to tell what the app is doing.

yA THANKS. working as designed now. but still cannot get the stupid timing exact to actually reset the damn lights that act up every so now and then and i have to reset and readd them via zigbee pairing.. i was able to do it manually today with putting switch behind the lights and turning it on off frm the dashboard.. but cannot get the timing exact in the rule probably due to delays.. you would think the rule would be more precise and easier to use than manually doing it.

thanks for your help. will keep futzing with it.. as we go out of town and once every month or two one of these lights freezes and needs to be reset..

The reset timing isn't exact itself, and is somewhat a hit or miss proposition, at least in my experience.

Here is my Reset rule. Works very well.

Consider making the repeat 20 (or 19) times, eliminate the on/off and delay, have the single action in loop be to toggle the light. Before the loop, you could have a delay, turn light on, then delay, to initialize the state of the light.

Why do you need 20 On/Off cycles?
Spec clearly calls for only 5 On/Off cycles with very specific timing.
Keeping a valid timing with manual On/Off cycling is not an easy task.
My automated Reset rule does it job with 100% success rate.

After 5 On/Off cycles the device instantly goes into pairing mode.
In this case continuing toggling power is not a good idea.
And it could be even harmful to the device but this is questionable.

The gardenspot lights call for 10 on off cycles . It also will depend.on the speed of the switch i have behind them.... but thanks.i.will try your delay timing.

Because the OP had 10 on and 10 off. If you re-read my post, I suggested using Toggle as the single and only action in the loop. Each time through the loop, at the loop timing set for the repeat, the on/off state will invert. That’s how Toggle works.

Here is a more complicated Rule that uses this. The only action of concern for the OP’s purposes is the first action of the Repeat, namely, the Toggle, which flashes the undercounter vanity lights at a slow rate when any of the alarm conditions of the Litter Robot are met.

toggle will not work.. it is very specific timing that needs to turn the light on off for the reset

Sure it could work, like this:

Turn on switch
Delay 0:00:01
Repeat 0:00:01  19 times
   Toggle switch
ENDREP

You have to decide if you want it on or off at the end, and whether it starts on or off... But that shows the basics of how a toggle could work.

Well, Bruce types faster than I can, but here is the post that I prepared in response to your remark that Toggle didn’t work. It has an initial delay that Bruce missed. I have no idea why you wanted that initial delay, perhaps because your rule was triggered by something else.

That’s confusing. Your original example said:

Unless I am missing something, that’s a Repeat loop with a 1 second timing, thus (with pre-initialization as I discussed, to get the light in an initial “on” state after an initial delay):

image

ahh got you .. i thought toggle turned it on and off. both.. ok one less delay to set.. will give it a try..

Thanks all.. didnt need 10 times.. only 10 including on and off this. rule seems to work well..
3 for 3 reset both of my lights in testing..

these are for sylvania gardenspots.

1 Like