Modbus component cant setup platform?

This error is killing me, can anyone see the issue?

Error while setting up platform modbus
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 442, in wait_for
return fut.result()
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/modbus/switch.py”, line 79, in setup_platform
hub = hass.data[MODBUS_DOMAIN][hub_name]
KeyError: ‘hub1’


modbus:
  name: test
  type: tcp
  host: 192.168.1.202
  port: 502
  
switch:
  platform: modbus
  coils:
    - name: Switch1
      hub: test
      slave: 1
      coil: 13
    - name: Switch2
      slave: 2
      coil: 14
  registers:
    - name: Register1
      hub: test
      slave: 1
      register: 11
      command_on: 1
      command_off: 0

Thanks

You missed a bit in your Switch2 config:

switch:
  platform: modbus
  coils:
    - name: Switch1
      hub: test
      slave: 1
      coil: 13
    - name: Switch2
      hub: YOUR_HUB_NAME __YOU_MISSED    
      slave: 2
      coil: 14

Easy to do but your clue is here:

hub = hass.data[MODBUS_DOMAIN][hub_name]

Looool totally missed that… thanks!

1 Like

Your welcome