Mqtt and string parsing

Hello,

I would like to read data from a CNC machine using mqtt. The broker data is not key/value pairs but a comma separated string and depending on the MQTT topic the strings are of different length. E.G.:

200,DMG.PRODUCTION.TIMES.ACT_CYCLE,DEFAULT,16496,s,2023-05-30T13:44:40.246+02:00
400,DMG.TOOL_ACT.NUMBER_1,800,2023-05-30T13:44:17.264+02:00

Using CSV I was able to parse the data, but there are 2 problems:

  1. is there any way to define the CSV structure for each MQTT Topic separately? At the moment I create a completely new section for each topic which establishes an additional connection to the broker.

  2. it was not possible to parse date and time correctly. When I remove the miliseconds in the date definition, the date is parsed, but is wrong. With the specification of the miliseconds I get the message that the “. cannot be processed as +02:00”.

Many greetings
Christian

Hi,

It is very helpful to provide your config to show what you have tried.

it was not possible to parse date and time correctly. When I remove the miliseconds in the date definition, the date is parsed, but is wrong.

Please try the format found in this example: Better Go Playground and let me know how that works

is there any way to define the CSV structure for each MQTT Topic separately?

not beyond what you are already doing

Hello,

thank you very much for the help, with that it worked!