JSON payload in MQTT message
-
Hi there, hope someone can point e in the right direction with this. I'd like to modify the mqtt client in a way that it posts json payloads containing the sensor id and possibly other information in the message. Where and how would I go for this?
Thanks, jjk
-
You could modify the protocol file found here:
https://github.com/mysensors/MySensors/blob/development/core/MyProtocolMySensors.cpp
-
thanks for the lead, I will check into that!
-
Do you mind if I ask what are you trying to do? I'm just curious
-
I don't mind at all
The idea is to post the sensor data to an uninformed controller/service, possibly web-based. Currently, the service would need to know what sensors are available and subscribe to the corresponding mqtt topics to get the sensor value as the message. I'd like it to simply subscribe to the top-level mystt topic and get all necessary information (like sensor id etc. ) in the actual message. There might be other ways to do this, I'm just experimenting and using a json container seems like a clean solution.
-
Maybe you could take a look at how they implemented the mysensors mqtt plugin in other controllers without reinventing the wheel
-
no intention to reinvent anything that is proven and works If you could kindly point me in the right direction for an example, I am more than happy to rely on what's available!
-
Have you already looked at github? https://github.com/search?utf8=✓&q=mysensors+plugin
-
I have not, but will now thanks!