Hi, I’m trying to read one of the analog inputs from my PLC
Does anyone what to put into the config-file to be able to read the “AI” inputs?
anything that will help me will be much appreciated.
Hi, I’m trying to read one of the analog inputs from my PLC
Does anyone what to put into the config-file to be able to read the “AI” inputs?
anything that will help me will be much appreciated.
Hello @fesklord,
I have a LOGO where input registers are temperatures, they are short integer so if I read 321 it means 32.1°C.
I divide my configuration.yaml so I have to edit 3 files:
configuration.yaml:
modbus: !include modbus.yaml
template: !include templates.yaml
modbus.yaml (please note the host
is your LOGO IP address, I store mine in the secrets.yaml file):
- name: "Siemens LOGO"
type: tcp
host: !sercret siemens_logo_ip
port: 502
sensors:
- name: "MyLOGO1"
unique_id: mylogo1
input_type: input
slave: 1
address: 0
count: 8
data_type: custom
structure: ">8h"
Note: structure:">8h"
means I have reading 8 short number of 2 bytes each with big endian ending. You can read about Python structure here.
As I read all 8 input registers at once and then use a template to separate the values, then I have less modbus requests made to the LOGO. So I divide the values in templates.yaml:
- name: Heater temperature
state: "{{ states('sensor.mylogo1').split(',')[0] | multiply(0.1) }}"
state_class: measurement
unit_of_measurement: °C
- name: External temperature
state: "{{ states('sensor.mylogo1').split(',')[1] | multiply(0.1) }}"
state_class: measurement
unit_of_measurement: °C
# and so on until states('sensor.mylogo1').split(',')[7]
I hope that helps and do not hesitate to reach out if you have any question.