Converting the Payload from a Thermometer connecting through MQTT

Hello,

I am running Openhab 3.3 Using the last OpenHabian Image on a raspberry pi 3.

Lately, i have been working on connecting a Meat Thermometer (Thermopro TP25) To OpenHab, to monitor the channel temperatures.
I managed to connect it through a Bluetooth to MQTT project, specifically, esp32-ble-mqtt.

The project works, however, the payload i receive from the gateway is a little bit funky. I currently receive a string that shows the decimal values of each of the bytes that compose the payload. An example of the payload received from the Bluetooth gateway is the following:

8,15,90,12,0,255,255,255,255,2,87,255,255,255,255,255,255,244,1,64

Each of those numbers is a byte from the payload, and they represent different things. For example,
the 8th and 9th numbers (255,255) are temperature probe channel 1, 10th and 11th (2,87) are temperature probe 2, etc etc.

So my question is, from this point, how can i separate this string into different temperature channels, battery indication, etc? If this was a json string, i would use the json transformation, but it is not.
The configuration of the mqtt thing also only gives an example for using the json transformation, which makes me think that is the only transformation that can be used?

Any help would or ideas would be appreciated.
Thanks!

You can use any transformation. JSONPATH is just what’s typically available from an MQTT device.

I’d suggest using JavaScript to parse the comma-separated values into an array and report back the values you want. Something like this.

https://www.tutorialrepublic.com/faq/how-to-convert-comma-separated-string-into-an-array-in-javascript.php

You would need a separate script for every value you want to pull out.

There’s probably a better solution that I’m not aware of, and if there is then I trust that someone will chime in to tell us about it. :wink:

Cool, thanks @rpwong, i will keep an eye on more responses here.
In the mean time, do you know how do you call a javascript transformation from the “Input transformation” mqtt channel?

For extracting multiple values from one input string, consider using a rule to analyse an Item containing raw data.
A rule can interact with many Items, a transformation is limited to returning just one value.

1 Like

Thanks @rossko57 ,
The way i was thinking about this is to mayne link a bunch of items to the same channel, and then use a different transformation on each, and that way it is all kept as object definitions.
Thanks!

Sorry, I’ve no idea about this as I don’t use input transformations.

From the point of view of good design and efficiency which of these is better?

1)To have multiple channels mapped to the same mqtt topic, and use different transformations for each channel.

or

2)To have multiple items associated to 1 channel that is mapped to one mqtt topic, and to use profiles on each link?

Thanks!

Hello,

If you are interested we can integrate it to Theengs Decoder
Once done it will be available with auto discovery into OpenHAB throug an esp32 with Openmqttgateway or a server with Theengs Gateway

We will need some raw broadcasted data and the value of the temperature that you are seeing with each raw data.

Hello @1technophile ,

That would be great, however, i did asked about this device in the Openmqttgateway community forum, and my understanding is that this device cannot be integrated into Openmqttgateway because it requires a connection and notification subscriptions. Thread Below:

However, if it is possible, it would be great, and i would be happy to help.

Thanks

Thanks for bringing this up!

Decoding following a connection is indeed not supported right now but definitely into our roadmap: Theengs Roadmap · GitHub

Thanks @1technophile,
Is subscribing to notifications on the roadmap too?

Yes we will add it

That is great news @1technophile ! Can’t wait to test it!
Thanks