OPC UA Interface to HA

thank you,

I’ll add you this too the docs. I’ll also try to fix up that critical error.

are you writing back to the device at all?

Not yet but I will try it quickly

10-4.

I created a service to allow for writing to nodeid’s. I have been using it in automations. here is an example.

I also provided an update on github, to try and catch the error before it crashes HA.

would it be too much to ask to update your custom component and trying to connect again to your WAGO without the username/password. my HA wont crash on the socket error so it is hard for me to test this particular issue.

Thank you,
With this update HA don’t crash, even without the username/password.

Hello minimix1234,

I have also a problem to write to a node on my WAGO PLC.
I created automation script like your example and I have the following message in the log

Error: “The server does not support writing the combination of value, status and timestamps provided.”(BadWriteNotSupported) encountered when attempting to write a value of: 5448123 to nodeid: ns=4;s=|var|WAGO 750-8101 PFC100 2ETH.Application.GVL.OPCUA_WritedVar

I have no problem with other OPC_UA client (like UAExpert)

interesting. let me look at the base FreeOpcUA client code. it may be inherently writing timestamps and status (like opc v1/2/3)

I’m glad I cleaned up the error reporting. that should make it easier to track.

what are this nodeid properties? like when viewed on uaexpert

I think I’m on to something.

there is a helper utility in the freeopcua code that converts python data types to UA datavalues.

It appears that anything that is not a UA DataValue already has the timestamp added to it.

I will need to think about how to get around this one.

def value_to_datavalue(val, varianttype=None):
    """
    convert anyting to a DataValue using varianttype
    """
    datavalue = None
    if isinstance(val, ua.DataValue):
        datavalue = val
    elif isinstance(val, ua.Variant):
        datavalue = ua.DataValue(val)
        datavalue.SourceTimestamp = datetime.utcnow()
    else:
        datavalue = ua.DataValue(ua.Variant(val, varianttype))
        datavalue.SourceTimestamp = datetime.utcnow()
    return datavalue

Ok,

It looks to be an issue with the client code from freeopcua. Somehow the freeopcua client node.set_value() code generated these errors. The proposed fix was to utilize node.set_attribute() code instead.

I created a tandem service opcua.set_attribute which can be utilized exactly like opcua.set_value. please update and give it a try.

I also found that in an attempt to mitigate a potential sensor unique_id naming collision i introduced a bug that would generate stale entries on HA restarts. I have reverted that change and it is working fine.