Hello,
In the meantime, I have done some further research and trials.
As a reminder : I run HA on a QNAP NAS TS-453D, under a docker container.The PLC is a CX-8190 running Windows Embedded 7. I use Twincat 3.
My configuration.yaml file currently looks like this…
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
# Example configuration.yaml entry
ads:
device: 'x.x.x.x.1.1'
port: 851
ip_address: 192.168.xx.xx
# Example configuration.yaml entry
switch:
- platform: ads
adsvar: GBL.MAIN.dkZITR_3_6
name: 'Drukknop'
# Example configuration.yaml entry
sensor:
- platform: ads
adsvar: 'GBL.H3C.HomeAutomation.Constants.LED_DIM_MIN'
unit_of_measurement: 'Level'
adstype: uint
name: 'DimLevel'
The ‘device’ tag is set to the ams-id that can be found in the Twincat programming environment, as is the IP address, which is fixed by the way. The PLC port is set to ‘851’ by default (so not ‘801’).
I also found out that HA needs pyADS installed in order to be able to communicate with a plc. I opened a console terminal and launched the command ‘pip install pyads’ which returned a message that the package was already installed. Great (I think)!
The HA user interface starts without reporting any visible error. The entities that are defined in the configuration file appear in the entities list, but with the indication ‘unavailable’. So, I guess no communication is established with the PLC, or the adsvar names are not formatted as it should, or I am trying to address variables that are not reachable by ADS.
I also logged in to the PLC via my PC and opened the ‘static routes’ dialog. I let the PLC do a search for ADS compliant devices on my network. It only found the PC from which I am developing. Does this mean that the HA instance on QNAP is not responding to ADS traffic? Or is this normal? Is pyADS service running, even if it is installed on HA? Can I check this in some way?
Some questions concerning the adsvar parameter :
-
Is the prefix for TwinCAT3 ‘GBL’ or ‘GVL’?
-
Do yo need to specify the whole variable path or just the variable name?
-
Can you reach any variable defined in the PLC or do you need to define variables in a special way in the PLC environment in order to be exposed to ADS?
-
Sometimes string type variable are surrounded by quotes and sometimes not (e.g. device parameter is specified between quotes, adsvar typically not (in my configuration file, I tried both as a test by the way)
Can anyone elaborate on this and point me in the right direction please?