Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How-to rename object on running opc ua server? #1766

Open
PetroGolovnya opened this issue Dec 23, 2024 · 2 comments
Open

How-to rename object on running opc ua server? #1766

PetroGolovnya opened this issue Dec 23, 2024 · 2 comments

Comments

@PetroGolovnya
Copy link

PetroGolovnya commented Dec 23, 2024

Describe the bug

I trying to rename object on running opc ua server.
From old DisplayName is 'SNMP' to new DisplayName is 'SNMP changed'.
But object name in tree not changed.
Code received new name from redis subscription.

To Reproduce

Here is code example:
`async def object_changed(jval):
org_id = jval["args"]["id"]
query = "SELECT po.id_p, po.address, p.name FROM page_object AS po LEFT JOIN page AS p ON "
query += f"p.id_p=po.id_p WHERE po.id_p={org_id}"
org, = await db.select(query, f"Database error on object {org_id}:")
node_ = server.get_node(ua.NodeId(org_id, 1))
display_name = await node_.read_display_name()

if org["name"] != display_name.Text:       
    now = datetime.datetime.now()
    await node_.write_attribute(ua.AttributeIds.DisplayName, \
        ua.DataValue(ua.uatypes.LocalizedText(org["name"].replace(':', ' ')), \
        ua.StatusCode(0), now.replace(tzinfo=tz_local).astimezone(tz_utc)))        
    await node_.write_attribute(ua.AttributeIds.BrowseName, \
        ua.DataValue(ua.uatypes.QualifiedName(org["name"].replace(':', ' ')), \
        ua.StatusCode(0), now.replace(tzinfo=tz_local).astimezone(tz_utc))) 
    await node_.write_attribute(ua.AttributeIds.Description, \
        ua.DataValue(ua.uatypes.LocalizedText(org["name"].replace(':', ' ')), \
        ua.StatusCode(0), now.replace(tzinfo=tz_local).astimezone(tz_utc)))`

Screenshots

Screenshot attached
snmp_plc

Version

Python-Version: 3.11.2 x64

opcua-asyncio Version (e.g. master branch, 0.9): asyncua-1.1.5

@AndreasHeine
Copy link
Member

why do you think its an issue of asyncua? in the attributes tab it shows the current value so from library side its working!
its more likely an issue in the client software not refreshing!
maybe close and reopen the parent folder/object so it will rebrowse/reread?

@aldoshkind
Copy link

aldoshkind commented Jan 11, 2025

Hello, @AndreasHeine !
I have exactly same problem as @PetroGolovnya . The node name rendered in tree view is incorrect (old) even after client software restart.
The client software on the picture above is Prosys OPC UA Browser. I use it as well.
It seems that for tree rendering Prosys uses Browse/Display name aquired via ReferenceDescription. Possibly asyncua does not update Browse/Display name stored in node references or does it incorrectly. You can check this by printing refernce in ViewService._browse after node's Browse name has been updated here:

res.References.append(ref)

Please consider reviewing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants