[SOLVED] Display Hue Motion Sensor temperature in HABPanel chart based on RRD4j stored data

Good morning guys,

I am new to this community - so first a hello to all of you!

What do I want to accomplish?
I want to display a graph with temperature data in my HABPanel

What did I do so far?

  1. I installed the RRD4J Plugin:
  2. I defined my item to retrieve the temperature data from the Philips Hue Motion sensor:
Number hueMotionSensorTemperature "temperature [%.1f °C]" <temperature> { http="<[hueMotionSensorTemperature:60000:JS(getHueTemperature.js)]" }

This is working so far. I can display the data of this item in my HABPanel. It works with HTTP Binding and Javascript Transformation.

hueMotionSensorTemperature.url=http://192.168.178.7/api/myapikey/sensors/7
hueMotionSensorTemperature.updateInterval=60000
(function(i) {
    var json = JSON.parse(i);
    return parseInt(json["state"]["temperature"]) / 100;
})(input)
  1. I left my rrd4j.cfg in services folder empty, as I read comments that it is not required!
  2. I created the rrd4j.persist in the persistence folder and it contains:
Strategies {
	everyMinute : "0 * * * * ?"
}
Items { 
    hueMotionSensorTemperature : strategy = everyChange, everyMinute
}
  1. I enabled logging and get log entries like:
2018-09-30 09:43:27.958 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'hueMotionSensorTemperature' with state '20.04' in rrd4j database
  1. The file hueMotionSensorTemperature.rrd in folder persistence/rrd4j exists and gets recreated if I delete it…

Where is the problem?
Independent if I use the default chart in HABPanel or the RRD4j one with the hueMotionSensorTemperature as input it just shows no data. I have no more ideas why and that is frustrating me…

Edit: and also by accessing the charts directly it isnt displaying any data:

Edit2: I guess I am a step closer: rrd4j is a liar! The log says it is storing data but if I query the service for my item it shows that there is no data. But why is no data saved?

Edit3: found a lot of posts from @opus @martinvw @finkm @rlkoshak and so on. Maybe you guys are having an idea here. Would appreciate it!

Hope to get some help in here!

Best,
Dirk

Your setup seems correct (keeping fingers crossed), however reading your post you seem to have deleted the .rrd while the OH (or better the rrd4j bundle) was running. That COULD be the cause of your problem.
I’d try to stop OH, delete the .rrd file and restart OH (it migth be the same as stopping the rrd4j bundle, dleting the file and restarting rrd4j, BUT I AM NOT SURE on that!).

already tried that - no changes at all…

Any hints regarding rrd4j in the log during start-up? (I’m fishing in the dark!)

2018-09-30 14:02:13.759 [DEBUG] [org.openhab.persistence.rrd4j       ] - BundleEvent STARTING - org.openhab.persistence.rrd4j

2018-09-30 14:02:14.069 [DEBUG] [stence.rrd4j.internal.RRD4jActivator] - RRD4j persistence bundle has been started.

2018-09-30 14:02:14.159 [DEBUG] [org.openhab.persistence.rrd4j       ] - BundleEvent STARTED - org.openhab.persistence.rrd4j

2018-09-30 14:02:14.839 [DEBUG] [org.openhab.persistence.rrd4j       ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService}={service.id=333, temp.items=hueMotionSensorTemperature, service.bundleid=224, service.scope=bundle, hueMotionSensorTemperature.items=hueMotionSensorTemperature, hueMotionSensorTemperature.def=GAUGE,90,0,3,60, component.name=org.openhab.persistence.rrd4j, component.id=211, temp.def=GAUGE,90,0,3,60, hueMotionSensorTemperature.archives=MAX,.5,1,1440:MAX,.5,5,2016:MAX,.5,15,2668, temp.archives=MAX,.5,1,1440:MAX,.5,5,2016:MAX,.5,15,2668, service.pid=org.openhab.rrd4j} - org.openhab.persistence.rrd4j
2018-09-30 14:02:16.443 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Created temp = GAUGE heartbeat = 90 min/max = 0.0/3.0 step = 60 3 archives(s) = [ MAX xff = 0.5 steps = 1 rows = 1440 MAX xff = 0.5 steps = 5 rows = 2016 MAX xff = 0.5 steps = 15 rows = 2668] 1 items(s) = [hueMotionSensorTemperature ]

2018-09-30 14:02:16.834 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Created huemotionsensortemperature = GAUGE heartbeat = 90 min/max = 0.0/3.0 step = 60 3 archives(s) = [ MAX xff = 0.5 steps = 1 rows = 1440 MAX xff = 0.5 steps = 5 rows = 2016 MAX xff = 0.5 steps = 15 rows = 2668] 1 items(s) = [hueMotionSensorTemperature ]

2018-09-30 14:02:17.051 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Created default_other = GAUGE heartbeat = 3600 min/max = NaN/NaN step = 1 6 archives(s) = [ MAX xff = 0.999 steps = 1 rows = 3600 MAX xff = 0.999 steps = 10 rows = 1440 MAX xff = 0.999 steps = 60 rows = 1440 MAX xff = 0.999 steps = 900 rows = 2880 MAX xff = 0.999 steps = 21600 rows = 1460 MAX xff = 0.999 steps = 86400 rows = 3650] 0 items(s) = []

2018-09-30 14:02:17.238 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Created default_numeric = GAUGE heartbeat = 60 min/max = NaN/NaN step = 60 6 archives(s) = [ AVERAGE xff = 0.5 steps = 1 rows = 480 AVERAGE xff = 0.5 steps = 4 rows = 360 AVERAGE xff = 0.5 steps = 14 rows = 644 AVERAGE xff = 0.5 steps = 60 rows = 720 AVERAGE xff = 0.5 steps = 720 rows = 730 AVERAGE xff = 0.5 steps = 10080 rows = 520] 0 items(s) = []
2018-09-30 14:02:25.596 [DEBUG] [org.openhab.persistence.rrd4j       ] - ServiceEvent REGISTERED - {org.openhab.ui.chart.ChartProvider}={service.id=337, service.bundleid=224, service.scope=bundle, component.name=org.openhab.persistence.rrd4j.chartservlet, component.id=212} - org.openhab.persistence.rrd4j

2018-09-30 14:02:26.273 [DEBUG] [4j.internal.charts.RRD4jChartServlet] - Starting up rrd chart servlet at /rrdchart.png

2018-09-30 14:02:26.764 [DEBUG] [org.openhab.persistence.rrd4j       ] - ServiceEvent REGISTERED - {javax.servlet.ServletContext}={osgi.web.version=1.12.0, osgi.web.contextpath=/, service.id=338, osgi.web.symbolicname=org.openhab.persistence.rrd4j, service.bundleid=224, service.scope=singleton, osgi.web.contextname=custom} - org.openhab.persistence.rrd4j

Looking into the logs it seems that you have used an own rrd4j.cfg with a named resource " huemotionsensortemperature" and which uses 3 archives. That .cfg doesn’t look correct. Your setting for max is 3.0 , the log showed a value of 20.04 to be persisted, that migth not got excepted.

thanks for this hint. found a file in userdata/config/org/openhab called rrd4j.config with the following content:

hueMotionSensorTemperature.archives="MAX,.5,1,1440:MAX,.5,5,2016:MAX,.5,15,2668"
hueMotionSensorTemperature.def="GAUGE,90,0,3,60"
hueMotionSensorTemperature.items="hueMotionSensorTemperature"
service.pid="org.openhab.rrd4j"
temp.archives="MAX,.5,1,1440:MAX,.5,5,2016:MAX,.5,15,2668"
temp.def="GAUGE,90,0,3,60"
temp.items="hueMotionSensorTemperature"

both were my tests during setting up of my own rrd4j.cfg before someone mentioned, that it is not necessary. will stop the bundle, wipe this out and restart the bundle now!

fixed the file, but restart of server was needed to take effect. now the start looks like this, AND there is data in the API and chart! :blush: :sunny:

THANK YOU!!!

2018-09-30 17:53:07.614 [DEBUG] [org.openhab.persistence.rrd4j       ] - BundleEvent STARTING - org.openhab.persistence.rrd4j

2018-09-30 17:53:07.920 [DEBUG] [stence.rrd4j.internal.RRD4jActivator] - RRD4j persistence bundle has been started.

2018-09-30 17:53:08.059 [DEBUG] [org.openhab.persistence.rrd4j       ] - BundleEvent STARTED - org.openhab.persistence.rrd4j

2018-09-30 17:53:10.063 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Created default_other = GAUGE heartbeat = 3600 min/max = NaN/NaN step = 1 6 archives(s) = [ MAX xff = 0.999 steps = 1 rows = 3600 MAX xff = 0.999 steps = 10 rows = 1440 MAX xff = 0.999 steps = 60 rows = 1440 MAX xff = 0.999 steps = 900 rows = 2880 MAX xff = 0.999 steps = 21600 rows = 1460 MAX xff = 0.999 steps = 86400 rows = 3650] 0 items(s) = []

2018-09-30 17:53:10.191 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Created default_numeric = GAUGE heartbeat = 60 min/max = NaN/NaN step = 60 6 archives(s) = [ AVERAGE xff = 0.5 steps = 1 rows = 480 AVERAGE xff = 0.5 steps = 4 rows = 360 AVERAGE xff = 0.5 steps = 14 rows = 644 AVERAGE xff = 0.5 steps = 60 rows = 720 AVERAGE xff = 0.5 steps = 720 rows = 730 AVERAGE xff = 0.5 steps = 10080 rows = 520] 0 items(s) = []

2018-09-30 17:53:15.907 [DEBUG] [org.openhab.persistence.rrd4j       ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService}={service.id=335, service.bundleid=225, service.scope=bundle, service.pid=org.openhab.rrd4j, component.name=org.openhab.persistence.rrd4j, component.id=211} - org.openhab.persistence.rrd4j

2018-09-30 17:53:16.731 [DEBUG] [4j.internal.charts.RRD4jChartServlet] - Starting up rrd chart servlet at /rrdchart.png

2018-09-30 17:53:17.398 [DEBUG] [org.openhab.persistence.rrd4j       ] - ServiceEvent REGISTERED - {javax.servlet.ServletContext}={osgi.web.version=1.12.0, osgi.web.contextpath=/, service.id=338, osgi.web.symbolicname=org.openhab.persistence.rrd4j, service.bundleid=225, service.scope=singleton, osgi.web.contextname=custom} - org.openhab.persistence.rrd4j

2018-09-30 17:53:17.873 [DEBUG] [org.openhab.persistence.rrd4j       ] - ServiceEvent REGISTERED - {org.openhab.ui.chart.ChartProvider}={service.id=337, service.bundleid=225, service.scope=bundle, component.name=org.openhab.persistence.rrd4j.chartservlet, component.id=212} - org.openhab.persistence.rrd4j

2018-09-30 17:53:52.583 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'hueMotionSensorTemperature' with state '20.75' in rrd4j database

2018-09-30 17:54:02.141 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'hueMotionSensorTemperature' with state '20.75' in rrd4j database

I’d give it some minutes!!

edited, see above :slight_smile:

1 Like

BTW, I use my own .cfg. in order to save only that data that is needed (the default has data over years!!). In your case I would adjust the max value (you are expecting temperature above 3°, do you) and give it a try!

Mine looks like;

TempLogger.def=GAUGE,90,U,U,60
TempLogger.archives=MAX,.5,1,1440:MAX,.5,5,2016:MAX,.5,15,2668:MAX,.5,240,1460
TempLogger.items=MyItems
1 Like

Please mark the thread as solved. Thanks

How?

Tick the mark under the post that provided your solution
hc_292

1 Like