How can I use the dashboard to write variables in an OPC UA server?

What product/components do you use and which version/fix level?

Cumulocity OPC UA agent (java) 1013.0.125

Are you using a free trial or a product with a customer license?

customer license

What are trying to achieve? Please describe in detail.

We are running the OPC UA agent, it is registered in Cumulocity IoT as device and we have set up a dashboard which displays several values from our OPC UA server. Now we want to write variables in the OPC UA server with the dashboard.

Do you get any error messages? Please provide a full error message screenshot and log file.

We have no glue how to do that. Is there a widget for that which we didn’t know ?
An example would be great !

Have you installed latest fixes for the products

Think so

Hello Benedikt,

writing values to an OPC UA server are possible via operation. As far as i know, there isn’t a standard widget which allows to create opc-ua specific operations. You have to use the REST API: see: OPC UA - Cumulocity IoT Guides

Example: (deviceId == OPC UA Server managed object id)
POST: {{url}}/devicecontrol/operations/

{
  "deviceId" : "2810961",
  "c8y_ua_command_WriteValue": {
    "values": {
        "ns=2;s=MySwitch": {
            "value": "true"
        }
    }
  },
  "description":"Write Value to ns=2;s=MySwitch"
} 

Creating a custom widget would be the right solution, which creates such operation.

Best regards,
Alex

1 Like

Hi Benedikt,

I have a few examples in a Postman Collection attached.

OPCUA.postman_collection.json.zip (3.2 KB)

3 Likes

Please find response inline

Hi Benedikt,

The asset table widget actually allows you to also send operations to assets.
See attached screenshots.


Regards,
Tristan

3 Likes

Hi Tristan,

thank you - and all the others - for your quick answers. It took me very much longer to get used to the operations interface, but now I managed to write variables in the OPC UA server via Postman.

But I cannot configure the asset table widget to display a button:
image

Are there any examples how to create custom widgets ?

Kind regards,

Benedikt

Hi Benedikt,

how have you configured the operation in the asset table? Looks a bit strange to me, that javascript is actually displayed at this point instead of a button.

Best regards
Christian

Hi Christian,
I first added the property “c8y_OpcuaServerId” and then added an action. Incomprehensibly I cannot access the operation again after having created it and cannot check the operation:


To show what I have done I’m adding another action:

Thank you and kind regards,
Benedikt

Hi Benedikt,

I can’t reproduce your issue. On what environment are you running on and which version? Is it *.cumulocity.com or *.eu-latest.cumulocity.com?

About your other question on how to implement a custom widget. You will find information on this in the official documentation. In addition, the Cumulocity Web SDK comes with the application package , which contains the tutorial application. If you create a new application based on the tutorial application template you will find an example for a custom widget.

c8ycli new my-app tutorial

In the directory src/widget a custom widget name demo-widget is defined.

Best regards
Christian

Hi Christian,
I’m using *.cumulocity.com, but do not know the exact version.

Thank you for the information about implementing custom widgets. I’ll work on that.

Kind regards,
Benedikt

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