How to use OPCUA Browser and Template nodes together [SOLVED]

I want to connect to OPCUA server and get the data on the dashboard. For the solution, I am using OPCUA Browser node and the template node.
image
But I don't know how to browse the data.
I am using the following code for template:

<div layout="row" layout-align="space-between">
	<select ng-model="item" ng-options="items.item.displayName.text for items in msg.payload">
		<option value="">-- Objects Root --</option>
	</select>
	<button ng-click="send({payload: {actiontype: 'browse', root: item}})"> Browse </button>
</div>

<div layout="row" layout-align="space-between">
    <ul> <li ng-repeat="items in msg.payload"> {{items.item.displayName.text}}: {{items.item.nodeId}} </li>
    </ul>
</div>

When I deploy it, my node-red server connection gets lost and I get this error message:

  • [warn] [OpcUa-Browser:72907975.5a3ce8] input browser
  • [info] [OpcUa-Browser:72907975.5a3ce8] start browse client on opc.tcp://10.61.145.44:4050

Then I have to delete the backup flow nad then restart node-red in order to run it again. I need some help regarding this. Thanks.

Solved. I found the solution.

Can you please post a copy of your work? I'm sure others could use it.

I have used the example of mikakaraila available on github as node-red-contrib-opcua library. The example flow code is:

[{"id":"a24729d8.6e3338","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a5c3b771.b035f","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false},{"id":"57e89fdc.43d9e","type":"ui_group","z":"","name":"Default","tab":"a5c3b771.b035f","disp":true,"width":"6","collapse":false},{"id":"30bfcadd.1595b6","type":"OpcUa-Endpoint","z":"","endpoint":"opc.tcp://TREL16087112.vstage.co:53530/OPCUA/SimulationServer","secpol":"None","secmode":"NONE","login":false},{"id":"9a453441.d77cc","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"715ed404.79906c","type":"ui_template","z":"a24729d8.6e3338","group":"57e89fdc.43d9e","name":"Browse","order":0,"width":"6","height":"11","format":"<div layout=\"row\" layout-align=\"space-between\">\n    <select ng-model=\"item\" ng-options=\"items.item.displayName.text for items in msg.payload\">\n        <option value=\"\">-- Objects Root --</option>\n    </select>\n    <button ng-click=\"send({payload: {actiontype: 'browse', root: item}})\">\n        Browse\n    </button>\n</div>\n<div layout=\"row\" layout-align=\"space-between\">\n    <ul>\n        <li ng-repeat=\"items in msg.payload\">\n          {{items.item.displayName.text}}: {{items.item.nodeId}}\n        </li>\n    </ul>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":250.49998474121094,"y":81.80000305175781,"wires":[["3da8dc2e.9c9f3c","1a39131f.0bb62d"]]},{"id":"3da8dc2e.9c9f3c","type":"ui_toast","z":"a24729d8.6e3338","position":"top right","displayTime":"2","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"Browsing...","name":"Action","x":471.49998474121094,"y":82.59999084472656,"wires":[]},{"id":"1a39131f.0bb62d","type":"OpcUa-Browser","z":"a24729d8.6e3338","endpoint":"30bfcadd.1595b6","item":"","datatype":"","topic":"ns=0;s=85/0:Simulation","items":[],"x":250.9000244140625,"y":187.40000915527344,"wires":[["715ed404.79906c"]]}]

Just change the endpoint address and everything will work fine.

The mistake which I was doing is a small mistake but that will make your life much harder.

image

Never check this option. If you check it then it will pass the input which results in crashing and stopping your server because there will no input for browser node thus the template node.

1 Like

hey, i have one more question please, how can I use this template to browse with OPC UA Client not OPC UA Browser. thanke you in advance.

The template is just a node that uses HTML formatting. I don't think we need a Template node with the OPC UA client since the OPCUA client is built to connect to the server and get you the payload.
According to my understanding, if you need some custom modification then you should do it in the OPC UA Browser node.

@khadija could you start a new thread an include details of your issue. Link back to this thread if it helps.

Closing this 2y old thread.