Display UoM

Is it possible to change the default display Unit of Measurement for an item? My system defaults to kph for speed, which is great for some things, I want m/s. I can’t find a way to achieve this, but it might be my poor google-kung-fu.

I’m current on 4.1.0

You can set the unit metadata to a different unit to change the item’s unit:

Number:Speed "Rainfall" { unit="mm/h" }

Taken directly from here:

Nooooooo. Don‘t mess with the unit if you only want change the display format. Unit metadata should only be used if the value comes from a binding without UoM support or you need to changed the unit of the persisted value.

Use a state description for changing display units.

1 Like

To me it sounds as if he wants to convert kph to mm/h.
If you change the unit by state description then oh still shows the old value but with a different unit. At least this is my understanding or am I wrong?

unit Metatdata is about storing the data, state description pattern is how to display data.

So when using units of measurement, don’t care about converting values at all, this is the job of UoM, but set the unit ONCE to a reasonable unit (depends on the measurement itself, obviously) and set the state description pattern to whatever you want (well, at lest matching to your measurement unit).

So for example a given measurement, coming through mqtt is 853 (integer) and from documentation we know that this value is °F, but multiplied by 10 (just to make it a bit more complex…).
Instead of calculations just set the unit inside the channel to d*°F (this is deci degree Fahrenheit, not very common…)
Now at the Item, as we want the measurement to be stored as Kelvin :slight_smile: we set the Item to Number:Temperature and use metadata unit to K.
We want to get the display to be in °C (with one decimal), so we are setting the state description pattern to %.1f °C and we’re good to go.
BUT: you should never change the unit metadata to another unit, as this will mix up the persistence. So be wise when starting configuration of an UoM Item :slight_smile:
Of course you can change the unit afterwards, but then it’s best option to delete the persisted data to avoid messed up charts.
You can always change the pattern to your needs, though, as this will only affect the current displayed value.


I learned something today. :smiley:


Wow, well will you look at that. I had no idea that simply providing the unit in the string would magically make the conversion happen. I assumed if I put in %f mph and the data was in kph, it would simply display the kph value with the text on the end.
That’s really rather slick and answers my question, thank you very much!

1 Like

In fact Units of Measurement is a very mpowerful tool :slight_smile:

1 Like