0.49 Zigbee db errors?

I’m using a HUSBZB-1 Zigbee/Zwave stick.

With out any zigbee devices paired I can restart server and zha starts without issues.

However if I have a zigbee device paired zha will fail to start when trying to read the zigbee.db.
I believe when I add a device there is something bad written to the db.

The fix is to delete the zigbee.db and then zha will start ok.

I have tried Smartthings Open/Closed sensor and Smartthings Motion sensor with same result.

The error is:

2017-07-20 06:56:44 INFO (MainThread) [homeassistant.setup] Setting up zha
2017-07-20 06:56:44 DEBUG (MainThread) [bellows.zigbee.appdb] Loading application state from /config/zigbee.db
2017-07-20 06:56:44 ERROR (MainThread) [homeassistant.setup] Error during setup of component zha
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 191, in _async_setup_component
    result = yield from component.async_setup(hass, processed_config)
  File "/usr/src/app/homeassistant/components/zha/__init__.py", line 87, in async_setup
    APPLICATION_CONTROLLER = ControllerApplication(ezsp_, database)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 30, in __init__
    self._dblistener.load()
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/appdb.py", line 204, in load
    clus = ep.in_clusters[cluster]
KeyError: 0

@rcloran I saw there were some changes related to clusters being changed to in_clusters/out_clusters.
Any chance this db error is related?
I tried 0.49 and dev (7/20) version of HA docker images.

https://github.com/rcloran/bellows/commit/9c9856bccf2fb04adddb0a0f49fc5c3185f1ded3 Should fix this. I haven’t confirmed, so if you can test for me, that’d be appreciated. You’ll need to re-add the device.

@rcloran Thanks, I will try those changes, hopefully late today, and let you know.

@rcloran

I tried copying over just the init and then the entire bellows dir from 9c9856bccf2fb04adddb0a0f49fc5c3185f1ded3.zip
on 0.49

However, I must be doing something wrong as I get below error.
Can you help with detailed instructions?

2017-07-21 03:39:48 ERROR (MainThread) [homeassistant.setup] Error during setup of component zha
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 187, in _async_setup_component
    result = yield from component.async_setup(hass, processed_config)
  File "/usr/src/app/homeassistant/components/zha/__init__.py", line 79, in async_setup
    import bellows.ezsp
  File "/usr/local/lib/python3.6/site-packages/bellows/__init__.py", line 295, in <module>
    from . import clusters  # noqa: F401, F402
ImportError: cannot import name 'clusters'

Looks like you might be copying the init.py from bellow/zigbee/zcl/ into the root directory of bellows. You’re probably missing some options to unzip

You were correct, my bad.
It works now :smile:

Should be fixed in 0.49.1.