maximumSince isn't the maximum

I’m getting wind speed values every minute or so from a LaCrosse sensor and using a rule to update max values. The problem is the Weekly Max is less than the Daily Max - which is by definition not possible.

The sensor actually report km/h which I convert to mph, that part works fine.

The rule:
rule “Update_LaCrosse_Wind_Speed” when
Item LaCrosseWeather_Wind_Speed received update
var speed = (LaCrosseWeather_Wind_Speed.state as DecimalType).doubleValue
var speed_mph = speed / 1.609
postUpdate(LaCrosseWeather_Wind_Speed_mph, speed_mph)

The problem is for some reason LaCrosseWeather_Wind_Speed_7dMax is less than LaCrosseWeather_Wind_Speed_24hMax.

Since 24hMax is a subset of 7dMax it should be impossible for this to happen. The opposite is possible of course.

Any ideas on what’s going on here.

Please How to use code fences for code and logs.

What database are you persisting the data to? If it’s rrd4j it might be an artifact of how the data is compressed as it ages.

It takes some time for an update to actually get written out to the database so I would not expect that the call to maximumSince(now.minusDays(1)).state would include the value you just posted to the Item. However, enough time has passed after that call for the maximumSince(now.minusDays(7)) to include the most recent value. Would that explain the difference you see?

This does seems like an artifact of rrd4j but with slightly different symptoms. The minusDays(1) value seems mostly correct. The minusDays(7) value seems to be the current value or close to it.

Does this imply that maximumSince could have different values for different persistence databases? I can see more complicated statistics getting messed up based on compression but Max and Min are pretty straightforward concepts.

If so what is the “preferred” database?

Please have a look into the documentation for rrd4j. This database does consolidate older data, using the default setup only the stored values for each minute over the last 8! houres are kept. When requesting data covering more then 8 houres the values are stored as average of timesteps.
If you need the correct values for the maximum since a day and a week you could either setup rrd4j in a way to have those values ( for example consolidate the maximum value of each timestep) or move to a database that does not consolidate (compress!) the data.

1 Like