[SOLVED] Clarification required for use of prefixes with UoM (Units of Measurements)

Hi all,

According to the docs:

The ‘MetricPrefix’ class provides prefixes like MILLI, CENTI, HECTO, etc. which are wrappers to create derived units.

Sounds great!

But what it the syntax to use for the prefixes?
Are there any examples?


The Reference:

Thanks @hr3
I have read that and there is virtually no information about the use of prefixes and the syntax.

All there is is:

Coding the UoM
When using units, metric prefixes (like MILLI, CENTI, HECTO, …) and dimensions please make sure to use the following package imports: For units and metric prefixes use org.eclipse.smarthome.core.library.unit package, for dimensions use the org.eclipse.smarthome.core.library.dimension or the official javax.measure.quantity package.

That’s it…

That is why I am asking about the prefixes

The example to convert temperature to Fahrenheit, use °C to get Celsius etc.

Number:Temperature temperature "Outside [%.2f °F]" { channel="...:current#temperature" }

Show the unit

"Outside [%.2f %unit%]"

Thanks I know that
I am asking specifically about the use of PREFIXES


1 Like

Thanks but I know what the SI prefixes are. What I am asking is how do I use then in openHAB. What is the syntax?

Is it just to add m in front of the symbol like mA for millamps?


Yes, try out.

Cool thanks

A other interesting possibility

var fahrenheit = myTemperature.toUnit("°F")

Me Likey