Rrd4j: smoothen data and edit rrd-files

I encountered an error in my Mi Smart Binding, which resulted in temperatures in 100°C:

now I have two issues:

Editing rrd-files:
As described in HowTo Change values in an rrd4j database I tried to edit the .rrd, but encountered this error in my JAVA-SE with the JAR @opus recommended in his thread (while opening the .rrd file):

C:\openHAB2>java -cp rrd4j-2.1.1-inspector.jar org.rrd4j.inspector.RrdInspector
Exception in thread "main" java.lang.NoClassDefFoundError: org/rrd4j/core/RrdDb
        at org.rrd4j.inspector.MainTreeModel.setFile(MainTreeModel.java:19)
        at org.rrd4j.inspector.InspectorModel.setFile(InspectorModel.java:37)
        at org.rrd4j.inspector.RrdInspector.loadFile(RrdInspector.java:361)
        at org.rrd4j.inspector.RrdInspector.selectFile(RrdInspector.java:355)
        at org.rrd4j.inspector.RrdInspector.<init>(RrdInspector.java:60)
        at org.rrd4j.inspector.RrdInspector.main(RrdInspector.java:599)
Caused by: java.lang.ClassNotFoundException: org.rrd4j.core.RrdDb
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 6 more

C:\openHAB2>java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) Client VM (build 25.221-b11, mixed mode)

next question: is there a possibility to include a logic for values coming from bindings?
e.g.: I can rule out temperatures above 50°C

Thanks for your help!

General idea -

Depending on the binding, you may be able to implement something like that in a transformation script or a transform profile.

1 Like

I hate proxy-items just for the purpose of filtering out faulty values, but yeah, guess this is the only solution then, if the binding gets the values directly from the devices and hasn’t a logic for that…

Sounds like the error I encountered. Did you use the rrd4j inspector file I provided a link for?

jupp. that exact JAR. I have two .rrds, but I expect both the same:

[11:16:40] openhabian:~$ sudo find / -name *.rrd
[sudo] Passwort für openhabian:

I took the one from /srv/openhab2-userdata/persistence/

I would have taken the one from the other location, however I can’t say if that would make a difference (don’t know what the other is).
On what system did you try to edit? On the machine running openHAB? I used my Windows client and not the Raspi running openhabian.

Back home at my windows machine and retried it, the command to be used is of course:

java -cp rrd4j-2.1.1-inspector.jar org.rrd4j.inspector.RrdInspector if you are using the one from the link in the last post!

I downloaded the .rrd from openHABian running openHAB 2.4 stable onto my windows-machine; downloaded the linked JAR-file and ran the JAVA there - I guess, just as you did. Perhaps my JAVA-version is too new?

yes, I changed the jar-file name also…

On my Windows10 client I have java version 1.8.0_221 and using the actually downloaded version of the rrd4j-2.1.1-inspector.jar did start for me without a problem.
Didi you start this command from the folder where the …inspector.jar is located?

ok - java-version is identical. I cd in the directory an then start the inspector… strange…

In this case I am out of ideas, sorry!

If these are actually RRDs you can use rrdtool to

  1. Dump the range around the spikes
  2. Find the spike yourself
  3. Issue an rrd update for that timestamp value with a new value.

I’m sure there are spike removers out there for processing RRD files. Try a google search.

If rrd4j alters or uses a custom RRD format then you can’t use rrdtool.

Cacti does the spike removal at display time and provides a button to remove spikes but I realise that doesn’t help you.

Finally and most importantly, RRD files are architecture specific. If you write an RRD file on ARM you cannot open it on AMD64. Not with the normal RRD Tool stack anyway. You “can” export the RRD as XML and import the XML on the other architecture. You can at that time filter it for spikes.

EDIT: Reading a little on rrd4j it might be a reimplmentation and being Java got around the architecture specific problem. However it could still be compatible with the original RRDTool suite of tools which will allow you to use much more readily available software to remove spikes.

I used the above mentioned rrd-inspector on my windows machine to remove such spikes.