[SOLVED] Converting minutes into hour

How did you associate the script with your Item? Where are you looking at a display?

What I did:
In the Openhab item from the sys info binding put the javascript in the profile:


This seems to work, an error in the javascript generates a log file entry.
I didnā€™t change the Item as I expected, the output value of the channel is changing:

And the widget looks like this:

component: oh-label-card
config:
  actionAnalyzerItems:
    - OpenhabSysteminfo_SystemUptime
  item: OpenhabSysteminfo_SystemUptime
  title: Uptime
  icon: oh:switch
  footer: =items.OpenhabSysteminfo_IPAddress.state

Applying a profile to a link alters the data from a channel before it gets updated to the Item.
The output of your transform is a string like ā€œ2 hours 10 minutesā€. You canā€™t update a Number type Item with a string like that.

1 Like

Thanks a lot. Got more understanding, how openhab works. :grinning:
But, still not solved the problem. Iā€™ll try to make a number2number javascript conversion by dividing it by 1440. Then I should get days ( hopefully )

We donā€™t know what ā€œthe problemā€ is. What are trying to achieve here, just a pretty transformation for display? If it is that, leave your Item in minutes and apply whatever transformation you want to the Itemā€™s state presentation pattern.

That is exactly, what I want to archive. Just transforming the minutes in the Widget Display to a better readable output like days/hours/minutes or similar. I searched the documentation but I didnā€™t find a way to do this.

Alright, stop fiddling with profiles if you donā€™t want to change the Items state.
Apply the transformation to your Itemā€™s state presentation pattern metadata. (Most of the docs are still OH2 and describe the same thing using in the Itemā€™s label.)

This thread is relevant for that -