Azure / Industrial-IoT

Azure Industrial IoT Platform
MIT License
524 stars 214 forks source link

Issue configuring what nodes to publish #1221

Closed ericvruder closed 1 year ago

ericvruder commented 3 years ago

I have recently set up a IoT Edge up in one of our machines and installed OPC Publisher and connected it to one of our opc-ua servers. I got it publishing the nodes correctly and routing them to the iot hub, so that's awesome. Though I have now run into the following problem:

This is how our node structure looks like atm. (anonymized):

Node Structure

And we asked OPC Publisher to publish the OPC-UA_COMM.OUT Node. The Publish node config looks something like this:

[
    {
        "EndpointUrl": "{opcuaConnectionString}",
        ...
        "OpcNodes": [
            {
                "Id": "ns=3;s=\"OPC-UA_COMM\".\"OUT\"",
                "DisplayName": "OUT Message",
                "SkipFirst": false
            }
        ]
    }
]

Problem is though, the temperature value is incredibly noisy and not relevant at the moment. I would like to be able to filter it away, so that I don't get a node published every time that value changes.

I have read the documentation, and it seems like it is possible to configure content of the json message that is sent. It seems like it is possible to filter away specific values, although I have not succeeded in that yet. I created the following config file:


{
    "Defaults": {
        "EndpointUrl": {
            "Publish": true,
            "Pattern": "(.*)",
            "Name": "EndpointUrl"
        },
        "NodeId": {
            "Publish": true,
            "Name": "NodeId"
        },
        "MonitoredItem": {
            "Flat": true,
            "ApplicationUri": {
                "Publish": true,
                "Name": "ApplicationUri"
            },
            "DisplayName": {
                "Publish": true,
                "Name": "DisplayName"
            }
        },
        "Value": {              
            "SourceTimestamp": {
                "Publish": true,
                "Name": "SourceTimestamp"
            },
            "StatusCode": {
                "Publish": false,
                "Name": "StatusCode"
            },
            "Status": {
                "Publish": false,
                "Name": "Status"
            },
            "Value:": {  
                "Temperature": {
                    "Publish": false,
                    "Name": "Temperature"
                },
                "DoorsOpen": {
                    "Publish": true,
                    "Name": "DoorsOpen"
                }
            }
        }
    }
}

I added it to the container, verified the file was there, and made sure that the publisher module was started with the correct settings. This is how the container create options look like:

{
  "Hostname": "publisher",
  "Cmd": [
    "OPCPublisher",
    "--tc=/appdata/nodeConfiguration.json",
    "--pf=/appdata/opcPublisher.json",
    "--tp=/appdata/pki/trusted",
    "--rp=/appdata/pki/rejected",
    "--ap=/appdata/pki/own",
    "--ip=/appdata/pki/issuer",
    "--aa",
    "--to",
    "--di=600"
  ],
  "HostConfig": {
    "Binds": [
      "/etc/iotedge/storage/publisher:/appdata"
    ]
  }
}

But still, it is being published! I would really appreciate some help.

I also understand that I could break it up into multiple different publishes. I have tried something like this:

[
    {
        "EndpointUrl": "{opcuaConnectionString}",
        ...
        "OpcNodes": [
            {
                "Id": "ns=3;s=\"OPC-UA_COMM\".\"OUT\".\"DoorsOpen\"",
                "DisplayName": "Doors open",
                "SkipFirst": false
            },
            {
                "Id": "ns=3;s=\"OPC-UA_COMM\".\"OUT\".\"Speed\"",
                "DisplayName": "Speed",
                "SkipFirst": false
            },
            {
                "Id": "ns=3;s=\"OPC-UA_COMM\".\"OUT\".\"Weight\"",
                "DisplayName": "Weight",
                "SkipFirst": false
            }
            ...
        ]
    }
]

And it works! I can control which sub values arrive. But they each come separately, and I would much rather have it all come together in one node.

marcschier commented 1 year ago

Please use OPC UA PubSub modes to publish datasets instead of single values. Regarding message transformation, we have removed this feature and recommend using ASA or a custom module for filtering instead.