C to F Conversion or MQTT manipulation in OH 4.2 for InkBird IBS-TH2 Thermometer/Hygrometers

Good Morning,

I have a fresh 4.2 setup on a Raspberry Pi 5 with mosquitto and a Theengs OpenMQTTGateway. It’s all up and running. I currently have 2 things on it, an inkbird IBS-TH2 Thermometer/Hygrometer and an MQTT Broker. Both are showing Online and communicating.

The issue I’m having is that the temperature is reported in Celcius and I need to convert it to Fahrenheit. I’ve read a lot of the previous posts on temperature conversions and although the logic never changes, I can’t seem to figure out how to get it to work on 4.2. I create everything through the UI so I don’t have the .things file or .rules file that are mentioned in a lot of the posts. Transformations seem like what I need but I can’t find that anywhere in the configuration.

The payload as viewed in MQTT Explorer coming from the sensor contains this info:

{"id":"49:24:03:04:0F:8D","name":"sps","rssi":-56,"brand":"Inkbird","model":"T(H) Sensor","model_id":"IBS-TH1/TH2/P01B/ITH-12S","type":"THB","tempc":23.67,"tempf":74.606,"extprobe":false,"hum":54.24,"batt":100}

Is there a way to just extract tempf instead of tempc and be done with it? When I added the thing, there wasn’t a tempf channel available, only the one for tempc.

Any ideas?

Thanks!

Sure. On the Generic MQTT Thing set (check “show advanced”):

  • MQTT State Topic: the topic where this JSON is published
  • Unit: °F
  • Incoming Value Transformation: JSONPATH:$.temf

The Item linked to this topic should be a Number:Temperature with the unit also set to °F.

Make sure you have the JSONPATH add-on installed.

Note: don’t post screen shots. Click on the code tab and post the text you find there. Use code fences:

```
code goes here
```

For completeness, if you had a device that only reported the temp in °C, you would configure the following:

  • MQTT State Topic: topic where the °C is published
  • Unit: °C; this tells OH what unit the Channel is posting
  • Incoming Value Tansformation: what ever is required to extract that value from what ever is published by the sensor
  • Item Number:Temperature
  • Item’s unit set to °F

By configuring the Channel wuth °C and the Item with °F that tells OH that it needs to convert the value published by the Channel before updating the Item. In short, the conversion will happen automatically.

Thanks, but this is where the confusion sets in for me. When you say the “Generic MQTT Thing,” you’re referring to the thermometer, right? If so, I don’t see a “show advanced” option. If you’re referring to the MQTT Broker, then I do have “show advanced” but I don’t see a place for MQTT State Topic, Unit, or Incoming Value Transformation.

JSONPATH is installed and my item is configured as such:

label: Frog Temp
type: Number
category: temperature
groupNames:
  - FrogTH2
tags:
  - Point
  - Temperature

I’m not sure where to set the unit to F but I have a Metadata stateDescription Pattern of %.1f °F that I entered previously after reading another post.

Thanks!

Belay my last. I never created a Generic MQTT thing. I added them from discovery. I was able to find the settings and right now the temp is being converted to deg F. Thanks for the help.

Glad you got it working! Come back if you run into trouble again. This stuff is hard and we love to help.

1 Like

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