Charts sometimes don't work with rrd4j persistence

rrd4j
Tags: #<Tag:0x00007f1822b022f0>

(Martin Mois) #1

Hello,

I am using openhab 2.2.0 on a Raspberry Pi2. Two temperature/humidity sensors are reporting their values via MQTT to OH.

I have defined these two items as follows:

String mqttReedTemp "Temp [%s]" {mqtt="<[mosquitto:/sensors/fenster-dach-bad:state:JSONPATH($.temperature)]"}
String mqttReedHumidity "Hum [%s]" {mqtt="<[mosquitto:/sensors/fenster-dach-bad:state:JSONPATH($.humidity)]"}

String mqttGarageTemp "Temp [%s]" {mqtt="<[mosquitto:/sensors/garage:state:JSONPATH($.temperature)]"}
String mqttGarageHumidity "Humidity [%s]" {mqtt="<[mosquitto:/sensors/garage:state:JSONPATH($.humidity)]"}

Group gTemperatures
String mqttReedTemp "Dach/Bad" (gTemperatures)
String mqttGarageTemp "Aussen" (gTemperatures)

Group gHumidities
String mqttReedHumidity "Dach/Bad LF" (gHumidities)
String mqttGarageHumidity "Aussen LF" (gHumidities)

My rrd4j.persist look as follows:

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

    default = everyMinute
}

Items {
        mqttReedTemp : strategy = everyMinute, restoreOnStartup
        mqttReedHumidity : strategy = everyMinute, restoreOnStartup
        mqttGarageTemp : strategy = everyMinute, restoreOnStartup
        mqttGarageHumidity : strategy = everyMinute, restoreOnStartup
}

The corresponding rrd definition look like this:

temp.def=GAUGE,120,-50,100,60
temp.archives=AVERAGE,0.5,1,10080:AVERAGE,0.5,60,89280
temp.items=mqttRaspberryPiCpuTemp,mqttReedTemp,mqttGarageTemp

humidity.def=GAUGE,120,0,100,60
humidity.archives=AVERAGE,0.5,1,10080:AVERAGE,0.5,60,89280
humidity.items=mqttReedHumidity,mqttGarageHumidity

Now the two charts look like this:

!

They are defined as follows in my sitemap:

Frame label="Temperaturen" {
                Chart item=gTemperatures period=D refresh=10000 label="Aussen Hum"
        }
        Frame label="Luftfeuchtigkeit" {
                Chart item=gHumidities period=D refresh=10000 label="Luftfeuchtigkeit"
        }

All rrd4j files are present:

pi@raspberrypi /opt/openhab/openhab-2.2.0/conf $ ll ../userdata/persistence/rrd4j/*Hum*
-rw-r--r-- 1 openhab openhab 86936 Feb 12 19:42 ../userdata/persistence/rrd4j/mqttGarageHumidity.rrd
-rw-r--r-- 1 openhab openhab 86936 Feb 12 19:42 ../userdata/persistence/rrd4j/mqttReedHumidity.rrd
-rw-r--r-- 1 openhab openhab 795224 Feb 12 19:43 ../userdata/persistence/rrd4j/mqttGarageTemp.rrd
-rw-r--r-- 1 openhab openhab 795224 Feb 12 19:43 ../userdata/persistence/rrd4j/mqttRaspberryPiCpuTemp.rrd
-rw-r--r-- 1 openhab openhab 795224 Feb 12 19:43 ../userdata/persistence/rrd4j/mqttReedTemp.rrd


The DEBUG log says that the values are correct:

2018-02-12 19:43:00.095 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'mqttGarageTemp' with state '1.00' in rrd4j database
2018-02-12 19:43:00.113 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'mqttGarageHumidity' with state '86.00' in rrd4j database
2018-02-12 19:44:00.076 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'mqttReedTemp' with state '10.0' in rrd4j database
2018-02-12 19:44:00.089 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'mqttReedHumidity' with state '50.0' in rrd4j database

Any ideas why the first chart looks good and second one not?


(Jürgen Baginski) #2

My initial guess would be that you are using strings although rrd4j does store numerals only. The conversion might have failed.failed .
Do you really have two definitions for the temp and humidity items as posted above?


(Martin Mois) #3

Changing the item type to Number nor implementing a rule that converts the String to float does solve the problem. Calling the REST API (http://raspberrypi:8080/rest/persistence/items/mqttGarageHumidity) does only list zeros.


(Josar) #4

RRD4J should not work at all with the strings.
Maybe you should also clean up after changing the items.

Additional you allready have groups, why not just persist them and not every item? It will make it easier to add more values.

Maybe there is something which differs from temp to hum value so rrd4j/openhab can’t auto convert the values?


(Martin Mois) #5

According to the RRD4J implementation, a StringItem is converted into a DecimalType (https://github.com/openhab/openhab1-addons/blob/master/bundles/persistence/org.openhab.persistence.rrd4j/src/main/java/org/openhab/persistence/rrd4j/internal/RRD4jService.java#L135). This conversion is based on the BigDecimal(String) constructor, hence rrd4j should also work with String items.

I have also tried to delete the rrd files as well as the tmp and cache folder under userdata.

The JSON message delivers the same format for temperature and humidity:

{"state": "Closed", "temperature": "22.0", "humidity": "35.0"}

(Josar) #6

Maybe i just missunderstood this, but good to now that strings also work.

NOTE: rrd4j is for storing numerical data only. Attempting to use rrd4j to store complex datatypes (eg. for restore-on-startup) will not work.

AÄÄHMMM
Do i see it right and are your defining the items two times? Not sure this is how it should be, and propose to reduce it to one item definition, or at least use different names for multiple items.

Group gTemperatures
Group gHumidities

String mqttReedTemp "Temp [%s]" (gTemperatures) 
   {mqtt="&lt;[mosquitto:/sensors/fenster-dach-bad:state:JSONPATH($.temperature)]"}
String mqttReedHumidity "Hum [%s]" (gHumidities) 
   {mqtt="&lt;[mosquitto:/sensors/fenster-dach-bad:state:JSONPATH($.humidity)]"}

String mqttGarageTemp "Temp [%s]" (gTemperatures) 
   {mqtt="&lt;[mosquitto:/sensors/garage:state:JSONPATH($.temperature)]"}
String mqttGarageHumidity "Humidity [%s]" (gHumidities) 
   {mqtt="&lt;[mosquitto:/sensors/garage:state:JSONPATH($.humidity)]"}

(Martin Mois) #7

Changing the configuration as described above does unfortunately not solve the problem. But thank you for pointing that out.

Could it be an issue with the step size? I have implemented a small Java app that opens the rrd database with rdd4j, but it only outputs zero and NAN.

Now I have used 300 seconds as new step size and wait until tomorrow.


(Josar) #8

This means at least the values are not in the database and so can also be not plottet correctly.
Changing the items to one will not imidiatly have an effect as there are still the bad numbers in the datatbase.


(Martin Mois) #9

But as mentioned before, the DEBUG log of the rrd4j persistence service says, it is persisting the correct values:

PS: Changing the step size and heartbeat did not solve the problem.


(Jürgen Baginski) #10

The DEBUG log shows what it is persisting (although it is hard to say if those numbers are 5 strings).
The better check is to look into the db what is actually in it, as long there are only zeros and Nan there is something wrong.


(Hilbrand Bouwkamp) #11

Was this problem ever solved? It looks similar to a problem I have: 2 charts and one of them shows strange values on the y-as, while the graphics visual look correct. It shows the same values in both basic ui and habmin. When I put only one definition in the rrd4j file it works. But when the definition is split over 2 definitions, like in this mentioned issue, I have this problem.


(Jürgen Baginski) #12

I can’t say if the problem as reported by the original poster is solved, however rrd4j does work for me without a problem.
Why don’t you post your actual problem (maybe in its own thread)?
?