Help with rule to run every 2 mins

I have a rule that sets a variable to true/false when the shower turns on.

I have a 2nd rule that I want to run every 2 mins while the variable from rule 1 is true. It is only executing once. What do I need to do to get it to trigger every 2 mins?

See @Chris_C 's solution in this thread:

2 Likes

But shouldn’t stays true trigger the rule every 2 mins while it is true?

The variable would need to be flipped to False and then back to True before the ‘state stays’ trigger would get triggered again. The rule in your screenshot won’t loop every five minutes by itself unless the variable changes from false to true and stays that way for 2 minutes (eg. from another rule not pictured).

Otherwise the approach @Bry mentioned is a reasonable way to loop every X minutes.

1 Like

It sure would be great to just have an option for Sharp Tools to execute every 5 minutes.

We have an amp-meter and have to send the refresh signal to it in order to get readings. Right now it is a linux cron job, to an HTTP trigger. Then we pump the result into influxDB.

We have a dozen use cases where every X minutes would be helpful.

Is the reason you do not have every X minutes as a “feature” due to Cloud CPU cost, or potential back-end un-intentional DDoS protection?

What are the other use-cases? As noted in the following thread, introducing a first-class looping feature is something we are considering…


It’s generally an anti-pattern that ends up making rules run significantly more often (and thus unnecessary resource utilization as you alluded to). Other than sending a periodic refresh to a device, most of the use-cases I see are better suited as an event-driven rule design. That being said, there are some cases where a loop could be a better fit, so I’m interested in hearing more use-cases from the community!

One concern is that if a loop is available as a first-class feature, many people will end up using a loop approach rather than an event driven approach which ends up unnecessarily multiplying the resource problem.

Heck, even going back to the use-cases where a loop is warranted (eg. a refresh), most of those rules are being written because of a fundamental flaw with an upstream device (eg. a device that is not reporting data in an event driven manner like it should). In those cases, sometimes it’s just a faulty device or oftentimes its old devices that didn’t push events because of now expired patents… but sometimes it’s a matter of updating or configuring the device accordingly.

I would note that energy meters and power meters are a bit unique in that they tend to report a ton of events, so there are some cases where periodically snapshotting energy/power data rather than using an event-driven rule makes sense!

I would pay a premium per month for easy of creating scripts with every down to the 5 minute mark.
Using variables for timer loops complicates scripts and they become hung sometimes.

Hot Water Re-Circulation Pump on Boiler. Run for 5 minutes every 15 minutes.
ICE Melt System on Roof, run every 4 hours for 1 hour.
Short Term Rental House with 20+ Thermostats (boiler and electric heat)
Reset to heat mode every hour to avoid frozen pipes in garage.

Today we are doing it with these simple cronjob:

CRON Job we use today:
*/5 * * * * /home/sharptools/./refresh

./refresh script is full of WGET lines.