Show UPS runtime on a chart?

I currently have a string item that holds a “runtime” from my APC UPS and it looks something like this…

Can anyone suggest how I could convert this into something that could be visualised on a chart? I’m guessing I’d need to convert it into some sort of hours and decimals?

Convert it to minutes and display that.
I’ve done it that way. I know I have 1600 minutes normally so can watch it reduce from that.

To elaborate on Crispin’s solution:

  1. Change the Item to store the total minutes or seconds
  2. Add a JS transformation to convert the total to the more readable hours minutes seconds
  3. Persist and chart the total value

Here is a transform I use to convert minutes to dd:hh:mm

(function(i) {
    if(isNaN(i)) return "NAN";
    var mins = i%60
    var totalhours = Math.floor(i/60)
    var hours = totalhours%24
    var days = Math.floor(totalhours/24)
    var pad = "00";
    return days+":"+(pad+hours).slice(-pad.length)+":"+(pad+mins).slice(-pad.length)+":00";
})(input)

Thanks guys, the UPS provides this data via the SNMP binding and from what I can see I can’t get the runtime in minutes… It just provides it as something like “6:02:00:00”.

Hi Tommy,
And it that hours:minutes:seconds:hundreds or days:hours:minutes:seconds?

We can build a simple JS transform to change this into minutes

I’d say at full capacity it’ll be Hours, Minutes, Seconds, Ms…

But eventually the hours might drop off if it was running one batteries and there was less than an hour left…

And I guess if I added more battery capacity it could start adding days to the front?

We’ll assume that it’s HH:MM:SS:XX

We need to do the inverse on the js function that @rlkoshak provided

Save the following in upsmins.js in the transformation folder

(function(i) {
    var hours = parseInt(i.split(':')[0])
    var mins = parseInt(i.split(':')[1])
    var output = hours * 60 +  mins
    return output
})(input)

So you need another item:

Number UPSmins

And a rule

rule "Convert UPS string to minutes"
when
    UPSString changed
then
    UPSmins.postUpdate(transform("JS", "upsmins.js", UPSSting.state.toString)
end