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

Unable to change variable value to True #1530

Open
Zouzou1988 opened this issue Oct 31, 2023 · 12 comments
Open

Unable to change variable value to True #1530

Zouzou1988 opened this issue Oct 31, 2023 · 12 comments

Comments

@Zouzou1988
Copy link

Hello Dears,
I can read data from a server (opc ua device) without any problem. However, i can't write any variables.
Here is my code:

    def set_opcua_data():
        try:
            node = client.get_node("ns=3; i=16847616")
            node.set_value(True)
        except Exception as er:
            print(f"*** Failure: {str(er)}")

Here is the error:

*** Failure: "The server does not support writing the combination of value, status and timestamps provided."(BadWriteNotSupported)

When i use Ua expert, i can read and write to the server!

Your help please :)

@schroeder-
Copy link
Contributor

some server doesn't allow setting the timestamp. you need to set it via DataValue.

datavalue = ua.DataValue(ua.Variant(True, ua.VariantType.Boolean))
node.set_value(datavalue)

@Zouzou1988
Copy link
Author

Same issue with your code:

            node = client.get_node("ns=3; i=16847616")
            data_value = ua.DataValue(ua.Variant(True, ua.VariantType.Boolean))
            node.set_value(data_value)

Error: "The server does not support writing the combination of value, status and timestamps provided."(BadWriteNotSupported)

@schroeder-
Copy link
Contributor

Try this:

node.set_attribute(ua.AttributeIds.Value, ua.DataValue(True))

@Zouzou1988
Copy link
Author

same error. sorry

@schroeder-
Copy link
Contributor

Are you sure you can write that value? Dod you try it via ua expert?

@Zouzou1988
Copy link
Author

it works using uaexpert.

@Zouzou1988
Copy link
Author

Capture

@AndreasHeine
Copy link
Member

why is there a blank after ; in the nodeid?

@Zouzou1988
Copy link
Author

why is there a blank after ; in the nodeid?

Do you mean « , »in the description of nodeid on UA expert ? I don’t know

@oroulet
Copy link
Member

oroulet commented Nov 1, 2023

datavalue = ua.DataValue(ua.Variant(True, ua.VariantType.Boolean))
datavalue.SouceTimestamp = None
datavalaue.ServerTimestamp = None
node.set_value(datavalue)
``

@Zouzou1988
Copy link
Author

datavalue = ua.DataValue(ua.Variant(True, ua.VariantType.Boolean))
datavalue.SouceTimestamp = None
datavalaue.ServerTimestamp = None
node.set_value(datavalue)
``

*** Failure: "The server does not support writing the combination of value, status and timestamps provided."(BadWriteNotSupported)

@oroulet
Copy link
Member

oroulet commented Nov 1, 2023

Try to remove status or add one of the timestamp. That is what the server says is the issue but does not tell us what it wants

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

4 participants