Error sending OPC UA variable

#1

Hello
I use OPCua-iiot contrib to access to OPC UA variables inside an OPC UA server.
I can read and write with no problem, using the predifined nodes.

But there, i need to use the 'change' node to prepare the content of the msg to be sent to set a value in an OPC UA variable.
I get the result :"Wrong Inject Type undefined! The msg.injectType has to be write."
I can't find any expmlaination about this error.

Here is my flow :
[{"id":"e49844ac.af9d58","type":"change","z":"10110044.30b59","name":"Préparation des datas à envoyer","rules":[{"t":"set","p":"payload","pt":"msg","to":"{"topic":"","nodetype":"inject","injectType":"write","addressSpaceItems":[{"name":"xSend","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xTest","datatypeName":"Boolean"}],"payload":true}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":586.0195388793945,"y":632.0039043426514,"wires":[["a6b3e89a.5f1b48","1b4c06d.0742df9"]]},{"id":"4ba9a4f7.395bbc","type":"OPCUA-IIoT-Response","z":"10110044.30b59","name":"","compressStructure":false,"showStatusActivities":false,"showErrors":false,"activateUnsetFilter":false,"activateFilters":false,"negateFilter":false,"filters":[],"x":1098.01953125,"y":626.0039129257202,"wires":[["d166869f.3d1c58"]]},{"id":"d166869f.3d1c58","type":"debug","z":"10110044.30b59","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1268.01953125,"y":626.0039129257202,"wires":[]},{"id":"c174f2b7.b5c62","type":"inject","z":"10110044.30b59","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":335.8984565734863,"y":621.953145980835,"wires":[["e49844ac.af9d58"]]},{"id":"a6b3e89a.5f1b48","type":"OPCUA-IIoT-Write","z":"10110044.30b59","connector":"21582029.3743a","name":"Envoi datas préparées","justValue":true,"showStatusActivities":true,"showErrors":true,"x":896.0195159912109,"y":632.0038890838623,"wires":[["4ba9a4f7.395bbc"]]},{"id":"1b4c06d.0742df9","type":"debug","z":"10110044.30b59","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":852.89453125,"y":725.6875,"wires":[]},{"id":"21582029.3743a","type":"OPCUA-IIoT-Connector","z":"","discoveryUrl":"","endpoint":"opc.tcp://127.0.0.1:4840","keepSessionAlive":true,"loginEnabled":false,"securityPolicy":"Basic128Rsa15","securityMode":"SIGNANDENCRYPT","name":"LOCAL SERVER","showErrors":true,"individualCerts":false,"publicCertificateFile":"","privateKeyFile":"","defaultSecureTokenLifetime":"","endpointMustExist":false,"autoSelectRightEndpoint":false,"strategyMaxRetry":"","strategyInitialDelay":"","strategyMaxDelay":"","strategyRandomisationFactor":"","requestedSessionTimeout":"","connectionStartDelay":"","reconnectDelay":"","maxBadSessionRequests":"10"}]

I don't think i made an error in the json syntax... so, can anybody help me?
{
"topic": "",
"nodetype": "inject",
"injectType": "write",
"addressSpaceItems": [
{
"name": "xSend",
"nodeId": "ns=5;s=Arp.Plc.Eclr/MainInstance.xTest",
"datatypeName": "Boolean"
}
],
"payload": true
}

0 Likes

#2

Hi there.
Nobody could answer?
Is my request not clear?
Where is there any detailled explanation about the errors Node-Red nodes return?

0 Likes

#3

Your flow isn't currently importable.Please read the following post How to share code or flow json and then edit the above message.

The error comes from the contrib node you are using, you could contact the developer to raise the issue via the nodes github page.

0 Likes

#4

Now, I have fixed the problem by using an other node.
Here is an example wich send an email when an OPC UA tag 'xSend' is set to TRUE, and it sets the OPC UA tag 'xSent' to true when the mail has been sent.
xSent returns to False when xSend returns to false.

[{"id":"10110044.30b59","type":"tab","label":"Send Mail","disabled":false,"info":""},{"id":"d0cb2109.ab173","type":"OPCUA-IIoT-Inject","z":"10110044.30b59","injectType":"read","payload":"","payloadType":"date","topic":"","repeat":"5","crontab":"","once":false,"startDelay":"","name":"Scan xSend ...","addressSpaceItems":[{"name":"xSend","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSend","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strText","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strMailTo","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strMailCC","datatypeName":""},{"name":"","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.strMailBCC","datatypeName":""}],"x":236.00001907348633,"y":248.00000286102295,"wires":[["4c0f65aa.553d3c"]]},{"id":"e3f86348.7ae06","type":"comment","z":"10110044.30b59","name":"Lecture texte à envoyer","info":"","x":202.00001907348633,"y":70.00000381469727,"wires":[]},{"id":"33c9ab4f.6e6904","type":"change","z":"10110044.30b59","name":"copy mail adresses, and strText in Mail","rules":[{"t":"set","p":"to","pt":"msg","to":"payload[3].value","tot":"msg"},{"t":"set","p":"cc","pt":"msg","to":"payload[4].value","tot":"msg"},{"t":"set","p":"bcc","pt":"msg","to":"payload[5].value","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload[1].value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1411.00004196167,"y":245.00001335144043,"wires":[["ab1624f6.a3f398","7518e5a1.a4f6bc","4b371b6a.c3f7c4"]]},{"id":"ab1624f6.a3f398","type":"e-mail","z":"10110044.30b59","server":"smtp.gmail.com","port":"465","secure":true,"name":"","dname":"Sending mail","x":1708.0001945495605,"y":246.0000286102295,"wires":[]},{"id":"4c0f65aa.553d3c","type":"OPCUA-IIoT-Read","z":"10110044.30b59","attributeId":"13","maxAge":1,"depth":1,"connector":"21582029.3743a","name":"... In the local server","justValue":true,"showStatusActivities":true,"showErrors":true,"parseStrings":false,"historyDays":"","x":442.0000190734863,"y":247.00000286102295,"wires":[["8b5a0cd8.fb222"]]},{"id":"8b5a0cd8.fb222","type":"OPCUA-IIoT-Response","z":"10110044.30b59","name":"Wait for answer","compressStructure":true,"showStatusActivities":true,"showErrors":true,"activateUnsetFilter":false,"activateFilters":false,"negateFilter":false,"filters":[],"x":672.0000152587891,"y":246.00000190734863,"wires":[["4abaa77f.5c3dc8","7c7aec60.dd4ea4","abdef645.a4af28"]]},{"id":"4abaa77f.5c3dc8","type":"switch","z":"10110044.30b59","name":"Test xSend = true","property":"payload[0].value","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":881.0000190734863,"y":248.00000190734863,"wires":[["6198d7d9.ae24f8"]]},{"id":"7518e5a1.a4f6bc","type":"OPCUA-IIoT-Node","z":"10110044.30b59","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","datatype":"Boolean","value":"true","name":"Send xSent ...","topic":"","showErrors":false,"x":1713.8868827819824,"y":302.45704460144043,"wires":[["e7f659ad.f856d8"]]},{"id":"e7f659ad.f856d8","type":"OPCUA-IIoT-Write","z":"10110044.30b59","connector":"21582029.3743a","name":"... to local server","justValue":true,"showStatusActivities":true,"showErrors":true,"x":1954.01997756958,"y":433.00394344329834,"wires":[["17416cc1.3e6113"]]},{"id":"17416cc1.3e6113","type":"OPCUA-IIoT-Response","z":"10110044.30b59","name":"Wait for answer","compressStructure":false,"showStatusActivities":false,"showErrors":false,"activateUnsetFilter":false,"activateFilters":false,"negateFilter":false,"filters":[],"x":2193.0200691223145,"y":433.00399684906006,"wires":[["33609b88.7c4cc4"]]},{"id":"33609b88.7c4cc4","type":"debug","z":"10110044.30b59","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":2380.0200958251953,"y":433.00395011901855,"wires":[]},{"id":"6198d7d9.ae24f8","type":"switch","z":"10110044.30b59","name":"Test xSent = false","property":"payload[2].value","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1117.019618988037,"y":248.00393104553223,"wires":[["33c9ab4f.6e6904"]]},{"id":"e4f13e7.aeee0c","type":"OPCUA-IIoT-Node","z":"10110044.30b59","injectType":"write","nodeId":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","datatype":"Boolean","value":"","name":"Send xSent ...","topic":"ns=5;s=Arp.Plc.Eclr/MainInstance.xSent","showErrors":false,"x":1706.5197410583496,"y":431.00401973724365,"wires":[["e7f659ad.f856d8"]]},{"id":"bbf31571.bd4798","type":"change","z":"10110044.30b59","name":"set xSent = false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1342.519832611084,"y":426.00395011901855,"wires":[["e4f13e7.aeee0c"]]},{"id":"7c7aec60.dd4ea4","type":"switch","z":"10110044.30b59","name":"Test xSend = false","property":"payload[0].value","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":870.5195732116699,"y":423.0039119720459,"wires":[["bbf31571.bd4798"]]},{"id":"abdef645.a4af28","type":"debug","z":"10110044.30b59","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1019.8945503234863,"y":638.6757850646973,"wires":[]},{"id":"4b371b6a.c3f7c4","type":"debug","z":"10110044.30b59","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1576.01953125,"y":116.00390815734863,"wires":[]},{"id":"21582029.3743a","type":"OPCUA-IIoT-Connector","z":"","discoveryUrl":"","endpoint":"opc.tcp://127.0.0.1:4840","keepSessionAlive":true,"loginEnabled":false,"securityPolicy":"Basic128Rsa15","securityMode":"SIGNANDENCRYPT","name":"LOCAL SERVER","showErrors":true,"individualCerts":false,"publicCertificateFile":"","privateKeyFile":"","defaultSecureTokenLifetime":"","endpointMustExist":false,"autoSelectRightEndpoint":false,"strategyMaxRetry":"","strategyInitialDelay":"","strategyMaxDelay":"","strategyRandomisationFactor":"","requestedSessionTimeout":"","connectionStartDelay":"","reconnectDelay":"","maxBadSessionRequests":"10"}]

0 Likes