In my opinion, all parameters from the Home Assistant Modbus documentation are entered correctly, and the connection type is also TCP.
Then why do I get an error message when checking the yaml file like this:
Configuration warnings
Invalid config for ‘modbus’ at configuration.yaml, line 20: required key ‘baudrate’ not provided
Invalid config for ‘modbus’ at configuration.yaml, line 20: required key ‘bytesize’ not provided
Invalid config for ‘modbus’ at configuration.yaml, line 20: required key ‘method’ not provided
Invalid config for ‘modbus’ at configuration.yaml, line 20: required key ‘parity’ not provided
Invalid config for ‘modbus’ at configuration.yaml, line 20: required key ‘port’ not provided
Invalid config for ‘modbus’ at configuration.yaml, line 20: required key ‘stopbits’ not provided
Invalid config for ‘modbus’ at configuration.yaml, line 20: required key ‘type’ Not provided
In my opinion, these parameters are only necessary for serial connections.
Modbus is a serial bus protocol with after the data is collected it is in your case transported over tcp.
There is also modbus-tcp.
I assume you are using esphome for this because you didn’t provided enough info. Did you use the right component in Esphome. I am not aware if there is a modbus tcp platform available
Thank you for your fast answer.
no I’m nor using esphome. My host is a Sungrow-PV-inverter.
This device has an IP interface over which the Modbus protocol is transmitted via TCP.
Flawless communication is possible using other software, such as pymodbus or ModbusMaster, provided the TCP, IP address, and port are configured.
not tested since no sungrow but it should read something like that
modbus:
- type: tcp # <== type: not typ:
host: xxx.xxx.xxx.xxx # <== the inverter's IP
port: 502 # <== modbus uses port 502 not 5002 or *1)
name: "myInverter" # <== or sungrow or whatever you like
sensors:
- name: inverter_serial
unique_id: inverter_serial
slave: 1 # <== the number you likely added at line device_address?
address: 5002 # <== this is the modbus address you read from
data_type: unit16
scan_interval: 30
*1) it could be 5002 if you configured this in your inverter but I doubt since that’s very uncommon one does it like that. Normally one uses the standard port numbers.
And watch the indents your looked a bit fancy … YAML doesn’t forgive wrong indentation but simply fails.
EDIT: and the error asking for baudrate and such resulted from the line where you used “typ:” but “type:” since if type: tcp isn’t given the integration assumes serial.