Hi guys,
I’ve got a question regarding a JSON-transformationPattern.
First things first (maybe it’s of interest to you).
I’ve bought a really, really cool device called WLANThermo, which is capable of retrieving various temperatures from BBQs/smokers. As it’s shipped /w WIFI and provides an API, you can easily access a JSON in order to integrate in smarthome applications.
Another neat feature is the built-in MQTT client, so it periodically sends statuses to a MQTT broker.
Now to my problem:
As I can’t manage to get the temperatures from MQTT to openHAB I’ve built a workaround with a PHP-file that gets the JSON-data and publishes the temperatures directly to openHAB via REST.
To get rid of that PHP-file I’d like to get the data /w openHAB directly from MQTT.
That’s the JSON that’s published to MQTT (I’d like to get the “temp”-nodes from the “channels”);
{
"system": {
"time": "1584794792",
"unit": "C",
"soc": 100,
"charge": false,
"rssi": -62,
"online": 0
},
"channel": [
{
"number": 1,
"name": "empty",
"typ": 3,
"temp": 39.6,
"min": 10,
"max": 35,
"alarm": 0,
"color": "#0C4C88"
},
{
"number": 2,
"name": "empty",
"typ": 3,
"temp": 9.7,
"min": 10,
"max": 35,
"alarm": 0,
"color": "#22B14C"
},
{
"number": 3,
"name": "Grillgut 1",
"typ": 3,
"temp": 67.9,
"min": 82,
"max": 93,
"alarm": 0,
"color": "#EF562D"
},
{
"number": 4,
"name": "Grillgut 2",
"typ": 3,
"temp": 68,
"min": 82,
"max": 93,
"alarm": 0,
"color": "#FFC100"
},
{
"number": 5,
"name": "Grillgut 3",
"typ": 3,
"temp": 66.8,
"min": 82,
"max": 93,
"alarm": 0,
"color": "#A349A4"
},
{
"number": 6,
"name": "Grillgut 4",
"typ": 3,
"temp": 68.6,
"min": 82,
"max": 93,
"alarm": 0,
"color": "#804000"
},
{
"number": 7,
"name": "GarraumUN",
"typ": 3,
"temp": 101.5,
"min": 93,
"max": 125,
"alarm": 0,
"color": "#5587A2"
},
{
"number": 8,
"name": "GarraumOB",
"typ": 3,
"temp": 9.1,
"min": 10,
"max": 35,
"alarm": 0,
"color": "#5C7148"
}
],
"pitmaster": {
"type": [
"off"
],
"pm": [
{
"id": 0,
"channel": 1,
"pid": 0,
"value": 0,
"set": 50,
"typ": "off",
"set_color": "#ff0000",
"value_color": "#000000"
}
]
}
}
So, within my mqtt.things I’ve set up a broker that’s working (already getting data from my weather-station) and the following thing;
Thing topic WLANThermo {
Channels:
Type number : wlanthermo_s1 "WLANThermo S1" [ stateTopic="WLanThermo/NANO-33e8b5/status/data/", transformationPattern="JSONPATH:$.channel[0].temp" ]
}
And my item that shows “Sensor 1r -°C”;
Number MQTT_WLANThermo_S1 "Sensor 1r [%.1f °C]" <temperature> (gMQTT, gSH_WLANThermo) { channel="mqtt:topic:mosquitto:WLANThermo:wlanthermo_s1" }
Could you please have a look and tell me what I’m missing?
Many thanks!