Darn, I keep having trouble with the min/max temperature

I thought I had this problem nailed, but Openhab keeps kicking me in the nuts on this one
I try to store and show the min and max temperatures of the outside temp I get from yahoo. That works, no complaints there.
I do that as follows (I will first describe what works)
I have 3 items

Weather_Temp Min

I use this well known rule:

rule "Set daily max and min temperature"
	Item Weather_Temperature changed or
		Time cron "0 0 0 * * ?" or
	System started
    val max = (Weather_Temperature.maximumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue
	val min = (Weather_Temperature.minimumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue

if( max != null && min != null) {

And that works as one can see in the Eventlog and ‘on screen’

2017-06-13 10:16:04.486 [ItemStateChangedEvent     ] - Weather_Temperature changed from 16 to 18
2017-06-13 10:16:05.299 [ItemStateChangedEvent     ] - Weather_Temp_Max changed from 16 to 18

So far so good. So it should be real easy to do the same for inside temperature (and that is what doesnt work)
So I have 3 new items


I use a similar rule with the essential items changed:

rule "Set Living max and min temperature"
	Item GF_Temperature changed or
		Time cron "0 0 0 * * ?" or
	System started
   val max = (GF_Temperature.maximumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue
	val min = (GF_Temperature.minimumSince(now.withTimeAtStartOfDay, "rrd4j").state as DecimalType).doubleValue

if( max != null && min != null) {

However that does not work as expected, whenever the temperature is changing, all 3 temperatures (current, min and max) change. I have the rrd4j persistence installed (otherwise the other rule wouldnt work either), but for the life of me I cant understand what I am doing wrong. I rebooted several times, just to make sure the rule would be known

When I check my eventlog I can see that the rule was triggered, but it just doesnt do what it should do.

2017-06-13 10:16:30.682 [ItemStateChangedEvent     ] - GF_Temperature changed from 20 to 10
2017-06-13 10:16:30.726 [ItemStateChangedEvent     ] - GF_Temperature_Max changed from 20.0 to 10.0     (<- that one shouldn't happen)
2017-06-13 10:16:30.740 [ItemStateChangedEvent     ] - GF_Temperature_Min changed from 20.0 to 10.0

2017-06-13 16:04:58.084 [ItemStateChangedEvent     ] - GF_Temperature changed from 10 to 25
2017-06-13 16:04:58.160 [ItemStateChangedEvent     ] - GF_Temperature_Max changed from 10.0 to 25.0
2017-06-13 16:04:58.169 [ItemStateChangedEvent     ] - GF_Temperature_Min changed from 10.0 to 25.0   (<-that one should not happen)

It seems that the rule just doesnt care about min or max, it updates both items with the current temperature. I checked and checked my rule, but I can’t figure it out.
Had the same on another openhab install, first min max works, 2nd min max does not.
Does anybody see a mistake I might have overlooked?

I thought on the previous trip around this, we established that “missing” persistence does not fail .maximumSince() / .minimumSince() , but simply gives a current value.
That feels awfully like your symptom.
There is more to persistence than just establishing the service - are these particular Items being persisted? Look at rrdj4.persist

Thanks, yes I actually have that, sorry for not mentioning

looks like:

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
	// for rrd charts, we need a cron strategy
	everyMinute : "0 * * * * ?"

Items {
	DemoSwitch,NoOfLights,Window_GF_Toilet,Heating* : strategy = everyChange, everyMinute, restoreOnStartup
	// let's only store temperature values in rrd
	Weather*,Weather_Chart* , Weather_Temp_Max,Weather_Temp_Min, GF_Temperature, GF_Temperature_Max, GF_temperature_Min: strategy = everyMinute, restoreOnStartup
// vim: syntax=Xtend

I think there is definitely a problem with my persist:
I decided to spread out the values on their own line:

Weather*,Weather_Chart*, Weather_Temp_Max,Weather_Temp_Min: strategy = everyMinute, restoreOnStartup
GF_Temperature,GF_Temperature_Max,GF_temperature_Min: strategy=everyMinute, restoreOnStartup

That suddenly brought things to live: max temp would go up if temp goes up, min temp would go down if temp goes down, but they always seem to revert back to resp 21.75 degrees and 14.5 degrees
So even if say the temp goes up to 50, Temp max will do too, but if temp goes down again the max temp will go back to 21.75.

Event log after a reboot:

2017-06-13 21:15:56.086 [GroupItemStateChangedEvent] - GF_Living changed from NULL to UNDEF through GF_Temperature
2017-06-13 21:15:56.087 [GroupItemStateChangedEvent] - gGF changed from NULL to UNDEF through GF_Living
2017-06-13 21:15:56.150 [ItemStateChangedEvent     ] - GF_Temperature_Max changed from NULL to 21.75
2017-06-13 21:15:56.161 [ItemStateChangedEvent     ] - GF_Temperature_Min changed from NULL to 14.5

Dumb question, the outside temperature you are getting from Yahoo is linked to a numeral item, correct?
Is that also true for the inside temperatures?

Additionally I would use some logging in the rule to make sure they are changing the max/min values.

yes indeed, albeit that the inside temp comes in via mqtt

Number GF_Temperature "Room temperature [%.1f °C]" <temperature> (GF_Living) {mqtt="<[mosquitto:home/Living/temp:state:default]"}
Number GF_Temperature_Max "Max temperature [%.1f °C]" <temperature> (GF_Living)
Number GF_Temperature_Min "Min temperature [%.1f °C]" <temperature> (GF_Living)

what logging would you advise?
currently I just check my eventlog and I see the changes there. they are just not always the right changes

@opus @rossko57
i thought I found it but I did not fully :slight_smile:

Anyway there was a problem in my persist file. Apparently when copying in the new items I had introduced a non printable character.
That I discovered when I broke it over 2 lines.
Subsequently, I got some weird values. It seemed that had to do with my impatience in testing.
Initially it seemed If I wait some 2 minutes between updates everything worked fine, but then suddenly when my temperature changed from 25-26 degrees, both the max and the min temperatures changed again to seemingly unrelated values. I get the impression they are averages of something. Now I know the RRDJ4 stores an average if upfdate faster than 1 minute, but here there was definitely more time in between

OK, it seems to work, if I do not do the updates too quickly. I thought once every minute would be slow enough but seems to need a bit slower.
Anyway, I will see how it keeps up, but for now both of you thanks for yr help. I really hope I have seen the last of min/max problems

More update
Yes, works perfect.
(if updates not too fast)

Final update
This is my final update for anybody coming upon this with similar problems.
Ever since the original question, I added many min/max items and it does work, following the method described here:
add the items in your items file
update the min/max values with a rule
add the min/max values to the rrdj4.persist file. (and ofcourse you shld have rrdj4 installed)

BUT sometimes it just needs patience. I have had min/max additions work almost immediately and in some cases it took a few hrs for it to work as supposed to.