Run Rule every X Minutes

What do your rule logs say? If you ran into an execution limit, that would be displayed in the logs. It’s 200 executions per rule per 10 minutes at the moment. It’s much more likely that your rule ran into an issue which didn’t allow the second part of the ‘loop’ to reset. While I don’t necessarily recommend building a looping pattern like this, if you are going to do so, it’s better to keep the loop as its own separate rule and keep it as simple as possible to avoid any potential side effects from the rest of the rule logic (especially something like an HTTP action where there’s potential for timeouts and things of that nature that could cause the rule to error out).

Hi Josh,
I have several timed loops that I use for polling devices and updating configurations. Every once in awhile one of the loops will stop running. Is the 200 executions you refer to a rule running?

Thanks

Per rule. And the rest of my original comment still applies… the design of how the variable is looped is critical. If you have other actions within your rule, if any of those fail and the rule doesn’t run to completion, that can break your rule.

Thanks. I was not aware of the 200 execution limit. My loop only sets the loop variable, nothing else involved. Is there anything else on the back end which could cause the loop to not execute?

The first place to check is always the rule logs.

And how is your rule setup? Sharing your rule design would help the community provide better guidance.

Thanks @josh !

My rule is fairly simple. It executes once / minute. Far less than the 200 / 10 minutes. However, I do make an HTTP call as a part of that rule. While the logs do not show any issue, I have changed the design of the rule as follows. Now i believe the rule should still execute even if the HTTP call fails.

Re-surfacing this topic…

I have a few loop timers (5, 10, and 30 min) that I had been using for about 8 or so months using the set variable/delay logic described above. These had been working somewhat reliably until recently where they timeout at some point during the day and I have to manually restart them by resetting the variable status what seems to be daily. Has anyone else had this issue?

Yes, I see this all the time. It does seem like the stoppages are happening more frequently lately.

Thanks @Nezmo - Do you have a good work around? I was considering building a rule to stop and reset these in the middle of the night but was hoping I was just overlooking something simple. @josh any insight? -Ryan

While the approach used in this thread is popular with the community, it’s not something we officially support since it doesn’t have the reliability we would expect. For example, if there are other actions within the rule and those fail, then the rule can abort before it gets to your ‘loop’ variable.

We’ve been working on some pretty significant platform updates behind the scenes and one of these is a new scheduler mechanism. As part of that scheduler, we are considering introducing native ‘loop’ functionality. We still don’t have the details ironed out and I still have some hesitation as looping is generally an anti-pattern when event-driven rules can accomplish the same thing.

:speaking_head: I’d love to hear the community’s use-cases for looping so I can better understand them as we consider a first-class looping feature. Please share if you have one. :speaking_head:

2 Likes

Just a heads up that there was an issue on Sunday that may have impacted your timer / state stays triggered rules. You can find the details here:

[RESOLVED] Rules not automatically rescheduling - #4 by josh

We are working on identifying the impacted rules so we can automatically reschedule them. In the meantime, if your Timer Trigger rules were impacted, you can re-save them which will automatically reschedule them.

A Loop Trigger would be great, as you mentioned loops in rules break.

I’m asking what the use-case for a loop is that isn’t better suited by an event-driven approach? Can you tell me about the rules you are creating that need to loop rather than being triggered by an event?

Thanks Josh - Happy to hear this feature is coming! My use cases below. Im currently only using loop timers at 5, 10, 30 and 60 min intervals.

  • A backup trigger for thermostat rules and window shade rules
  • Weather API pulls
  • Refreshing device status for devices that tend to timeout when idle for longer periods
1 Like

I use a loop to refresh my Honeywell T5 thermostat’s connection to SmartThings. Without this refresh the data in ST on!y updates a few times a day making it useless in automations.

1 Like

Doing the same with my T6, temperature only gets updated a few times a day, but I want to use my thermostat to drive my AC as well, since it’s better positioned.
So every few minutes there’s a loop to refresh the thermostat and get a temp reading.

I think for the rest, as your suggestion, I tried to remove all others. But that one remains looped…

The best way i would use a loop is for things like if a rule is supposed to trigger but doesn’t, it can keep trying a specific amount of times. Or for like the light fading up or down, I created my own loops where if my bedroom door closes as the fade is happening, it will stop and call another rule to set the lights to a certain level than shut them off. I sleep with my door open, so if it closes, that means im up and out of the room. Idk if that falls in line with what you asked lol

1 Like

@Terri Clever loop workaround. Thanks.

@josh the use case I am trying to solve is I have the pleasure of Optimum cable for Internet service. I am polling a Hubitat cloud endpoint that ‘should’ be changing if everything is working. When it doesn’t change, I send a text notification that the internet service is down. Happens about every 10 days. Polling time is every 15minutes.

1 Like

I believe I have a use case that might be a good answer to the loop-timer vs event-driven approach. Here it is.

I have a mini-split ac unit. I installed a wifi module in it, so I can control the ac remotely. I was able to link it to Smarthings in order to use automations.
The goal is to turn the ac off if a motion sensor remains inactive for 30 minutes, but I only want to run the automation if the motion sensor has been inactive for 30 minutes AND the ac is currently ON.
The problem is that the status of the ac unit only updates when it is turned on/off via smarthings. If I use the physical remote control for the ac unit, the status change is not pushed to smarthings. Which means that one of the conditions will be a false positive.

The time loop/interval would allow me to check the current status of the ac unit every 30 minutes without having to rely on the motion sensor.

Does that make sense?

Thanks

Thanks for sharing.

It sounds like it’s working around a faulty event implementation. In my opinion, the ‘right’ approach would be for the device integration or device driver to be updated so you could properly rely on the device status. I understand that’s not always going to be possible, so I appreciate the example!

What are you doing every 30 minutes to check the current status? Are you issuing a refresh command or something similar?

If that’s the case, couldn’t you still design it in an event driven way? Have the rule trigger when the motion sensor remains inactive for 30 minutes - the first action would be to refresh the status of the device, then a delay action in case it takes a few seconds for the refresh to complete, and only then check the status to determine what action to take.