OPC UA [Custom Component]

Evening,

After search and waiting I decided to try my hand can creating a custom component to integrate opcua data into home assistant.

My repository can be found below and was heavily influenced by the modbus component.

minix1234/hacore_opcua: opcua custom component for home assistant (github.com)

It is poll based and currently only supports the specification of sensors. It does however publish a service to write data back to opcua nodeids.

My initial testing included several self-hosted opcua servers under various authentication schemes and it has proven stable.

Feel free to try it out and provide feedback or submit PRs to extend the functionality.

happy automating and stay safe

2 Likes

public service announcement:

we found an instance where a refused socket connection can cause HA loading issues.

we are working to track down the root cause of the error and fix it.

Hi
Are you still active on this topic ?
I am very interested as i have a PLC (and OPCUA)
Regards

morning,

it still works. there are some optimizations that need to happen to improve the reconnection process.

it’s also sync vs async, but that would need a total rewrite.

what kind of PLC?

I’m trying to use the library and have uploaded the filed to custom_components. I was not able to use HACS for some reason…

Should the section to specify the server be added in configurations.yaml?

‘’’
opcua:

  • name: target1
    url: “opc.tcp://172.17.0.2:4840/”
    application_uri: “urn:example.org:FreeOpcUa:python-opcua”
    session_timeout: 600000
    secure_timeout: 600000
    security_string: “Basic256Sha256,SignAndEncrypt,/ssl/certificate-example.der,/ssl/private-key-example.pem”
    ‘’’

evening,

that is correct. the configurations for both the server and points need to be added to the configuration yaml file

the options specified will depend on the setup. usually you will need a certificate to allow for the OPC UA encryption methods to work.

here is an example where I can connect to a Prosys OPC UA simulation server.

please note, I ‘borrowed’ the client certificates from the FreeOPCUA python files here.

opcua:
  - name: prosys
    url: "opc.tcp://192.168.50.244:53530/OPCUA/SimulationServer"
    session_timeout: 600000
    secure_timeout: 600000
    username: "prosys"
    password: "prosys"    
    #application_uri: "urn:example.org:FreeOpcUa:python-opcua"
    #security_string: "Basic256Sha256,SignAndEncrypt,/ssl/certificate-example.der,/ssl/private-key-example.pem"