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_Temperature
Weather_Temp_Max
Weather_Temp Min
I use this well known rule:
rule "Set daily max and min temperature"
when
Item Weather_Temperature changed or
Time cron "0 0 0 * * ?" or
System started
then
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) {
Weather_Temp_Max.postUpdate(max)
Weather_Temp_Min.postUpdate(min)
}
end
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
GF_Temperature
GF_Temperature_Max
GF_temperature_Min
I use a similar rule with the essential items changed:
rule "Set Living max and min temperature"
when
Item GF_Temperature changed or
Time cron "0 0 0 * * ?" or
System started
then
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) {
GF_Temperature_Max.postUpdate(max)
GF_Temperature_Min.postUpdate(min)
}
end
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?