Formatting number item with sign

I have a number Item for which I have added the formatting option as such:

[%.1f °C]

It works well - but I want to format the number so, that for positive values the number is prefixed with a “+” just like the negative ones are prefixed with a “-”.

i.e. +19.7°C

I want to use the item to show the degree difference in todays meassure compared to yesterdays - and here would like the difference to be “signed” always.

I tried to find somewhere where the formatting options are defined, but without luck :wink:

Anyone ?

Have you tried UoM?

1 Like

Hi Martin,

Or you could use a javascript transformation for the item, where in the javascript you can prefix any positive values with a desired ‘+’.

1 Like

The %.1f stuff is java formatter, look for java docs.
I think %.1+f will do what you want.

See openHAB docs

1 Like

The %.1+f just gives “Err”…

… but %+.1f works !!! :wink:

Thanks for leading me onto the solution !

1 Like