Rrd4j and charts in Openhab2

Hello,
I’ve got some problems to figure out how it works to display a simple Temperature chart.

rrd4j.persist

    Strategies {
        everyMinute:"0 * * * * ?"
        everyHour : "0 0 * * * ?"
        everyDay  : "0 0 0 * * ?"
        default = everyChange
    }

Items {
    Est_T_Max : strategy = everyMinute, restoreOnStartup
}

Items in .items file

    Number   Est_Temperatura   	"Temperatura [%.1f °C]"  				<temperature>  		(Esterno, Meteo) 		{weather="locationId=myhome, type=temperature, property=current"}
    Number   Meteo_Grafico_Temperatura            	"chart data"

sitemap:

Frame {
                Switch item=Meteo_Grafico_Temperatura label="Grafico Temperatura" mappings=[0="Hour", 1="Day", 2="Week"]
				Chart item=Est_Temperatura period=h refresh=6000 visibility=[Meteo_Grafico_Temperatura==0, Meteo_Grafico_Temperatura=="Uninitialized"]
				Chart item=Est_Temperatura period=D refresh=30000 visibility=[Meteo_Grafico_Temperatura==1]
				Chart item=Est_Temperatura period=W refresh=30000 visibility=[Meteo_Grafico_Temperatura==2]
              }

Where’s the mistake to display a chart correcly?

Can’t see anything obvious in those, how does your rrd4j.cfg look? It is in the services folder.

I didn’t touch it.

Is needed to configure something in it?

# please note that currently the first archive in each RRD defines the consolidation
# function (e.g. AVERAGE) used by OpenHAB, thus only one consolidation function is
# fully supported
#
# default_numeric and default_other are internally defined defnames and are used as
# defaults when no other defname applies

#<defname>.def=[ABSOLUTE|COUNTER|DERIVE|GAUGE],<heartbeat>,[<min>|U],[<max>|U],<step>
#<defname>.archives=[AVERAGE|MIN|MAX|LAST|FIRST|TOTAL],<xff>,<steps>,<rows>
#<defname>.items=<list of items for this defname>

P.S.

I look also in the Est_Temperatura.rrd file , in persistence/rrd4j folder and looks like these

R R D 4 J , v e r s i o n 0 . 1 < XŽ#B s t a t e G A U G E <ø ø ø . A V E R A G E ?à àø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø A V E R A G E ?à hø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø

you mixed the items and groups.
if you poll the temperature in Est_Temperatura
this has to be in your rrd4j.persist file, like:

Est_Temperatura : strategy = everyMinute, restoreOnStartup

Then you need a group and your item from above in this group (in the items file):

Group Temp_Speicher            "Temperature"     <temperature> 
Number Est_Temperatura <temperature> (Temp_Speicher)

and this group has to be mentioned in your chart item:

Chart item=Temp_Speicher period=h refresh=6000 visibility=[Meteo_Grafico_Temperatura==0, Meteo_Grafico_Temperatura=="Uninitialized"]

At least it is in my OH like this. Maybe, if you only want to show only one temperature in this chart you could use the number item where the temperature is in in the chart like you did. But then you have to put this in the rrd4j.persist.
Right now, you don’t persist your Number item (Est_Temperatura)

I can’t find this item nor a group with this name in your items definitions. Does it exist?

Furthermore, if you are also using another persistence, you have to define in the sitemap, from which persistence this data is coming: service="rrd4j"

Edit: @Windrad was faster… :wink:

1 Like

Ok, I didn’t see the obvious.Sorry.
My question concerning the rrd4j. cfg pointed to the last part of that file. You haven’t touched it, so rrd4j will try to persist all items ( which it can’t in case of non-numeric items). If you would have stated any items in that file., other items would NOT be persisted.

Indeed the error was:

Est_T_Max : strategy = everyMinute, restoreOnStartup

instead of

Est_Temperatura : strategy = everyMinute, restoreOnStartup

For sure my error (sorry about stupid error :slight_smile: )

BUT i have another question, because in my opinion make chart it is a little triky and hostile for noobs like me.

Now , due to your help, I’m able to display Temperature chart correctly (see photo)

Where I have to modify the code to display also Tmax and Tmin in the same Chart???

I Know guy it is easy and maybe i can manage by myself, but I hope these question can help also further people with the same problems and If i understand well the various arguments maybe I can help someone other in the forum.

my actual files are that:

rrd4j.persist

Strategies {
    everyMinute:"0 * * * * ?"
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"

    default = everyChange
}

Items {
    Est_Temperatura : strategy = everyMinute, restoreOnStartup
    Est_T_Min : strategy = everyMinute, restoreOnStartup
    Est_T_Max : strategy = everyMinute, restoreOnStartup
    Est_Umidita : strategy = everyMinute, restoreOnStartup
    Est_Pressione : strategy = everyMinute, restoreOnStartup
}

items file

Group Meteo 

Number   Est_Temperatura   	"Temperatura [%.1f °C]"  				<temperature>  		(Meteo) 		{weather="locationId=myhome, type=temperature, property=current"}
Number   Est_T_Min        	"T Min [%.1f °C]"     					<temperature>   	(Meteo)		{weather="locationId=myhome, type=temperature, property=min"}
Number   Est_T_Max       	"T Max [%.1f °C]"     					<temperature> 		(Meteo)		{weather="locationId=myhome, type=temperature, property=max"}

And the sitemap

 Frame {
                Switch item=Meteo_Grafico_Temperatura label="Grafico Temperatura" mappings=[0="Hour", 1="Day", 2="Week"]
				Chart item=Est_Temperatura period=h refresh=6000 visibility=[Meteo_Grafico_Temperatura==0, Meteo_Grafico_Temperatura=="Uninitialized"]
				Chart item=Est_Temperatura period=D refresh=30000 visibility=[Meteo_Grafico_Temperatura==1]
				Chart item=Est_Temperatura period=W refresh=30000 visibility=[Meteo_Grafico_Temperatura==2]
              }

I try by myself to make a very fast test but it doesn’t work

I try to display the whole group

Frame {
                Switch item=Meteo_Grafico_Temperatura label="Grafico Temperatura" mappings=[0="Hour", 1="Day", 2="Week"]
				Chart item=Meteo period=h refresh=6000 visibility=[Meteo_Grafico_Temperatura==0, Meteo_Grafico_Temperatura=="Uninitialized"]
				Chart item=Meteo period=D refresh=30000 visibility=[Meteo_Grafico_Temperatura==1]
				Chart item=Meteo period=W refresh=30000 visibility=[Meteo_Grafico_Temperatura==2]
              }

But some other needed =)

Thank you at all the replayers !!! OpenHAB is YOU guys!!!

Try

Items {
Meteo* : strategy = everyMinute, restoreOnStartup
}

in the persistence file instead of all single items. Everything else should be fine (although I haven’t used different periods controlled by a switch item yet).

It’s the copy-paste of tge Opnhab1 DemoHome with only variables change :sweat_smile:

Edit:

Items {
	Meteo_gTemperature* : strategy = everyMinute, restoreOnStartup
}

ok ^^ These is the solution!!!

Note for further readers:
After a couple of test with persistence, is better to check /var/lib/openhab2/persistence/rrd4j and remove unusefull files created for error during test

More documentation on charts can be found in the openhab documentation and wiki (link in docs)

http://docs.openhab.org/configuration/sitemaps.html#element-type-chart

Hi,

I still got problems with the rrd4j persists and charts in my sitemap.
I like to have one switch to toggle multiple chart views like @Muplex did above.
I’m using a Raspi 3 running openhabian and I’m quite new to this things :slight_smile:

This are my /etc/openhab2/items/sonoff.items:

// Switch state
Number Sonoff_Licht_3_RSSI_chart "RSSI Chart data 3"
// wifi quality of item
Number Sonoff_Licht_3_RSSI       "WZ Fenster L: RSSI [%d %%]" <network> (gSYS,gRSSI)
{ mqtt="<[broker:tele/sonoff_3/STATE:state:JSONPATH($.Wifi.RSSI)]" }

my /etc/openhab2/sitemaps/debug.sitemap:

        // Sonoff_Licht_3_RSSI_chart
        Switch  item=Sonoff_Licht_3_RSSI_chart label="Sonoff_Licht_3_RSSI_chart" icon=line mappings=[0="Hide", 1="Hour", 2="Day", 3="Week"]
        Chart   item=Sonoff_Licht_3_RSSI period=h refresh=5000   visibility=[Sonoff_Licht_3_RSSI_chart==1]
        Chart   item=Sonoff_Licht_3_RSSI period=D refresh=30000  visibility=[Sonoff_Licht_3_RSSI_chart==2]
        Chart   item=Sonoff_Licht_3_RSSI period=W refresh=30000  visibility=[Sonoff_Licht_3_RSSI_chart==3]

and my /etc/openhab2/persistence/rrd4j.persist:

Strategies {
    everyMinute : "0 * * * * ?"
    everyHalf : "0 30 * * * ?"
    everyHour : "0 0 * * * ?"
    everyDay : "0 0 0 * * ?"
    default = everyUpdate, restoreOnStartup
}
Items {
        Sonoff_Licht_1_RSSI : strategy = everyChange, restoreOnStartup
        Sonoff_Licht_2_RSSI : strategy = everyChange, restoreOnStartup
        Sonoff_Licht_3_RSSI : strategy = everyChange, restoreOnStartup
        Sonoff_Licht_4_RSSI : strategy = everyChange, restoreOnStartup
        gWAETHER : strategy = everyChange, restoreOnStartup
        gRSSI : strategy = everyChange, restoreOnStartup
        //* : strategy = everyChange, restoreOnStartup
}

My /etc/openhab2/services/rrd4j.cfg is left untouched.

The .rrd-files get updates in /var/lib/openhab2/persistence/rrd4j/.
Not sure, why I just get empty charts in my sitemap…

Any ideas how to fix that? :thinking:


EDIT:
Found out, that I should record at least every minute, so I got empty entries… :blush:

Changed persistence/rrd4j.persist to:

Items {
        gRSSI : strategy = everyChange, everyMinute, restoreOnStartup

Is it working after the update?

Regarding to my post?

Yes, it’s working like a charm! :grinning: thanks for asking :+1:

Hello, I am reviving my OH2 setup and am refreshing my Sitemap to include some charts. This thread has been very helpful but something is just not right when I attempt to copy the examples into my own implementation. The configurations render the following broken image icon:

22 PM

Error:
2018-01-05 04:33:55.532 [WARN ] [thome.ui.internal.chart.ChartServlet] - Chart generation failed: null

Sitemap:

       Switch item=Weather_Chart_Period label="Chart Period" icon=line mappings=[0="Hour", 1="Day", 2="Week"]
       Chart item=gGraphTemp period=h refresh=300000 service="rrd4j" visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="Uninitialized"]
       Chart item=gGraphTemp period=D refresh=300000 service="rrd4j" visibility=[Weather_Chart_Period==1]
       Chart item=gGraphTemp period=W refresh=300000 service="rrd4j" visibility=[Weather_Chart_Period==2]
    }

Items:

Number temperatureGarage "Garage [%.1f °F]" <temperature> (gGarage, gGraphTemp) {mqtt="<[mybroker:openhab/garage/temperature:state:default]"}
Number temperatureCentralMkt "Outside [%.1f °F]" <temperature> (gGraphTemp) {mqtt="<[mybroker:weather/new_york:state:default]"}
Number NestTemperature "Temperature" <temperature> (gNest, gGraphTemp) {channel="nest:thermostat:xxx:yyy-zzz:temperature"}

Persistence:

    // for rrd charts, we need a cron strategy, every Minute is a must have.
    everyMinute : "0 * * * * ?"
    everyHour: "0 0 * * * ?"
    everyDay : "0 0 0 * * ?"
    default = everyChange
}

Items {
    //* : strategy = everyChange, restoreOnStartup
    gGraphTemp* : strategy = everyMinute, restoreOnStartup
}

RRD files:

openhab@openhab2:~/openhab2$ ls -alth /var/lib/openhab2/persistence/rrd4j/
-rw-r--r-- 1 openhab openhab  28K Jan  4 20:47 NestTemperature.rrd
-rw-r--r-- 1 openhab openhab  28K Jan  4 20:47 temperatureCentralMkt.rrd
-rw-r--r-- 1 openhab openhab  28K Jan  4 20:47 temperatureGarage.rrd

Any help on this would be greatly appreciated.

The posted files do look ok. rrd4j is known to be acting a bit weird if you do changes in the Setup, did you delete the .rrd files after the last changes and restrart OH in order to have a clean start? (Just a wild guess!)
Another check would be using the REST API to look into the database in order to check wether there are values persisted at all.

Thank you for the feedback but unfortunately no resolution yet. Per your recommendation, I cleared out the RRD files and rebooted. I did not know about the REST API, so after getting that setup was able to confirm that values are being populated in the respective RRD files.

I am wondering about the services/rrd4j.cfg file. Mine is currently setup with defaults (all the settings are commented out). I may have missed this altogether and did not see any examples of this in the forums. If setting up parameters are required then I will have a go at this tonight and report back.

In this case the defaults should be used.

I have resolved my graphing issue by installing openHABian on my Pine A64. Graphing worked straight away. Not sure what the issue was before, but clean install did the trick. A few hours after getting rrd4j working I stumbled into the Influx/Grafana install option in openhab-config.

InfluxDB plus Grafana is no doubt more powerful, however on a Raspi that migth be using to much of your system capabilities. InfluxDB can be setup to hold a never increasing amount of data like rrd4j, but it needs to be setup for that ( it is not the default setting). Grafana can display the data way more fancy, but as before, the fancy part needs user settings.
I opted against all that.