Python

Attached the step by step description to access the OPC UA values. The script below can be used to run a first trial.

Install IDE

Since you decided to use python as your programming language I expect you already having an IDE on your machine. If not I would recommend you to install pycharm or Anaconda.

Tip: If you have little experience with python I strongly recommend you the tutorials of this guy.

Open IDE and install needed libraries

I’m continuing with pycharm since it is the environment I use. First we open the pycharm environment. Now we install the needed libraries. To install the one you need, you have to got to File-> Settings-> Project:(Your project)-> Project Interpreter-> + There you choose “opcua” and “cryptography” and install both.

Tip: Libraries in python are like additional function packages you can use. The best of it is most of them are free even the ML libraries of Google.

Copy python file

The python file is a separate project you find here.

Check credentials

You have to check certain things to ensure the proper connection. If you only want to try the connection you are good to go with the credentials below. If you want to read or write specific values please contact the ehub team.

from opcuaclient_subscription import opcua
from opcuaclient_subscription import toggle
import pandas as pd
import logging
import time

# Configuration logging
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.WARNING)
logger = logging.getLogger('opc ua client')

if __name__ == "__main__":
    client = opcua(user='user', password='passowrd')
    if client.connect():
        client.subscribe(df_Read= pd.DataFrame({'node': [       "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bAnlageEin",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bQuittierung",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bReqResearch",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bWdResearch",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.rSollWirkleistung"
                                                                  ]}))

        while True:
            client.publish(df_Write=pd.DataFrame({  'node': [   "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bAnlageEin",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bQuittierung",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bReqResearch",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.bWdResearch",
                                                                "ns=2;s=Gateway.PLC1.65LK-06420-D001.PLC1.Batan.strWrite_L.strBatterienanlage.rSollWirkleistung"
                                                                    ],

                                                    'value': [  True,
                                                                False,
                                                                True,
                                                                toggle(),
                                                                2
                                                                    ]}))
            time.sleep(0.100)



    client.disconnect()

Issues