noc
February 25, 2025, 2:39am
1
I have a python script that uses opcua-asyncio. Client authentication is successful. The client code can be found here:
import asyncio
import logging
import socket
import dataclasses
from cryptography import x509
from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Type, Union, cast, Callable, Coroutine
from urllib.parse import urlparse, unquote, ParseResult
from pathlib import Path
import asyncua
from asyncua import ua
from .ua_client import UaClient
from ..common.xmlimporter import XmlImporter
from ..common.xmlexporter import XmlExporter
from ..common.node import Node
from ..common.manage_nodes import delete_nodes
from ..common.subscription import Subscription, SubscriptionHandler
from ..common.shortcuts import Shortcuts
from ..common.structures import load_type_definitions, load_enums
This file has been truncated. show original
I can successfully get data for these methods that don’t require arguments.
get_root_node
get_objects_node
get_server_node
Which return these respective values:
i=84
i=85
i=2253
This validates that the script works.
The difficulty I’m facing is in correctly identifying tags to get their reported values.
I have used the Ignition designer to copy the path to any tag value of choice for example "[default]The/Full/Tag Path/Including Spaces/Output.value"
When I use the get_node method where the nodeID is "ns=1;s=[default]The/Full/Tag Path/Including Spaces/Output.value"
I get this error "ERROR:asyncua:The node id refers to a node that does not exist in the server address space.(BadNodeIdUnknown)"
The server is configured to "Expose Tag Providers".
The same error occurs whether I use a "ns" name space value of 1, 2, 3 etc.
What is the correct format for the tag path I should be using?
Is the NodeID string formatted correctly?
To verify that the server is configured correctly, use the OPC quick client in the gateway config webpage, are you able to browse the desired tags there?
If so, you might have good luck copying the path (nsu=…) as displayed after attempting a [r]ead on a specific tag.
Exposed Tags are always in namespace index 2.
Have you restarted since enabling Exposed Tags? Have you tried a third party client like UaExpert to see what the NodeIds look like?
This worked for me:
foo = await client.get_node("ns=2;s=[default]/Foo").get_value()
bar = await client.get_node("ns=2;s=[default]/Folder/Bar").get_value()
print(f"foo value: {foo}")
print(f"bar value: {bar}")
1 Like