MQTT Temperature conversion Kelvin to Celsius

Hi Folks,

I have a temperature reading of an MQTT thing in Kelvin and want to convert it into °C

my understanding of the UoM is, that the conversion is done by the OH3 Framework when i define the unit correctly

Maybe you can help me here

thing file:

Bridge mqtt:broker:SignalK "SignalK"
[
    host="172.16.25.2",
	port="1884",
    clientID="openHAB"
]

Thing mqtt:topic:SignalK:Enviroment "WT" (mqtt:broker:SignalK) {
    Channels:
        // Wassertemperatur
        Type number : Temperature  [stateTopic="vessels/self/environment/water/temperature",  unit="K"]
}

items file

Number:Temperature WasserTemp "Temperature [%.1f °C]" <temperature> {channel="mqtt:topic:SignalK:Enviroment:Temperature"}

output is still in Kelvin

Thanks a lot for ur help
mike

You need to do the desired conversion in the channel definition.

What do you mean by “output”, where are you looking?

:slight_smile: okay … but where ?
The unit is set to Kelvin and according to the openhab UoM Documentation the conversion between units should be done by the OH framework

Instead of telling the channel to give the unit “K” use “°C”.

i just display the output in the UI

Okay, we’ll guess that you are using OH3 and are referring to MainUI.
You’ve not told us what you see, but I guess its 285 K or similar?

The Item holds a temperature, it doesn’t matter what units that’s in so long as we convert to what we prefer when used e.g. displayed.

Embedding a [state presentation] in a file-defined Item’s label is a legacy of OH1.
It’ll work fine with legacy UI like BasicUI used with a sitemap.

But MainUI seems to ignore that, and requires you to set the Item metadata state description / pattern I think, for the same effect.

Nope … the temperature in the sitemap is also 290.6 K and not °C

I am confused… because I found this conversation which describes my problem to 100 percent

nope this doesn’t work at all, because the temperature reading on the channel is in Kelvin

:roll_eyes: I was wrong! Setting the channel “unit” results only in a changed unit-sign and not in a conversion. I must have missunderstood something. Sorry for that!
@rossko57 Thanks for stepping in!

Absolutely no problem :slight_smile:
i am happy for every litte help here …

Assuming your sitemap Text widget does not have a label= to override that given in the Item…

Note that sitemap based viewer will need a refresh to pick up edits in this area.

It sounds for all the world like your Item label is ignored.
Confident there is no muddle over Items?
Confident there are not both UI and file based versions?
You can see in your events.log what Item is getting changed by MQTT, and what to.
Try editing your Items file, retype that [presentation] in case of stray invisible character, make sure file loads as evidenced in your openhab.log
Change label text spelling, is that change seen?

I have to say the way I expect this to work is for binding to pass 290 K to Item, but Item to use [presentation] as default units when supplied, and convert to 17 C at the point of updating.
If true, still points at missing [presentation]

Comment: Opus digging into this further in

And it looks like MQTT binding has a bug here.