1) Give a description of the problem
Every hour, I am querying $weather.conditions.current_observation.pressure_in
, and using the results to draw a graph. It’s been working beautifully for the past 3 months, but about 2-3 times a month, WUnderground returns a zero (or maybe it’s a null). Now, honestly, that is an acceptable tolerance of errors (2-3 bad out of 728 polled), but each time it happens, it TRASHES my graph, which stays sloppy (and unusable) for 47 hours, at which time the bad data finally scrolls off the side of my graph.
2) What is the expected behavior?
What I have done to try to solve this is: in the last few steps in the piston, I store the current ‘myPressure
’ number into 'myPressureOld
", and add +10 to create ‘myPressureOldMax
’, and subtract -10 to create ‘myPressureOldMin
’.
Then, at the beginning of the piston (when it runs next) it checks to see if the NEW number is inside the range of ‘Min
’ and ‘Max
’. If it is, I can assume it is good data, and to carry on like normal. If it is outside that range, I can assume it is a glitch in WUnderground, and we re-use the ‘Old
’ data one time.
3) What is happening/not happening?
About 2-3 times a month, a -1692.44 slips past somehow. (all my numbers should fall between 0 and 100) When I examine the math a bit, I notice that if wuPressure
is 0, then myPressure
would be -1692.44. This leads me to think that WUnderground returned a zero or null.
So I guess my question is, why is my IF statement not catching the negative number after the math, and re-using the old (yet still fairly accurate) number?
4) Post a Green Snapshot of the piston
Is there a better way to code that IF statement?
(In case you are wondering, wuPressure
is data straight from WUnderground, and myPressure
is my custom math to make it fall between 0-100 for my location)
Just to show you the descrepancy, here is 7 hours of data, with the error in the middle:
45.35
46.51
46.51
-1692.44
50.58
51.16
51.74