[SOLVED] [FACEPALM]Having trouble with displaying min and max temperature

I am having some trouble reproducing min and max temperature as is done in the openhab demo by Kai
I am literally using his code just with a different town.
The temperature is displayed correctly, but the min and max temperature just follow the current temperature.

i have defined my items as follows: (but it is literally from the demo file
items:

Number Weather_Temperature      "Buitentemperatuur [%.1f °C]" <temperature> (Weather, Weather_Chart) { channel="yahooweather:weather:Amsterdam:temperature" }

Number Weather_Temp_Max         "Todays Maximum [%.1f °C]"      <temperature> (Weather, Weather_Chart)
Number Weather_Temp_Min         "Todays Minimum [%.1f °C]"      <temperature> (Weather, Weather_Chart)

the sitemap looks like this (again, literally from the demo file)
Sitemap

Text item=Weather_Temp_Max valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
Text item=Weather_Temp_Min valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
Text item=Weather_LastUpdate visibility=[Weather_LastUpdate>30] valuecolor=[Weather_LastUpdate>120="orange", Weather_LastUpdate>300="red"]

and my rule looks like this (also literally from the demo file)

rulesfile:

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)
	val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay)
	if( max != null && min != null) {
		postUpdate(Weather_Temp_Max, max.state)
		postUpdate(Weather_Temp_Min, min.state)
	}
end

In one post I came across the suggestion to define the rule like this:

.....(now.withTimeAtStartOfDay).state

but that just makes the min and max not change at all anymore :slight_smile:

Obviously I am overlooking something.
can anybody point me in the right direction?

1 Like

Those Items need to be persisted to obtain values there

Thanks, but it leaves me still a bit fumbled.
I am using the exact same rrd4j.persist as the demo file:

// 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
	Temperature*,Weather_Chart* : strategy = everyMinute, restoreOnStartup
}

// vim: syntax=Xtend

So seems every item in 'weather_Chart group and Temperature group is added to the strategy. Should I change that?
Anyway, I changed to this:

Temperature*,Weather_Chart*,Weather_Temp_Max,Weather_Temp_Min : strategy = everyMinute, restoreOnStartup
But that doesnt seem to work either: It doesnt show any min-max temp anymore

Hi,

try this please,

rule "Set daily max and min temperature"
when
	Item Weather_Temperature changed 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

Thank you, but even after a reboot of system the min and max temperatures remain blank.
there seems to be a “(” missing in the val max and val min lines

Yes, your right ;), sorry

=(Weather_Temperature…).doubleValue

should be right.

Thank you but sadly it does not work. It is as my original problem: when the temperature drops, both min and max temperature drop.
I can’t really see any mistake in my persist file, or any file

The Yahoo weather binding data has been a bit fickle lately and there are a few discussions here about this.

I would consider using another provider.

Thank you, but even if fickle, shouldnt values that come in be handled correctly? The rules and persistence are not really depending on what Yahoo does I would guess.
Nevertheless was thinking about Switching to WU anyway, but I dont think Yahoo is the source of the problem here, but I have no idea what it could be

If the Items received a value just once then that is what value they will remain. Look in events.log and verify that you are actually getting temperature updates. If not then everything will remain static.

Thanx Rich,
I do get events like this:

2017-05-31 07:35:30.210 [ItemStateChangedEvent     ] - Weather_Temperature changed from 12 to 13
2017-05-31 07:35:30.246 [ItemStateChangedEvent     ] - Weather_Temp_Max changed from 12.0 to 13.0
2017-05-31 07:35:30.250 [ItemStateChangedEvent     ] - Weather_Temp_Min changed from 12.0 to 13.0

So yes there is change, it is just thatthe max and min seem to change along. And that is what I have been observing in my app al along: the temperature changes but the min and max just keep changing along, both up and down
I really have no idea what I am doing wrong

Try please Weather* instand off Temperature* in your rrd4j.persist.

Thanks Heiko. I needed to wait for the temperature to drop before I knew if it was working but sadly no. Outside temp went down, min and max both went down too.
I am (only a bit) frustrated as I would think this is a very basic thing :slight_smile:

Just a quick question, did you installed RRDJ4 persistence in Addons-Persistence under Paper UI? Cause it looks like min and max is working but persistence is not working so not storing the old values.

My yahoo weather files are as follows:
things file:

yahooweather:weather:83fbd0f2 "Weather Information" [ location=2347000 ]

items file:

Group  Weather_Chart								<piechart>
Group  Weather					"Weather"			<therm2>
Number Weather_Temperature      "Sıcaklık [%.1f °C]"                  <therm2>   (Weather, Weather_Chart) 	[ "CurrentTemperature" ] { channel = "yahooweather:weather:83fbd0f2:temperature" }
Number Weather_Temp_Max         "Bugünkü En Yüksek [%.1f °C]"         <therm2>   (Weather, Weather_Chart)
Number Weather_Temp_Min         "Bugünkü En Düşük [%.1f °C]"          <therm2>   (Weather, Weather_Chart)
Number Weather_Chart_Period     "Grafik Periyodu"					  <chart>
Number YahooWeatherCode         "Bugün [MAP(yahoo_weather_code.map):%s]"  <yahoo_weather> (Weather) { http="<[weatherCache:60000:XSLT(yahoo_weather_code.xsl)]"}
DateTime Weather_LastUpdate     "Son Güncelleme [%1$ta %1$tR]"            <new_clock>

sitemap file:

Text item=Weather_Temperature valuecolor=[Weather_LastUpdate=="NULL"="lightgray",Weather_LastUpdate>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"] {
			Frame {
				Text item=Weather_Temp_Max valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
				Text item=Weather_Temp_Min valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
				Text item=Weather_LastUpdate visibility=[Weather_LastUpdate>30] valuecolor=[Weather_LastUpdate>120="orange", Weather_LastUpdate>300="red"]
				Text item=YahooWeatherCode label="Durum" icon="yahoo_weather"
			}
			Frame {
				Switch item=Weather_Chart_Period label="Grafik Periyodu" icon="chart" mappings=[0="Hour", 1="Day", 2="Week"]
				Chart item=Weather_Chart period=h refresh=600 visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="NULL"]
				Chart item=Weather_Chart period=D refresh=3600 visibility=[Weather_Chart_Period==1]
				Chart item=Weather_Chart period=W refresh=3600 visibility=[Weather_Chart_Period==2]
			}

rrdj4.persist

Strategies {
	everyMinute : "0 * * * * ?"
	default = everyUpdate
}

Items {
	* : strategy = everyChange, restoreOnStartup
	Weather_Chart* : strategy = everyMinute, restoreOnStartup
}

rules file:

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)
	val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay)
	if( max != null && min != null) {
		postUpdate(Weather_Temp_Max, max.state)
		postUpdate(Weather_Temp_Min, min.state)
	}
end

// Creates an item that stores the last update time of this item
rule "Records last weather update time"
when
  Item Weather_Temperature received update
then
  postUpdate(Weather_LastUpdate, new DateTimeType())
end

1 Like

Erkan
Please beat me on the head with a stick. I was sure I had installed it, but when i checked I had not.
At my age one sometimes plans to do something, but forgets the moment one walks into another room. I am sure I had but I probably got distracted right before doing it.
So stupid of me.
Anyway, I now installed it and I will work with the various comments. I am pretty sure I will get it to work now.

Thank you thank you very much.
Please excuse me while I go stand in a corner and be deeply ashamed .
I didnt even think about checking it before as I was sure I had done it. facepalm, triple facepalm

:slight_smile: Kees, experience talks. Your situation looked so familiar to me, then i remembered i did the same mistake dealing with the demo file :wink:

To be fair, I for one would expect .maximumSince() to return an error if there were no default/selected persistence.

The * is not a wild card. That line means persist all members of the Weather Group.

I completely agree. After all most of the other persistence methods do. Weird. I bet it is a side effect of how it is implemented such that if the call to the DB returns null it just returns the current value which masks the fact that the DB is missing.

1 Like

@febz11, @rossko57, @rikoshak, @LukaNoah
installing the RRDJ4, helped, on falling temp the maximum temp stayed, minimum temp followed.
At midnight, new max temp settled, min temp still going down.
In the morning when temp goes up again. I know that everything is fine.
Will report back in th emorning

OK guys, works perfectly. Thanks a bundle. Eventhough I feel as stupid as the man who called the TV repair guy only to find out it was unplugged.

Erkan: thanks to your personal experience I am helped now too. Have a great day. Oh, and I will happily steal a bit extra from the code you posted :slight_smile:
@rlkoshak Rich: I think I have read everything you ever wrote about RRD4j, So yes indeed I knew the * was not a wildcard. Your info and advice to others has been helpfull to me on on many fronts
@rossko57 rossko57: In hindsight, it might have al worked with the original setup, I might give that a try, later, just out of curiosity. There might have been an error in my eventlog. but I only searched it for the temperature.
@LukaNoah , thank you for your input, I lerned there is more than 1 way to write a rule :slight_smile:

All: Thanks for taking time and effort to help me, and as usual, I learned more than just about the subject at hand