out of curiosity (wanting understand OPC UA a little better), I started building a small bridge to expose HA contents via OPC UA. I used a Python OPC UA implementation (https://github.com/FreeOpcUa/python-opcua) and am finally able to browse nodes and their current state via a OPC UA client, see the screenshot.
My initial status could probably be enhanced to allow interaction with HA (e.g. propagating values written to OPC UA nodes), expose events when entity values change or expose services as OPC UA methods.
However, beyond the feasibility of all this, I have no real application in mind so far. Any ideas where this might be useful ?
Regards,
Lars
P.S. For the curious, I have uploaded my current attempt to https://github.com/LarsAC/ha2ua if you want to take a look. The code is not really polished, so beware.
Will add more documentation how to make it work over the next couple of days. Roughly you need a venv with the hass python bindings and the free OPC UA stuff mentioned in my first post.
Interested if there was any progress creating a OPCUA add-on for HassIO?
I would like to do some monitoring and control of a swimming pool using a B&R PLC for local control and use OPCUA to communicate with the HA system. I have several spare PLC’s to use and OPCUA can be easily enabled in the PLC, we have tested the communication using a POC running Python and have that working (IOT project for work).
I’m very interested too in the progress or is there a different integration for OPC-UA? I too am looking to expose the home assistant sensors to a B&R PLC…
cool minix1234, looking forward to a opcua HA component.
In past I used FHEM which had a modbus slave component so you could “map” FHEM’s sensors to modbus registers (read/write) so I could make a HMI on an industrial SCADA system.
If there was a OPCUA component which could “map” HA tags/sensors/input_…" with read/write access, this would be a great solution also to link as HMI.
that I believe would be closer to the OPs original intent.
I’m looking to gather some data for logging, graphing and programmatic other uses from several systems.
I will create a GitHub repo soon. just reviewing the sync vs async component setup requirements.
I based the component off of the modbus component and they are using thread locks while I have not. I just want to make sure it won’t cause stability issues.
(I program for fun and as required for work/ work around but it is not my formal training)
I guess you need to install opcua with : pip install opcua ?
If I do that on my Hassio Home Assistant I get :
➜ ~ pip install opcua
Collecting opcua
Using cached opcua-0.98.12.tar.gz (571 kB)
Requirement already satisfied: python-dateutil in /usr/lib/python3.8/site-packages (from opcua) (2.8.1)
Requirement already satisfied: pytz in /usr/lib/python3.8/site-packages (from opcua) (2020.4)
Collecting lxml
Using cached lxml-4.6.2.tar.gz (3.2 MB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-lwedsz99/lxml/setup.py’"’"’; file=’"’"’/tmp/pip-install-lwedsz99/lxml/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ egg_info --egg-base /tmp/pip-pip-egg-info-zlixhpse
cwd: /tmp/pip-install-lwedsz99/lxml/
Complete output (3 lines):
Building lxml version 4.6.2.
Building without Cython.
Error: Please make sure the libxml2 and libxslt development packages are installed.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I can’t seem to install lxml ?
I now remember back why I did not tried https://github.com/LarsAC/ha2ua any further.
It didn’t work on Home Assistant’s shell/Linux. (direct install on Home Assistant OS installation Type)
I went on using NodeRed instead where NodeRed would be a simulated Modbus Slave with Modbusregisters filled with data from HA.
Does anyone have a step-by-step solution how to install opcua ( https://github.com/FreeOpcUa/python-opcua) succesfully on HA ? Or does your opcua addon does not require this ?
I think it installs HASSOS (own HA OS), maybe this Linux can not be expanded ? (aside from the HA shared Config folder) ?
I cannot manually install libxml2-devel :
➜ ~ sudo pip install libxml2-devel or libxslt-dev
ERROR: Could not find a version that satisfies the requirement libxml2-devel (from versions: none)
ERROR: No matching distribution found for libxml2-devel
or is there a different way of installing these ? (apt-get install does not work also).
Maybe it’s possible to install an extra docker container of your software ? I installed Portainer also on this HASOSS. Some HA Addons also install docker containers.
It is installed on Proxmox, I don’t have the same view as you.
Only have 1 running container.
All addons & homeassistant parts are “images” which have a state “Unused” which is not true.
I’ll try your approach of running install opcua in homeassistant container