Create many s7 node entries

Hello everybody,

I want to create a lot of variables from TIA Portal to Node-RED, but there are a lot of them. I can export .json the node and create several, I am trying to do it from excel but it is a lot of concatenation.

Or how can I read 200 boolean variables from a data block and then have that variable set to true so I can manage it to send an email referring to that variable?

What can I do?

variables

Thanks for your help!

Hello, can't you just read all variables at once and then parse it to your requirements?
image
to create all variables you can import csv file, so you don't have to do one by one
image

And how do I analyse according to the requirements, for example if it is true or false, if there are two hundred boolean variables, and show the ones that are true.

Thank you very much

Hello, lets do it one step at the time...
1.please read all variables in single node instead of separate one by one.
2.Msg.payload will look like: Tag1: true, Tag2: false, Tag3: false, Tag4: true, Tag5: false
3.Then based on this object you filter the tags that you want to use and send it in email

1 Like

What I do for individual nodes, I store the variable s7 in this function
flow.set('ALR_Dif_relay',msg.payload)
return msg;

Then in another node function
var ALR_Dif_relay = flow.get('ALR_Dif_relay');

and then a conditional that if true, is stored in a variable and a message and sent in a mail, so with several variables together.

My question is how do I collect all those variables that are true, and put them as a body for an email.

Thank you very much for answering

[{"id":"b07cd5d8a9884a8e","type":"function","z":"279d0ea8.c23d82","name":"FilterTrueTags","func":"function filterTrueTags(tags) {\n    return Object.keys(tags).filter(key => tags[key] === true);\n}\n\nconst tags = msg.payload\n\nmsg.payload = filterTrueTags(tags)\n\nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":560,"wires":[["3b62b96a624b4f6c"]]},{"id":"b3df672959fdad08","type":"inject","z":"279d0ea8.c23d82","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Tag1\":true,\"Tag2\":false,\"Tag3\":false,\"Tag4\":true,\"Tag5\":false,\"NewTag0\":false,\"OldTag1\":true}","payloadType":"json","x":290,"y":560,"wires":[["b07cd5d8a9884a8e"]]},{"id":"3b62b96a624b4f6c","type":"debug","z":"279d0ea8.c23d82","name":"debug 285","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":560,"wires":[]}]

This way you will filter out variables which are true,
Then you can do whatever you want to do - iterate over it and create the string you want and forward it to email

1 Like

It worked, thank you very much!

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