MQTT unit?

i want to display and convert the recieved values from mqtt binding, made the definition of the unit in the things-file:


Bridge mqtt:broker:myAuthentificatedBroker “Mosquitto” [host=“”, port=1883, secure=false, username=“test”, password=“testPW”, cliendID=“openHab”] {
Thing mqtt:topic:meineWetterstation:EmpfangeneWerte “WS2080_pywws” @ “Garten” {
Type number : TemperaturAussen “Temperatur” [stateTopic=“weather/WS1080_pywws/temp_out_c” , unit=“°C” ]

To get the value with the right unit and formating of the description i use the .items-file:


Number outTemperaturDefault “Temperatur [%.1f %unit%]” (gWetter) {channel=“mqtt:topic:meineWetterstation:EmpfangeneWerte:TemperaturAussen”}
Number outTemperaturCelsius “Temperatur [%.1f °C]” (gWetter) {channel=“mqtt:topic:meineWetterstation:EmpfangeneWerte:TemperaturAussen”}
Number outTemperaturFarenheit “Temperatur [%.1f °F]” (gWetter) {channel=“mqtt:topic:meineWetterstation:EmpfangeneWerte:TemperaturAussen”}

In my sitemap only outTemperaturCelsius and outTemperaturFarenheit show the same value (outTemperaturFarenheit should be the temperature converted to Farenheit), there is no conversion. With the item outTemperaturDefault is no unit diyplayed.

Is there a trouble in my configuration or understanding?


If you want to use units, you need to use Quantity Type Items e.g. Number:Temperature

Thanks for the fast response,

it worked perfect for Temperature, Speed (km/h) and Pressure
to use an other dimension (for example mm) i tried to use

Number:Dimensionless outRegen “Regen [%.1f %unit%]” (gWetter) channel=“mqtt:topic:meineWetterstation:EmpfangeneWerte:Regen”}

Type number :   Regen   "Regen"   [stateTopic="weather/WS1080_pywws/rain"  , unit="mm"  ]

how can i define a custom qunatity type (for example mm oder l), how can i convert to temperature in °C to °F, where can i devine the speed (i would like to see it in mm/h and not km/h)?


Number:Dimensionless type is for proportions like percentage or decibels or parts-per-million
It won’t work with units of length like mm.

The idea of units is that it doesn’t matter much what units an Item state is in.
If you want to display in a particular unit, you specify that in the [state presentation] box e.g.
[%.1f mm/h]

ok, so the unit defined in mqtt.things is not used, right?

You’d have to read the binding docs. I’m not sure if it is only used for outgoing payloads.