Getting BBQ temperatures from "WLANThermo" via MQTT

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!

You should have a look in your openhab.log and events.log

Have you installed the JSONPATH transformation service?

Hi @rossko57,
yes - “transformation-jsonpath - 2.5.2” is installed and running.
Both openhab.log and events.log are empty in regards to JSONPATH-errors and the MQTT_WLANThermo_S1 item.

openhab.log since updating of .things and .items;

>>> 2020-03-21 13:40:43.622 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'binding_mqtt_ip.things'
2020-03-21 13:52:15.794 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
>>> 2020-03-21 13:58:41.201 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'binding_mqtt.items'
2020-03-21 14:07:50.619 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 14:12:52.856 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 14:14:51.950 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 14:31:36.461 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 14:36:35.364 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 14:40:24.481 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 14:41:41.128 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 15:15:05.193 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 15:22:42.003 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 15:32:43.447 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!
2020-03-21 15:35:15.093 [ERROR] [00.internal.handler.KM200DataHandler] - Communication is not possible!

there is an “old” log-entry from today where I had a typo in the .things-config (but as you can see it is from 10:22)…

2020-03-21 10:22:53.367 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.channel[0].temp)' in XXX

…so I checked console if the transformation service is up and running;

272 │ Active │  75 │ 2.5.2                   │ openHAB Add-ons :: Bundles :: Transformation Service :: JSonPath

events.log contains only entries like the following (please note this is not the same item I’m using for MQTT, but instead these are the items that are filled via the PHP-script via the REST-API);

MQTT_WLANThermo_S* = MQTT
MQTT_WLANThermo_T* = REST

2020-03-21 15:38:30.088 [ome.event.ItemCommandEvent] - Item 'MQTT_WLANThermo_T*' received command X.Y

Sounds like your Item isn’t updating. Check channel config.
You can get your whole payload into a String Item to begin with. When that works, worry about JSONPATH. Solve your problem in small steps.

1 Like

Man, I need that one! Ordering today! Thanks for the tip!
What’s your problem with the mqtt broker?

Hi @Hydropower!

You’re welcome… here are the measurements of my last BBQ-smoking (just to show you how well the sensors are working - I ordered them also via WLANThermo).

The broker is working fine, I can’t manage to get the JSON from the broker as my item stays empty. As I’m doing other JSONPATH transformations /w openHAB I guess I’m missing something - maybe the path is wrong. Didn’t have the chance to test things out as it took some time to get the PP done :wink: !

If you need help /w setup of your WLANThermo, drop me a line buddy!

Looks really nice! Is it from the internal web page or the app?

That’s Grafana - I’m persisting the values via openHAB in influxDB and visualize them in Grafana (so self-made).

The solution to get WLANThermo-values into openHAB via MQTT;

things:

Bridge mqtt:broker:<your_brokername> [ host="<your_ip>", port=<your_port>, secure=<false/true>, username="<broker_user>", password="<broker_user_password>", clientID="<displayname_for_openHAB>" ]
{
	Thing topic WLANThermo {
	Channels:
		Type string : wlanthermo_s1 "WLANThermo S1" [ stateTopic="WLanThermo/<WLANThermo-name>/status/data", transformationPattern="JSONPATH:$.channel[0].temp" ]
                ... and so on
	}
}

items:

String MQTT_WLANThermo_S1_string "S1 (string) [%s]" { channel="mqtt:topic:<your_brokername>:WLANThermo:wlanthermo_s1" }
Number MQTT_WLANThermo_S1 "S1 (empty) [%.1f °C]"
... and so on

rules:

rule "MQTT/S1_Convert String to Integer"
    when
        Item MQTT_WLANThermo_S1_string changed
    then
        MQTT_WLANThermo_S1.postUpdate(Float::parseFloat(String::format("%s",MQTT_WLANThermo_S1_string.state).replace(',','.')))
    end
... and so on
1 Like

I don’t understand what you actual problem was. The payload used , comma as a decimal point?

The problem was that the payload is actually a string, not a number - therefore the item wasn’t updated. It worked until the point where the Number Item was linked with a String thing, thus the latter was capable as being declared a Number.

All MQTT payloads are strings, every one.
The output from every transform is always a string.

The binding handles type conversion to a given channel type e.g. number type channel, which can of course be linked to a suitable Item.
Of course that only works when the input string is suitable, e.g. “3.14” for number, but not “3.14X”

Which is all to say that your original setup, directly to a Number Item, was sound. Probably just needed a binding restart to pick up a file edit.