Convert celsius to fahrenheit

have following MQTT broker data

/sensor/main//HUM/add111 {“Temperature”:23.22,“Humidity”:46.7,“created_at”:“2022-06-22T17:04:10.5833725Z”,“VersionInfo”:1.0,“ModuleType”:“HUM”,“value”:“46.7”,“Address”:111,“Name”:""}

How do I convert this to fahrenheit for display. Right now its showing celsius in OH

Thank you
Fahd

You’re missing a whole lot. You’ve shown us the raw message and jumped straight to how to see it on your UI. There’s a ton of stuff between those two points.

What’s your Thing/Channel config?
What’s your Item config?
What’s your UI config?



Hopefully this helps

Sadly not really. Screen shots are terrible. Please click on the code tab for the Thing and paste in the code you see there. Use code fences:

```
code goes here
```

Why use a String Item?

Create the Channel as a number Channel (all the configs you’ve already done will probably be the same.

One additional setting you’ll have is “Unit of Measurement”. Put °C there.

Recreate the Item as a Number:Temperature Item.

Click on “Add Metadata” and add “State Description”. In the “Pattern” section put in %.1f °F. That tells MainUI to convert the °C to °F (with one decimal place) in most places it’s shown in the UI.

Completed all the steps you mentioned. Still showing Celsius

UID: mqtt:topic:a618b11e4c:57e0706733
label: CC2356
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:a618b11e4c
location: CC2356
channels:
  - id: CC2356_C02
    channelTypeUID: mqtt:string
    label: CC2356_C02
    description: ""
    configuration:
      stateTopic: /sensor/main//CO2/add105
      transformationPattern: JSONPATH:$.value
  - id: CC2356_Humidity
    channelTypeUID: mqtt:string
    label: CC2356_Humidity
    description: ""
    configuration:
      stateTopic: /sensor/main//HUM/add111
      transformationPattern: JSONPATH:$.Humidity
  - id: CC2356_Temp
    channelTypeUID: mqtt:number
    label: CC2356_Temp
    description: ""
    configuration:
      stateTopic: /sensor/main//HUM/add111
      transformationPattern: "JSONPATH:$.Temperature "
      unit: °C

This has no effect on incoming MQTT data in older versions. Your OH version?

This is command I used

apt-cache policy openhab

I think @rossko57 is on to something. I don’t think that fix existed in OH 3.2 release.

So you can either upgrade to the latest milestone, wait a couple weeks for 3.3 to be released, or deal with this using a JS transformation that converts the °C to °F before it gets to the Item.

How would I use a JS transformation? just for learning purpose.

Start here Transformations | openHAB

Then here JavaScript - Transformation Services | openHAB

Then here Items | openHAB

Thank you for sharing, was able to get it to work with JS transformation

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.