Modbus not working after upgrade to HA 091

Modbus not working

error below any ideas?
Fri Mar 29 2019 09:45:41 GMT+0300 (Israel Daylight Time)
Error while setting up platform modbus
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.5/asyncio/tasks.py”, line 400, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/modbus/switch.py”, line 68, in setup_platform
hub = hass.data[MODBUS_DOMAIN][hub_name]
KeyError: ‘default’

Could you post you modbus config and snippets of any applicable modbus sensor, switch or binary sensor config please?
Otherwise for your own troubleshooting efforts.
The key issue (for me anyway?) is the error relating to:

hub = hass.data[MODBUS_DOMAIN][hub_name]
KeyError: ‘default’

It’s looking for a defined name for the hub.

type: serial
method: rtu

port: /dev/ttyUSB0

port: /dev/serial/by-id/usb-Silicon_Labs_CP2104_USB_to_UART_Bridge_Controller_0133D18C-if00-port0
baudrate: 9600
stopbits: 1
bytesize: 8
parity: N
timeout: 4

  • platform: modbus

    coils:
    #====================================Module #1=============================

Living Room

  - name: Switch01
    slave: 10 
    coil: 0
  - name: Switch02
    slave: 10 
    coil: 1
  - name: Switch03
    slave: 10
    coil: 2
  - name: Switch04
    slave: 10
    coil: 3
# Kitchen
  - name: Switch05
    slave: 10
    coil: 4
  - name: Switch06
    slave: 10 
    coil: 5
  - name: Switch07
    slave: 10
    coil: 6
  - name: Switch08
    slave: 10
    coil: 7

Thanks for posting that.
Next question, what version of HA did you upgrade from?

From 0.88.0 you need to define your serial modbus hub like this:

# Example configuration.yaml entry
switch:
  platform: modbus
  slave: 1
  coils:
    - name: Switch1
      hub: hub1
      slave: 1
      coil: 13
    - name: Switch2
      slave: 2
      coil: 14

The important difference from the earlier modbus config is:
name: YourHubName

Likewise there needs to be the ‘hub’ defined in your modbus switch config as well.

Example configuration.yaml entry

switch:
platform: modbus
slave: 1
coils:
- name: Switch1
hub: hub1
slave: 1
coil: 13
- name: Switch2
slave: 2
coil: 14
registers:
- name: Register1
hub: hub1
slave: 1
register: 11
command_on: 1
command_off: 0

For the full documentation start here:

I reviewed this…
there is no issue with the settings as the same settings are working on clean installaion

Confused that I don’t see hub: hub1 or name: hub1 in the config examples you posted?

Sorry about the indentation on the switch examples.

Update: Clean installation of what version?

09.2
And i use same settings… For long time…

I can only suggest you try the new config and see if that helps.

thanks issue solved…
don’t know why and how…

Good news but was it with changes or did it just start working?

I just wrote everything from scratch on the file

The latest versions seem to be less forgiving in small errors in config I have found.

For example I had a modbus sensor which was working perfectly up to 0.90.0:

  • name: Grey Water RUN COUNT/Batch
    hub: hub1
    #unit_of_measurement: “L”
    slave: 1
    register: 3081

But had to remove the “/”

to become:

  • name: Grey Water RUN COUNT Batch
    hub: hub1
    #unit_of_measurement: “L”
    slave: 1
    register: 3081

I think that is the way the development is heading it seems.
Don’t let errors slip by…make users fix up sloppy mistakes instead?