Split strings (15 lines ASCII, max 20 char each) and store some of the lines in (INFLUX-) DB

Gents, I could need a helpful hand in my dashboard-project!

The content below shows, what the flow is getting in as strings from the TCP-node.
It's a basically a info-package which is always triggered by multiple sensors.

Challenges:
A) Split these lines and give it each line a name (e.g. by topic, object, array...)
B) Store some of the lines in a DB-table (INFLUX or MariaDB)

ABC
ABC
ABC
ID-Nr:12345
IP:000.000.000.000
ABC/ABC: 00- 01
Adresse:008-000
ML1- 8: --------
ML9-16: --------
ABC
TPD:IP
08:36:52 25.11.2000
ABC
ABC
L:095630 09h41 25.11.17

Hi George,

firstly, if you have any control over what the TCP node is getting, you should reformat the data into a sensible & extensible format (like JSON) - then part (A) of your task would be super simple.

If you have no say over the format of data, then please explain what you expect that list of strings to become.

e.g.

ABC                -->  a payload of ABC
ABC                -->  a payload of ABC
ABC                -->  a payload of ABC
ID-Nr:12345        --> topic: "ID-Nr"  payload: "12345"
IP:000.000.000.000 --> topic :"IP"     payload: "000.000.000.000"
ABC/ABC: 00- 01    --> etc
Adresse:008-000    --> etc
ML1- 8: --------
ML9-16: --------
ABC
TPD:IP
08:36:52 25.11.2000
ABC
ABC
L:095630 09h41 25.11.17

Also, if you a expecting to write this to a DB, then you probably want all values in one object (so read up on the join node for how to join messages into one object.


As for part (B) - worry about that later.

Is that multiple lines in one message, or multiple messages?
The best thing is to feed it into a debug node and show us what it looks like, then there should be less confusion. Also tell us what the result should look like.

Steve,
thank you and here my feedback. Your example looks great. Yes, one object is what i want.
Sry, I have problems to share my feedback in the same prof. format as you did...but I hope it's sufficient.

ABC --> topic: "Info" payload: "Text"
ABC --> topic: "CustomerName" payload: "Text"
ABC --> topic: "Branch" payload: "Text"
ID-Nr:12345 --> topic: "ID-Nr" payload: "12345"
IP:000.000.000.000 --> topic :"IP" payload: "000.000.000.000"
ABC/ABC: 00- 01 --> topic: "GER/BER" payload: "12345"
Adresse:008-000 --> topic: "Adress_008" payload: numeric (3)
ML1- 8: -------- --> topic: "ML1" payload: "12345678", mixed e.g. -1----7- or 123-567-
ML9-16: -------- --> topic: "ML9" payload: "12345678", mixed e.g. -1----7- or -23-5---8
ABC --> topic: "Status" payload: "Text"
TPD:IP --> topic :"TPD:IP" payload: "000.000.000.000"
08:36:52 25.11.2000 --> topic :"EMA_DateTime" payload: numeric
ABC --> topic: "UGType" payload: "Text"
ABC --> topic: "Slot" payload: "Text"
L:095630 09h41 25.11.17 --> topic: "MessageID" payload: numeric "Text" (straight to DB-field)

Yes Colin, I will provide the payload by tomorrow (CET).

Gents, I very much appreciate your support!
Here two examples from the payload and my feedback to Steve...now finally in a correct format.

Final goal is to store each line's content filtered (Steve) into DB-fields and publish it via INFLUXDB and GRAFANA and publish the whole message on one single status line in a dashboard.

Regarding those 8 digits in "ML1- 8:" and ML9-16:
Each number reflects a status. So every digit needs it's field in in the DB.

Example 1:
msg : Object
oemphasized textbject
topic: ""
payload: "ML1- 8: ---4---- "
_session: object
_msgid: "ccd362ee.9476b"

Example 2:
msg : Object
object
topic: ""
payload: "L:096699 12h00 28.11.17 "
_session: object
_msgid: "21e210a1.d1a9"

ABC                     --> topic: "Info" payload: "Text"
ABC                     --> topic: "CustomerName" payload: "Text"
ABC                     --> topic: "Branch" payload: "Text"
ID-Nr:12345             --> topic: "ID-Nr"  payload: "12345"
IP:000.000.000.000      --> topic :"IP"     payload: "000.000.000.000"
ABC/ABC: 00- 01         --> topic: "GER/BER" payload: "12345"
Adresse:008-000         --> topic: "Adress_008" payload: numeric (3)
ML1- 8: --------        --> topic: "ML1-8" payload: "12345678", mixed e.g. -1----7-
ML9-16: --------        --> topic: "ML9-16" payload: "12345678", mixed e.g. -1----7-
ABC                     --> topic: "Status" payload: "Text"
TPD:IP                  --> topic :"TPD:IP" payload: "000.000.000.000"
08:36:52 25.11.2000     --> topic :"EMA_DateTime" payload: numeric
ABC                     --> topic: "UGType" payload: "Text"
ABC                     --> topic: "Slot" payload: "Text"
L:095630 09h41 25.11.17 --> topic: "MessageID" payload: numeric

Are you getting that sequence of messages one at a time via TCP or have you split them up from a single packet?

If they are individual messages how to you know which of the ABC messages is which?

TCP: I am getting that sequence of messages one at a time. So a 15-string sequence comes in.
Triggers of this sequence of messages are external sensors.
ABC 1-3: Each one needs a topic as described in Steve's example / my update.

OK, so it is the order that matters. I would start by using a Join node to combine them all into a 15 element array. Then I think you will just have to write code in a Function node to go through the array and build a message for each one and send it on. You will need some error checking to recognise when there is one missing and presumably discard the lot in that case.

Thx Colin, so I have added the Join-node (mode manually, array, 15) and that looks already good.
I have no experience in writing the code for the Function-node.
Maybe you or anybody has the mood & time and would help me with that or shows me the direction.

Gents, a Python script is the current solution and it works pretty well.
But I could need your help in how to extract the "_value" which is in this example a 0 (zero).

Bildschirmfoto 2020-12-23 um 09.38.34 (1)

If you hover over this in the debug window you will see there is an option to copy the path for each of the elements - which it will put into the clipboard.

You can then use a change node to move it to message payload etc

Craig

Craig, that works perfectly fine. Thank you very muchđź‘Ť

No worries - glad to help

Craig

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.