home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.03k stars 28.28k forks source link

Modbus gives "Invalid config" when using tcp #114831

Closed oscfor closed 1 month ago

oscfor commented 1 month ago

The problem

After updating to 2024.4.0 I get the following error:

Configuration warnings Invalid config for 'modbus' at modbus/ctc.yaml, line 1: not a valid value for dictionary value 'modbus->0->type', got 'tcp' Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'baudrate' not provided Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'bytesize' not provided Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'method' not provided Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'parity' not provided Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'stopbits' not provided Invalid config for 'modbus' at modbus/ctc.yaml, line 3: 'host' is an invalid option for 'modbus', check: modbus->0->host Invalid config for 'modbus' at modbus/ctc.yaml, line 6: 'retry_on_empty' is an invalid option for 'modbus', check: modbus->0->retry_on_empty

What version of Home Assistant Core has the issue?

core-2024.4.0

What was the last working version of Home Assistant Core?

2024.3.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

modbus

Link to integration documentation on our website

https://www.home-assistant.io/integrations/modbus/

Diagnostics information

No response

Example YAML snippet

My configuration in the ctc.yaml

- type: tcp
  name: "ctc"
  host: 192.168.1.220
  port: 502
  delay: 3
  retry_on_empty: true

  sensors:
    - name: "ctc_hw_mode" # and so on...

Anything in the logs that might be useful for us?

Configuration warnings
Invalid config for 'modbus' at modbus/ctc.yaml, line 1: not a valid value for dictionary value 'modbus->0->type', got 'tcp'
Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'baudrate' not provided
Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'bytesize' not provided
Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'method' not provided
Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'parity' not provided
Invalid config for 'modbus' at modbus/ctc.yaml, line 1: required key 'stopbits' not provided
Invalid config for 'modbus' at modbus/ctc.yaml, line 3: 'host' is an invalid option for 'modbus', check: modbus->0->host
Invalid config for 'modbus' at modbus/ctc.yaml, line 6: 'retry_on_empty' is an invalid option for 'modbus', check: modbus->0->retry_on_empty

Additional information

It looks like it doesn't understand tcp any more, only serial connection.

home-assistant[bot] commented 1 month ago

Hey there @janiversen, mind taking a look at this issue as it has been labeled with an integration (modbus) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `modbus` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign modbus` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


modbus documentation modbus source (message by IssueLinks)

janiversen commented 1 month ago

hmmm that seems like a bug, I will investigate.

janiversen commented 1 month ago

Just checked the code, and it looks ok.

You have an invalid entry (as the log says) retry_on_empty, that might be the cause.

janiversen commented 1 month ago

This is documented as a breaking change in the release notes. It is recommended to read the release notes before upgrading, it can help avoid problems.

Closing since it is not a bug.

stefanogelmini commented 1 month ago

I've the some error, but after remove: #close_comm_on_error: true its work.

My config:

- type: rtuovertcp
  name: hub1
  host: 192.168.1.8
  port: 503
  #close_comm_on_error: true
  delay: 0
  message_wait_milliseconds: 30
  #retries: 3
  timeout: 5
janiversen commented 1 month ago

Just read the release notes it's all in there.