import typing import opcua def get_value(hmi_opcua: opcua.Client, tag: str) -> typing.Any: root = hmi_opcua.get_root_node() for child in root.get_child(["0:Objects", "1:HmiRuntime", "1:HMI_RT_4", "1:Tags"]).get_children(): name = child.get_browse_name().Name.split("::")[1] if name == tag: return child.get_value() raise ValueError(f"Could not find {tag}") # simulated MTP700 with activated OPCUA client = opcua.Client("opc.tcp://127.0.0.1:4949") client.session_timeout = 600000 client.connect() print("Tag in position:", get_value(client, "Tag_in_pos")) client.disconnect()