maximumSince/minimumSince faulty?

Hello,
last couple of days Iam revorking my automation to mqtt and bunch of sonoff and stuff and so Iam playing with OH2.4 all day long.
It’s kind of working as I need, but it does look like sometimes after restart or some random period time it just start doing strange stuff.
Currently I’m struggling to understand what is going on in here (it was working like 4hours ago) and then after restart it simply put updated variable to min/max instead of actual min/max and not showing anything on FE.

Maybe somebody will spot something smelly, but I kind of can’t :slight_smile:
Thanks in advance

items definition:

    Number testHumidity            "Humidity"   <humidity>    { channel = "mqtt:homie300:home:garden:air#humidity" }
    Number testHumidityMax         "Max"        <humidity>
    Number testHumidityMin         "Min"        <humidity>

and rule:

    rule "Set daily max and min humidity"
    when
        Item testHumidity changed or
        Time cron "0 0 0 * * ?" or
        System started
    then
        val max = testHumidity.maximumSince(now.withTimeAtStartOfDay)
        val min = testHumidity.minimumSince(now.withTimeAtStartOfDay)
        if (max !== null && min !== null) {
            postUpdate(testHumidityMax, max.state)
            postUpdate(testHumidityMin, min.state)
        }
    end

logs:
init: (looks ok)
2019-06-21 21:13:28.929 [vent.ItemStateChangedEvent] - testHumidity changed from NULL to 61
2019-06-21 21:13:53.923 [vent.ItemStateChangedEvent] - testHumidityMax changed from NULL to 61
2019-06-21 21:13:53.925 [vent.ItemStateChangedEvent] - testHumidityMin changed from NULL to 61

first update: (not ok)
2019-06-21 21:15:05.602 [vent.ItemStateChangedEvent] - testHumidity changed from 61 to 60
2019-06-21 21:15:05.625 [vent.ItemStateChangedEvent] - testHumidityMax changed from 61 to 60
2019-06-21 21:15:05.627 [vent.ItemStateChangedEvent] - testHumidityMin changed from 61 to 60

and another: (not ok)
2019-06-21 21:15:35.644 [vent.ItemStateChangedEvent] - testHumidity changed from 60 to 20
2019-06-21 21:15:35.669 [vent.ItemStateChangedEvent] - testHumidityMax changed from 60 to 20
2019-06-21 21:15:35.672 [vent.ItemStateChangedEvent] - testHumidityMin changed from 60 to 20

I think we’d need to know a bit about your persistence setup,it is key. What is your default db (have you changed it to mapdb)? What’s your strategy for this Item?

Isnt persistence only for data which i want to store? I mean, this rule and these items no matter if persisted should be populated by minmax or am wrong? isnt this function just compare data stored in the variable and if bigger/lower then update?

those three test items are not persisted anywhere, but normal “not testing” ones are via:

Strategies {
	everyMinute	: "0 * * * * ?"
	every5Minutes : "0 */5 * * * ?"
    every10Minutes : "0 */10 * * * ?"
   	everyHour   : "0 0 * * * ?"
   	everyDay    : "0 0 0 * * ?"
   	default = everyChange
}

Items {
    gStoreData : strategy = everyChange, everyDay, restoreOnStartup
    gStoreWeather : strategy = every10Minutes, restoreOnStartup
}

and indeed there is a group gStoreWeater and gStoreData which contains non-testing humidity (which are faulty as well, that’s why i have created those testing ones)

And I’m using JDBC MariaDB connection. Which if Iam thinking about it might be an issue as i was using mysql persistence before and it worked. But then I’ve read some post that jdb persistence is more stable, hmmm

btw, even out group of which stores data in rules it’s doing something

2019-06-21 21:13:53.610 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::query: try to generate the table for item 'testHumidity'

Ye-es … but … myItem.maximumSince(XX) is a persistence based method.


I mean, think about it; in order to calculate the maximum value since previous time XX someone somewhere has to store the collection of values.

How you had it working by random chance of persistence strategy I don’t know.

Anyway, if you want this to work you’ll need to set up proper persistence for your humidity Item - hourly, everyChange, whatever you want - and then need to make sure your max/min functions use the correct persistence service, either by setting default or specifying in the method.

ok it does seems like issue with groups
if I have in persistence

gStoreWeather : strategy = everyChange, every10Minutes, restoreOnStartup

it does not work, but if I do

* : strategy = everyChange, every10Minutes, restoreOnStartup

it works just fine, eg. with * data are being updated in database …
my items are defined like so:

Group gStoreData
Group gStoreWeather
Number Weather_Humidity         "Humidity"              <humidity>  (gStoreWeather, Garden, Weather)  { channel = "mqtt:homie300:home:garden:air#humidity" }

anything Iam missing ?
thanks for your help

If you want to persist the members of a group, you need to use *

gStoreWeather* : strategy = ...

ah and i thought it’s for persisting
gStoreWeater
gStoreWeaterx
gStoreWeaterSomething

etc.

ok then, thank you very much!