Trying to extract furnace runtime

Hello all,

Trying to figure out how to return/display the furnace runtime.

I’ve added a call to the furnace in my http binding:


And then I created an item to display the entire string returned.

String Tstat2_Ystrdy “Yesterday runtime [%s]” { http="<[tstat2:600000:JSONPATH($.yesterday)]" }

And then this in my sitemap:

Text item=Tstat2_Ystrdy

And it returns the data as expected:

But what I’d like to get it to look like is:

Yesterday runtime 3hrs, 21min

How do I parse the string and format it like that?


Use JS(yesterdayRuntime.js) instead of JSONPATH. Make transform/yesterdayRuntime.js:

(function(json) {
  var datalog = JSON.parse(json);
  return "Yesterday runtime " + datalog.yesterday.heat_runtime.hour + "hrs, " + 
    datalog.yesterday.heat_runtime.minute + "min";

Thanks for that, but where do I put it???

Unfortunately you’re talking above my head…

You would create a text file named yesterdayRuntime.js in the /etc/openhab/configurations/transform directory on your openHAB server (assuming you installed openHAB via the official apt-get instructions; otherwise, wherever your transform directory is on your installation). The file would contain:

(function(json) {
  var datalog = JSON.parse(json);
  return "" + datalog.yesterday.heat_runtime.hour + "hrs, " + 
    datalog.yesterday.heat_runtime.minute + "min";

You would then change your Tstat2_Ystrdy item configuration to look like this:

String Tstat2_Ystrdy "Yesterday runtime [%s]" { http="<[tstat2:600000:JS(yesterdayRuntime.js)]" }

That makes sense and work perfectly! Appreciate the lesson today.

Have a Merry Christmas and Happy New Year!

1 Like