[SOLVED]Need help configuring MQTT item (Xiaomi BLE LYWSD03MMC & TheengsGateway)

Hi,
I have installed TheengsGateway on a separate machine and have configured it to send data to mosquitto running on RPI where openhab is running (with mqtt binding).

I’m using windows MQTT explorer to check what is published on mosquitto…
I see it under topic:
home/TheengsGateway/A4C13800DF22

you can see in the payload he sends temperature, humidity etc…

{"name":"ATC_00DF22","id":"A4:C1:38:00:DF:22","rssi":-60,"brand":"Xiaomi","model":"LYWSD03MMC","model_id":"LYWSD03MMC_ATC","tempc":26.9,"tempf":80.42,"hum":50,"batt":48,"volt":2.661}

i have created a new generic mqtt thing under mosquitto broker
mqtt:topic:mosquitto:e9533c6404

then added a channel for temperature
mqtt:topic:mosquitto:e9533c6404:Temperature
under it,
MQTT State Topic:
home/TheengsGateway/A4C13800DF22
(I also tried home/TheengsGateway/A4C13800DF22/tempc as tempc is published in the payload)

probably I’m doing something wrong, what would be the way to extract data from that json and display it as number

thanks!

You have to use JSONPATH to extract the value from the JSON Object.
Please be aware that you have to install the JSONPATH Transformation Service to use it.

There are two options to do the transformation. As you have multiple values which are all read only values, the simple way is, to create one string channel. stateTopic is home/TheengsGateway/A4C13800DF22.
Do nothing else for the channel.

Now link a number item to this channel, let’s begin with tempc In the link, set Profile to use JSONPATH (if the option does not appear, you forgot to install JSONPATH).
Set the JSON Path to $.tempc and enjoy. :slight_smile:
Repeat for humidity and battery by using $.hum and $.batt as JSON Path. With advanced options in the link, it should even pe possible to add °C to the temperature value to add units of measurement. But to be honest, I’ve never tested…

The other option is, to use the incomming state transformation and create multiple channels, but this way data will be received multiple times.

Thanks! Works like a charm!