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
73.92k stars 30.98k forks source link

modbus configuration requiring mandatory serial configuration settings for a TCP connection #127458

Open peter5111 opened 1 month ago

peter5111 commented 1 month ago

The problem

Had a working modbus yaml config in a previous release of HA Core

following upgrade to 24.10.0 modbus config now errors due to missing serial configuration details despite the configuration being for a TCP connection.

No changes were made to the previously working .yaml

What version of Home Assistant Core has the issue?

2024.10.0

What was the last working version of Home Assistant Core?

No response

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

modbus:
    -   name: sma855
        type: tcp
        host: 192.168.178.136
        port: 502
        area: newstead
        sensors:
            -   name: SMA_855_Power_AC
                state_class: measurement
                device_class: power
                unit_of_measurement: W
                slave: 3
                address: 30775
                data_type: int32
                min_value: 0
            -   name: SMA_855_Power_Day
                state_class: total
                device_class: energy
                unit_of_measurement: Wh
                slave: 3
                address: 30517
                data_type: uint64
                min_value: 0
    -   name: sma861
        type: tcp
        host: 192.168.178.137
        port: 502
        area: newstead
        sensors:
            -   name: SMA_861_Power_AC
                state_class: measurement
                device_class: power
                unit_of_measurement: W
                slave: 3
                address: 30775
                data_type: int32
                min_value: 0
            -   name: SMA_861_Power_Day
                state_class: total
                device_class: energy
                unit_of_measurement: Wh
                slave: 3
                address: 30517
                data_type: uint64
                min_value: 0

Anything in the logs that might be useful for us?

Configuration warnings
Invalid config for 'modbus' at configuration.yaml, line 14: required key 'baudrate' not provided
Invalid config for 'modbus' at configuration.yaml, line 14: required key 'bytesize' not provided
Invalid config for 'modbus' at configuration.yaml, line 14: required key 'method' not provided
Invalid config for 'modbus' at configuration.yaml, line 14: required key 'parity' not provided
Invalid config for 'modbus' at configuration.yaml, line 14: required key 'stopbits' not provided
Invalid config for 'modbus' at configuration.yaml, line 15: not a valid value for dictionary value 'modbus->0->type', got 'tcp'
Invalid config for 'modbus' at configuration.yaml, line 16: 'host' is an invalid option for 'modbus', check: modbus->0->host
Invalid config for 'modbus' at configuration.yaml, line 18: 'area' is an invalid option for 'modbus', check: modbus->0->area

Additional information

No response

home-assistant[bot] commented 1 month ago

modbus documentation modbus source

peter5111 commented 1 month ago

removed "area: newstead" entries No idea how / when they got there. Likely I simply didn't notice the log messages at the time.

Still highlights an issue with how error messages are generated; tcp is absolutely a valid type for modbus and shouldn't be flagged as otherwise due to an unrelated configuration error. All bar one of the flagged errors were valid entries within the yaml according to the modbus documentation.

Not the first time a similar bug has been reported in the modbus module; suggests room for improvement in documentation and log message logic. Not everybody who is getting their head around Homeassistant is a genius programmer.

thrhymes commented 2 weeks ago

having the same problem with rtuovertcp

so here is my config:

#EPEver eBox-Wifi-01 modbus
modbus:
  - type: rtuovertcp
    name: Solar2
    host: 10.0.0.69
    port: 8088
    delay: 5
    timeout: 10
    retries: 20
    message_wait_milliseconds: 30

here are the logs

2024-11-07 16:00:48.556 ERROR (MainThread) [homeassistant.config] Invalid config for 'modbus' at configuration.yaml, line 43: required key 'baudrate' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 43: required key 'bytesize' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 43: required key 'method' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 43: required key 'parity' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 43: required key 'stopbits' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 44: not a valid value for dictionary value 'modbus->0->type', got 'rtuovertcp', please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 45: 'host' is an invalid option for 'modbus', check: modbus->0->host, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 49: 'retries' is an invalid option for 'modbus', check: modbus->0->retries, please check the docs at https://www.home-assistant.io/integrations/modbus
2024-11-07 16:00:48.556 ERROR (MainThread) [homeassistant.setup] Setup failed for 'modbus': Invalid config.

here is why this matters when i cannot read the battery-charge state the inverter does not turn off draining the battery

i dont see what is wrong with the config suddenly? i did not change it.compairing it to the documentation... it looks fine... i read the last few update-notes, but could not find, whats wrong...

help please!

mhbacks commented 6 days ago

same here: had a working configuration including 2024.10.04. After Upgrade to 2024.11.01 and .02 a get the same error.

so here is my config:

modbus:
  - name: "lg_heatpump"
    type: tcp
    host: !secret lg_heatpump_modbus_host_ip
    port: !secret lg_heatpump_modbus_port
    retries: 5

    sensors:
       [...]

here are the logs

2024-11-18 08:06:04.401 ERROR (MainThread) [homeassistant.config] Invalid config for 'modbus' at configuration.yaml, line 60: required key 'baudrate' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 60: required key 'bytesize' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 60: required key 'method' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 60: required key 'parity' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 60: required key 'stopbits' not provided, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 61: not a valid value for dictionary value 'modbus->0->type', got 'tcp', please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at configuration.yaml, line 64: 'retries' is an invalid option for 'modbus', check: modbus->0->retries, please check the docs at https://www.home-assistant.io/integrations/modbus
Invalid config for 'modbus' at secrets.yaml, line 7: 'host' is an invalid option for 'modbus', check: modbus->0->host, please check the docs at https://www.home-assistant.io/integrations/modbus
2024-11-18 08:06:04.401 ERROR (MainThread) [homeassistant.setup] Setup failed for 'modbus': Invalid config.