Asynchronous writing of meter values

David Pritchard shared this question 8 months ago
Need Answer

When you write a value to a meter, why doesn't the rule wait until the value is stored?


If you do this:


Store value 0 in meter attribute xyz.

If (abc)
      Store value 1 in meter attribute xyz

The result will often be that the meter attribute always reads 0, even though the condition "abc" was met. There's a delay (somewhat less than a second, but I imagine it depends how "busy" the box is) in writing the value, but rules don't pause their execution. So you have to insert waits into the rule, which can really start to add up if you write a lot of values.


Isn't this a bug?

Comments (5)

photo
1

Have you tried: "refresh all" before reading?

photo
1

I'll try it. Thanks!

photo
1

Sadly, it doesn't work.


I tried the following rule:


Set meter value to 0
Refresh all
if (1=1)
     Set meter value to 600
     Refresh all
if (1=1) 
     Set meter value to (current value) + 1
     Refresh all

Running it several times, the results vary: 1, 2, 3, 601, 602...


Now I'm going to affirm it: this is a bug.

photo
1

Putting a wait of as little as 0.01 seconds between writes is enough to get 601 in the test rule, consistently. But in real-world conditions that doesn't always seem to be enough. It depends how busy the box is.

photo
1

Ahahaha, John, you're the best! The option "refresh all" before reading" is what I always do first. Unfortunately, I have not encountered such a problem, so I can not give you advice on this. But I want to change jobs in order to develop my skills a little more in a more professional team, I even ordered a resume after I read resume writers reviews so I can ask my new colleagues for advice if this problem is still relevant to you.