MQTT Custom name space Dealing with strings

Hi All,

I'm subscribing to a topic that has mutable tags of in two 16bit modbus registers, what is the best may to combine the registers and break the string up into usable tags?

This image is too small to see anything.

Thanks Kevin, i've uploaded a better image

It looks like that topic is getting JSON payloads published to it, that might be a good first stop. Have you tried enabling "JSON Payload" in the Optional settings of your Custom namespace in MQTT Engine? That would at least give you a break-out of that data array in tags within MQTT Engine.

Hi Kevin,

Yes i've tried, i don't seem to receive anything when i enable the JSON payload

Can you copy paste the whole JSON payload here? Maybe we can inspect it to see if it’s not actually valid JSON. I see literal “\n” in the screenshots which is not a promising start.

Also, you might have to:

  • Delete the existing tag (from the previous configuration) in MQTT Engine.
  • Wait for a new message to be published to that topic.
  • Inspect the Status -> Diagnostics -> Logs page of the Gateway web UI and look for any JSON parsing errors from MQTT Engine (if you don't see the expected result, which should be a folder named 818MFMHive and tags for each of the keys in the JSON object).

Hi Kevin,

Its not being sent to the broker in JSON, its a string,

Its sent to the Hive broker as the string below.

{"TS" : "%date%", "Slave name" : "B18_Hive_Connection", "data" : "%data%", "Register Request" : "%name%"}

I'm receiving the same string in the ignition engine and MQQT FX as below

{"modbus_B18_Hive_Connection":"{"TS" : "02/11/2023 15:37:31", "Slave name" : "B18_Hive_Connection", "data" : "[-5325,17934]", "Register Request" : "ToTkW"}\n\n.{"TS" : "02/11/2023 15:37:32", "Slave name" : "B18_Hive_Connection", "data" : "[16384,17257]", "Register Request" : "V1N"}\n\n"}

Where does that substitution happen?

It looks like something along the chain is bungling the JSON encoding/decoding and you end up with a string payload resembling JSON but not actually JSON.

not sure, maybe if it try and format the sent string into a json array it might work.

Thanks All,

I managed to get this sorted, for some reason Ignition engine with the JSON payload enabled kept giving errors when i used double quotes. it worked fine in single quotes. i always taught double quotes was Propper json.
"Name" : "Value" vs 'Name' : 'Value'