OH2 and rrd4j and chart

Hi friends,
i am struggalling with rrd4j persistance and chart.
i have created three items under one group which recieve temperature, humidity and heat indx value from esp8266 over mqtt messages.
.item file is as below.

Group    gGraphWeather             "Weather"
Number   Bed_Humidity         "Bedroom Humidity % [%s]" <humidity> (FF_MasterBedroom, gLight, gGraphWeather) {mqtt="
    <[mosquitto:ashish/bed1/Humidity:state:default]"}
    Number   Bed_Tmp         "Bedroom Temp DegC [%s]" <temperature> (FF_MasterBedroom, gLight, gGraphWeather) {mqtt="
    <[mosquitto:ashish/bed1/TmpdegC:state:default]"}
    Number   BED_heat_indx    "Bedroom HtIndx% [%s]" <temperature> (FF_MasterBedroom, gLight, gGraphWeather) {mqtt="
    <[mosquitto:ashish/bed1/TmphtindxC:state:default]"}

rrdj4.config file is as below.

ctr24h.def=GAUGE,900,0,U,60
ctr24h.archives=AVERAGE,0.5,1,480:AVERAGE,0.5,10,144
ctr24h.items=Bed_Humidity, Bed_Tmp, BED_heat_indx

rrd4j.persist fie is as below.

Strategies {
        everyMinute : "0 * * * * ?"
        everyHour   : "0 0 * * * ?"
        everyDay    : "0 0 0 * * ?"
       default = everyChange
}
Items {
        gGraphWeather* : strategy = everyChange, everyMinute, restoreOnStartup
}

sitemap setting is as below.

Frame{
        Switch item=Weather_Chart_Period label="Bedroom Weather" icon=line mappings=[0="Hour", 1="Day", 2="Week"]
        Chart item=gGraphWeather period=h refresh=5000 service="rrd4j" visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="Uninitialized"]
        Chart item=gGraphWeather period=D refresh=300000 service="rrd4j" visibility=[Weather_Chart_Period==1]
        Chart item=gGraphWeather period=W refresh=300000 service="rrd4j" visibility=[Weather_Chart_Period==2]
}

sitemap shows as per below imag

Openhab%20chart

i didnot get three options “Hour” , "Daily ", “Weekly”
& i get all three charts on same site map as per attached impage.
Humidity and tempareture line in Weekly chart is only for one days. how ever setting for all three items in rrd4j.config and rrd4j.persis are same.

requested community to guide me to resolve this.

You need to create the Item that is used to control visibility.

Note that you might see “uninitialized” in OH1 but not in OH2, “NULL” would be more sensible there.

1 Like

Can you give any example ???
I am not professional programmer but learn by example & tutorial.
Thanks.

Well, you showed us your xxx.items file with some Items in it. I hope that what that does is clear enough to you, even if copy-pasted. It describes a bunch of Items for the system to create at load time.

In your sitemap, you have
Switch item=Weather_Chart_Period ...
I expect you understand this is telling the UI to do something using an Item with the name given.

This Item is not in your xxx.items file. So, unless you have defined it somewhere else, it does not exist and your sitemap will fail.
Does your sitemap fail? Well, it’s not doing what you want, so it is failing in some way.
You could look in your openhab.log file to see if any errors are reported.

But let’s assume that Item does not exist yet. A fix would obviously be to create it, by adding a new Item definition to your xxx.items file.
What kind of Item, though? Let’s look back at the sitemap. The Item is used in a Switch widget - BUT when you look at the mappings= part, the Item’s value is being referred to as a number.
If we check with the visibility= part in the Chart sitemap lines, it also gets referred to as a number.
So, create a Number type Item with the wanted name.
I’m not going to give you copy-paste for that.

The other minor issue is about this in your sitemap -

... visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="Uninitialized"]

This is to show or hide the Chart based on the state of the Weather_Chart_Period item, which we think is a Number.
The visibility= here will show this chart if the item has state 0 or if it has not yet been set.

At system boot time, Items do not have a sensible state. Even numbers are not given zero state. Items get a special state to show they are uninitialized to begin with.
In openHAB-1 that special state was Uninitialized. In openHAB-2 the special state is NULL.
You work out what to do here.

1 Like

Thanks for explaining things.
i have add only single item in my .item file

Number   Weather_Chart_Period     "Bedroom Weather"

now i get proper graphisc on site map.


now after chagning Hour to Day selection chart not changed automatic.
i have to refresh page. i think i have to make rule like. if Weather_Chart_Period update then refresh sitemap. am i on right track???

Second thing as per attached screen shot Humidity and temperature chart line are only for one day. althow all three items are in same persistance group.

once again thanks for explaining things & not providing solution directly. this help me to understand openhab .

There is no way to force a browser to tefresh from a rule.

You might look at the refresh= parameters in your sitemap entries and find out what they mean.

Have you looked in openhab.log yet? There are ways to mess up a sitemap that leave it mostly working, but the auto refresh not working.

The chart cannot plot data that does not exist. You might need to look into what you are storing in rrd4j and when.

I don’t know why chart not refresh at that time. Now it works as expected. Also I can change chart type in android app.

Thanks.

All three items Temperature, Humidity & heat index post by esp8266 for every 5 seconds.
rrdj4 persistent settings are same for all three items.

1 Like