Hello people! I am having some troubles with formatting mqtt messages sent from my device. I am quite a beginner with openhab 2.5 so please consider that I migh be missing something very obvious, nevertheless, here is my issue.
I set-up an MQTT connection between my device and my openHAB server and everything works, but I can’t seem to upscale it.
current implementation (few sensors, one topic per sensor):
A couple of sensors are attached to my raspberry-pi (say: temperature, humidity, battery_level, …). This raspberry-py sends data to my openHAB server via MQTT protocol. Every sensor is a Thing, every Thing is linked to a Channel, and from the topic name I know what the sensor is streaming.
when I read the mqtt messages from my python client I get something like this:
- topic = Temperature
- payload = “56”
So far so good, everything works.
desired solution (one topic for many sensors)
Now I am going to add 9 more different temperature sensors, 9 more humidity sensors, and so on.
I created the related Things (so fe, Temperature_2, Temperature_3, …) and want to send their data along with the same MQTT message that I am already using for the temperature. The goal is to produce an MQTT message like this:
- topic = Temperature
- payload = {sensor1: 56, sensor2: 45, …}
problem
I tried adding all my Temperature Things to the temperature channel, but the payload doesn’t change and only reports the numerical temperature value of whatever sensor is streaming data.
I think I should be using the Outgoing Value Transformation. I have installed the JSONPATH extension and set the “outgoing value transofrmation” to “JSONPATH:$.device.status.temperature”
to see if it did something, but it cannot parse the experssion and thus no message is sent.
how can I fix this? How can I set the payload of the MQTT message?
Thank you very much in advance!