# OPCUA Trigger Node Read multiple OPCUA Tags

**URL:** <https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339>\
**Category:** Help\
**Tags:** workflow, opc-ua\
**Created:** [November 30, 2023, 8:51am UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339 "2023-11-30T08:51:04Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sasikumar\_Rajendran](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sasikumar\_Rajendran](https://forums.losant.com/u/Sasikumar_Rajendran)\
**Post date:** [November 30, 2023, 8:51am UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/1 "2023-11-30T08:51:04Z")

</div>

I am trying to read the below configured OPC UA tags in the work flow using the OPCUA trigger node. When I configure the trigger node as Individual Items, I can get data changes via workflow. If I use the agent conf file, it does not react to any changes.

Also, how multiple tags be added to this trigger configuration?

[[triggers]]  
name = ‘opcuaTrig1’  
type = ‘opcua’  
uri = ‘opc.tcp://10.33.4.83:49320’  
samplingInterval = ‘5’  
eventFilter = [‘Message’, ‘Value’]

# 

[[triggers.monitoredItems]]  
nameSpace = ‘2’  
identifier = ‘s=Line1.Machine2.Global\_IOT.U\_iot\_RunData.Speed’

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/be1e6706f8b6240f57887d463aade9e0f7fcd081.png)

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [November 30, 2023, 3:09pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/2 "2023-11-30T15:09:51Z")

</div>

Hey @Sasikumar_Rajendran,

The first place I recommend looking is the GEA’s log file. If the trigger is failing due to some error, the error should be logged. You can read the logs using the following command on the gateway:

```auto
docker logs CONTAINER_ID

```

Trigger errors will usually be logged shortly after the GEA launches.

Information on that command can be found here:

> **[docker logs](https://docs.docker.com/engine/reference/commandline/logs/)**

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [November 30, 2023, 3:15pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/3 "2023-11-30T15:15:28Z")

</div>

> Also, how multiple tags be added to this trigger configuration?

You can add another `[[triggers.monitoredItems]]` section like so:

```auto
[[triggers]]
name = ‘opcuaTrig1’
type = ‘opcua’
uri = ‘opc.tcp://10.33.4.83:49320’
samplingInterval = ‘5’
eventFilter = [‘Message’, ‘Value’]

[[triggers.monitoredItems]]
nameSpace = ‘2’
identifier = ‘s=Line1.Machine2.Global_IOT.U_iot_RunData.Speed’

[[triggers.monitoredItems]]
nameSpace = ‘2’
identifier = ‘s=My.Other.Identifier’

```

---

<div class="post-metadata">

**Author:** ![Sasikumar\_Rajendran](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sasikumar\_Rajendran](https://forums.losant.com/u/Sasikumar_Rajendran)\
**Post date:** [November 30, 2023, 4:10pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/4 "2023-11-30T16:10:11Z")

</div>

For instance, if I need to get data for 500 tags from OPC, does it require 500 lines to be added to the config file ? Is there a calling function available where the set of 500 tags can be maintained and called to check its status ?

---

<div class="post-metadata">

**Author:** ![Sasikumar\_Rajendran](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sasikumar\_Rajendran](https://forums.losant.com/u/Sasikumar_Rajendran)\
**Post date:** [November 30, 2023, 4:18pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/5 "2023-11-30T16:18:20Z")

</div>

[losant\_log.zip](https://forums.losant.com/uploads/short-url/nvuSel4siVKQzPAB2VVUdZp4fkH.zip) (1.6 KB)  
PFA of logfile

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [December 1, 2023, 3:40pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/6 "2023-12-01T15:40:38Z")

</div>

> For instance, if I need to get data for 500 tags from OPC, does it require 500 lines to be added to the config file ?

Yes, you would need to add a `[[triggers.monitoredItems]]` entry for each identifier you want to monitor.

> Is there a calling function available where the set of 500 tags can be maintained and called to check its status ?

You can use the [Agent Config: Get Node](https://docs.losant.com/workflows/data/agent-config-get/) to view the GEA’s current configuration. Any values that are defined in the TOML file (i.e. not as command line flags or environment variables) can also be changed using the [Agent Config: Set Node](https://docs.losant.com/workflows/data/agent-config-set/). Invoking the node will cause the GEA process to restart with the new config applied.

---

<div class="post-metadata">

**Author:** ![Sasikumar\_Rajendran](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sasikumar\_Rajendran](https://forums.losant.com/u/Sasikumar_Rajendran)\
**Post date:** [March 26, 2024, 1:02pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/7 "2024-03-26T13:02:35Z")

</div>

I am trying to push the OPCUA trigger configuration using Agent Config: Set Node with Payload Path Option. The below image shows a description of the configuration passed via a virtual button. This requires more naming and formatting to be done. Is there any option to configure monitored items without naming or formatting conventions such as triggers.[0].monitoredItems.[0] etc.

Entirely objective is to automate the opcua trigger tag addition process.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/f/fad82577d770b9312f4c30cc884d21bb016cddad.png)

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [March 26, 2024, 3:09pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/8 "2024-03-26T15:09:45Z")

</div>

You can pass the updated configuration in JSON form through a [payload path](https://docs.losant.com/workflows/accessing-payload-data/#payload-paths) or a [JSON template](https://docs.losant.com/workflows/accessing-payload-data/#json-templates). Whatever is handed to the Config: Set Node will [deep-merge](https://ramdajs.com/docs/#mergeDeepRight) with the existing configuration (which is why you must pass a `null` item to delete a trigger config object).

For example, given the following `triggers` configuration retrieved from the Agent Config: Get Node …

```json
{
  "triggers": [
    {
      "opcuaId": "0",
      "uri": "opc.tcp://dylans-mbp.lan:53530/OPCUA/SimulationServer",
      "securityPolicy": "None",
      "securityMode": "None",
      "samplingInterval": "100",
      "eventFilter": [],
      "name": "opcuaSimServer",
      "type": "opcua",
      "monitoredItems": [
        {
          "nameSpace": "3",
          "identifier": "i=1002"
        }
      ]
    },
    {
      "opcuaId": "0",
      "uri": "opc.tcp://dylans-mbp.lan:53530/OPCUA/SimulationServer",
      "securityPolicy": "None",
      "securityMode": "None",
      "samplingInterval": "100",
      "eventFilter": [],
      "name": "opcuaSimServer2",
      "type": "opcua",
      "monitoredItems": [
        {
          "nameSpace": "4",
          "identifier": "i=1005"
        }
      ]
    }
  ]
}

```

… changing the `triggers` property using the Config: Set Node and providing the following value …

```json
{
  "triggers": [
    {}, // no changes to the first config
    {
      "name": "aDifferentName", // change the configName
      "monitoredItems": [
        { "nameSpace": "3" }, // change only the nameSpace of the first monitoredItem
        {"identifier": "i=1002", "nameSpace": "2"} // add another monitoredItem
      ]
    }
  ] 
}

```

… results in the following deep-merged `triggers` value …

```json
{
  "triggers": [
    {
      "opcuaId": "0",
      "uri": "opc.tcp://dylans-mbp.lan:53530/OPCUA/SimulationServer",
      "securityPolicy": "None",
      "securityMode": "None",
      "samplingInterval": "100",
      "eventFilter": [],
      "name": "opcuaSimServer",
      "type": "opcua",
      "monitoredItems": [
        {
          "nameSpace": "3",
          "identifier": "i=1002"
        }
      ]
    },
    {
      "opcuaId": "0",
      "uri": "opc.tcp://dylans-mbp.lan:53530/OPCUA/SimulationServer",
      "securityPolicy": "None",
      "securityMode": "None",
      "samplingInterval": "100",
      "eventFilter": [],
      "name": "aDifferentName",
      "type": "opcua",
      "monitoredItems": [
        {
          "nameSpace": "3",
          "identifier": "i=1005"
        },
        {
          "nameSpace": "2",
          "identifier": "i=1002"
        }
      ]
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![Sasikumar\_Rajendran](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sasikumar\_Rajendran](https://forums.losant.com/u/Sasikumar_Rajendran)\
**Post date:** [March 26, 2024, 4:42pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/9 "2024-03-26T16:42:25Z")

</div>

Thanks for the reply. This example is applicable to changing or replacing multiple triggers. Here, I would only want to make changes to the monitored item tags (add tags or remove tags from the monitored items list), and the rest of the trigger configuration remains the same. Either using a payload path or JSON template.

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [March 26, 2024, 4:48pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/10 "2024-03-26T16:48:19Z")

</div>

The deep-merging I mentioned before would work for that as well; just select the Payload Path option in the Config: Set Node and pass it a path to an object with the changes you want to make. (Or select the JSON Template option and construct the object inline.) The object would look like the example updates from my previous reply.

---

<div class="post-metadata">

**Author:** ![Sasikumar\_Rajendran](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sasikumar\_Rajendran](https://forums.losant.com/u/Sasikumar_Rajendran)\
**Post date:** [March 26, 2024, 6:05pm UTC](https://forums.losant.com/t/opcua-trigger-node-read-multiple-opcua-tags/5339/11 "2024-03-26T18:05:55Z")

</div>

It works. Thanks for the support.
