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:
you can see in the payload he sends temperature, humidity etc…
i have created a new generic mqtt thing under mosquitto broker
then added a channel for temperature
MQTT State Topic:
(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
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.
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.
Repeat for humidity and battery by using
$.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!