Converting Seconds to H:M:S

I am using a binding that reports the system uptime in seconds…

My item for illustration sake…

ItemUpTime Uptime [%d]

Is there a way I can change this to read out in Hours:Minutes:Seconds?

So instead of showing 45825 Seconds it would display as 12:43:45.

Looks like you’ve already done it.

Yes, I’ve done a manual calculation…how can I get the sitemap to display in H:M:S instead of just seconds which the binding returns?

So after thinking about this for another moment, I’m assuming this is one possibility of what TRANSFORMATIONS could be used for.

I have a bit of JavaScript code that will do the conversion that I want…what do I need to do to get the number of seconds into the code so that it can process and convert and then display the desired output?

var measuredTime = new Date(null);
measuredTime.setSeconds(XXXX); // specify value of SECONDS  XXXX is the value from OH
var MHSTime = measuredTime.toISOString().substr(11, 8);

If the item from your previous illustration is providing the uptime as a number of seconds, it should be possible to get that number via something like:

myItem.state

And this thread on converting strings to numbers could be useful.

@KidSquid, that javascript code snippet works only when uptime is smaller than one day, right?

Following link you can find idea how I converted seconds to days, hours and minutes in OH1 system info binding. It emulates Linux uptime format.

https://github.com/openhab/openhab1-addons/blob/master/bundles/binding/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoBinding.java getElapsedTime method start from line 324.

Take a look at this and see if you can pick up some ideas:

Maybe have a look here: