core: Modbus not working from 2021.3.1

The problem

Modbus does not start in 2021.3.1 and 2021.3.2. In 2021.2.3, everything works normally.

What is version of Home Assistant Core has the issue?

2021.3.1 and 2021.3.2

What was the last working version of Home Assistant Core?

2021.2.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Modbus

Link to integration documentation on our website

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

Example YAML snippet

# Put your YAML below this line

modbus:

  • type: serial method: rtu port: /dev/serial0 baudrate: 115200 stopbits: 1 bytesize: 8 parity: N name: default
  • type: tcp host: 192.168.88.9 port: 502 name: wise4060

Anything in the logs that might be useful for us?

# Put your logs below this line

2021-03-06 19:59:30 ERROR (MainThread) [homeassistant.components.switch] Error while setting up modbus platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/modbus/switch.py", line 89, in async_setup_platform
    hub: ModbusHub = hass.data[MODBUS_DOMAIN][coil[CONF_HUB]]
KeyError: 'modbus_hub'
2021-03-06 19:59:30 ERROR (MainThread) [homeassistant.components.switch] Error while setting up modbus platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/modbus/switch.py", line 89, in async_setup_platform
    hub: ModbusHub = hass.data[MODBUS_DOMAIN][coil[CONF_HUB]]
KeyError: 'modbus_hub'



About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

as you can see, there is a key error, because “default” do not exist. In reality you found an error in the documentation. In my version we have DEFAULT_HUB = “modbusHub”, I will make a PR to update the doc.

Your error is in your sensors, not switch.