Rules and Expressions with Open Weather API

It looks like you may have manually triggered your true/false timer twice. It appears to be running in duplicate.

1 Like

Is there a way to prevent more than one instance of a rule running?

I’ll preface this with a reminder that looping like this isn’t something we officially support, but there are some best-practices you can use to help with this sort of thing:

:test_tube: Unofficial Variable Loop Rule Best Practices

That being said, we are considering introducing a first class loop feature and are looking for feedback from the community on what use-cases they are using loops for (in general, event driven rules are preferred, but there are some use-cases where a loop makes sense)

Thanks @josh. I think I have it to only a single instance now with the Stays for xxx clause. This was a big deal because I was getting multiple thousand hits on OpenWeather API and it was starting to cost real money. This should take me from 2000+ pings daily to 72.

Hey Ken,
The multiple running is most likely caused by manually flipping your true/false AFTER it has already been started once. The second time triggers your rule while the first is still running. That will add another instance every time the variable is flipped.

1 Like

With the updates trigger, that’s absolutely right. The state stays trigger helps deduplicate the events which is why it’s the first thing listed in the unofficial recommendations linked above. :slight_smile:

Here’s my response from Ken’s other thread:

Yup…it looked like Ken was using DELAY, not STAYS. I’ve had relatively few issues since changing mine to STAYS, but… it’s not perfect. About 4 or 5 times a week I’ll have to restart my 10 minute weather timer. No errors or clues as to why it stops. No real complaints, just waiting for the “First Class” timer!!! LOL

Is there a way to tell it has stopped? This is one of the reasons I had parallel rules running. I have a once a day rule that resets my variables. If it hasn’t failed, I will now have two running.

I use another rule to alert me if the loop timer stops. Don’t know if right or wrong, but it does the job for me.

You might notice this is based off of a virtual switch being OFF or ON. I changed this timer to use a virtual switch instead of a variable. This one has not stopped since I created it as opposed to my variable based one that stops often. I don’t know what the difference would be… but…

2 Likes