Quick Start Guide for OPC and KeserverEX

This Flow will coincide with a blog on how to get started with connecting Node-RED to KeserverEX with Security Policies, Sign and Encrypt.

Dependencies

https://flows.nodered.org/node/node-red-contrib-opcua

[{"id":"4ce867cf99f83967","type":"group","z":"1e5a89d7e25de505","name":"Quick Start Guide to OPC","style":{"label":true},"nodes":["1cbc398e79846cde","22a9a25a3328defe","ac721b9ee6029c4a","f8e835895bdb8c1f","2ff48ed1a7f05e30","45dc76db6975c6d5","0a3d290d39b372f7","b06860496056652f","93cd856f17717533","97a7efc3363486a6","1d3c76e4c6aab9fa","0e1cbba094b40f03"],"x":34,"y":19,"w":752,"h":202},{"id":"1cbc398e79846cde","type":"inject","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"ns=0;i=84","payload":"","payloadType":"date","x":170,"y":60,"wires":[["ac721b9ee6029c4a"]]},{"id":"22a9a25a3328defe","type":"debug","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","name":"debug 16","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":60,"wires":[]},{"id":"ac721b9ee6029c4a","type":"OpcUa-Client","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","endpoint":"","action":"browse","deadbandtype":"a","deadbandvalue":1,"time":10,"timeUnit":"s","certificate":"n","localfile":"","localkeyfile":"","securitymode":"None","securitypolicy":"None","useTransport":false,"maxChunkCount":1,"maxMessageSize":8192,"receiveBufferSize":8192,"sendBufferSize":8192,"name":"","x":360,"y":60,"wires":[["f8e835895bdb8c1f"],[]]},{"id":"f8e835895bdb8c1f","type":"function","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","name":"regex","func":"// Extract the part after \"s=\" using regex\nconst regex = /;s=(.*)/;\nconst match = msg.topic.match(regex);\n\nif (match && match[1]) {\n    // Get the matched group, which is the part after \"s=\"\n    const extractedString = match[1];\n\n    // Retrieve the existing array from the context store, or initialize it if it doesn't exist\n    let myArray = flow.get(\"myArray\") || [];\n\n    // Add the extracted string to the array\n    myArray.push(extractedString);\n\n    // Save the updated array back to the context store\n    flow.set(\"myArray\", myArray);\n\n    // Optionally, you can pass the updated array in the message payload for further use\n    msg.payload = myArray;\n} else {\n    // Handle the case where the regex does not match\n    // node.warn(\"The payload does not contain the expected pattern.\");\n}\n\n// Return the message to continue the flow\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":60,"wires":[["22a9a25a3328defe"]]},{"id":"2ff48ed1a7f05e30","type":"inject","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","name":"Read","repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"str","x":130,"y":120,"wires":[["45dc76db6975c6d5"]]},{"id":"45dc76db6975c6d5","type":"OpcUa-Item","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","item":"ns=2;s=Simulation Examples.Functions.Ramp1","datatype":"Int32","value":"","name":"Read","x":270,"y":120,"wires":[["0a3d290d39b372f7"]]},{"id":"0a3d290d39b372f7","type":"OpcUa-Client","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","endpoint":"","action":"read","deadbandvalue":"","time":"","certificate":"n","localfile":"","localkeyfile":"","useTransport":false,"maxChunkCount":"1","maxMessageSize":"8192","receiveBufferSize":"8192","sendBufferSize":"8192","name":"","x":420,"y":120,"wires":[["b06860496056652f"],[]]},{"id":"b06860496056652f","type":"debug","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","name":"Read value","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":120,"wires":[]},{"id":"93cd856f17717533","type":"inject","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","name":"Write","repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"str","x":130,"y":180,"wires":[["97a7efc3363486a6"]]},{"id":"97a7efc3363486a6","type":"OpcUa-Item","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","item":"ns=2;s=Simulation Examples.Functions.myInt","datatype":"Int32","value":"8","name":"Write","x":270,"y":180,"wires":[["1d3c76e4c6aab9fa"]]},{"id":"1d3c76e4c6aab9fa","type":"OpcUa-Client","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","endpoint":"","action":"write","deadbandvalue":"","time":"","localfile":"","localkeyfile":"","useTransport":false,"maxChunkCount":"","maxMessageSize":"","receiveBufferSize":"","sendBufferSize":"","name":"","x":420,"y":180,"wires":[["0e1cbba094b40f03"],[]]},{"id":"0e1cbba094b40f03","type":"debug","z":"1e5a89d7e25de505","g":"4ce867cf99f83967","name":"Write value","active":true,"console":"false","complete":"true","x":610,"y":180,"wires":[]}]

Flow Info

Created 10 months, 1 week ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x3)
  • function (x1)
  • inject (x3)
Other
  • OpcUa-Client (x3)
  • OpcUa-Item (x2)
  • group (x1)

Tags

  • kepware
  • kepserver
  • flowfuse
  • opc
  • opcua
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option