ZHA: database file

teh zha componenet doesn’t work for me. I always get the same error. I use the dresden electronik conbee usb strick.

I have to create the database file myself (sqlite3). The database file is not created by the component. This doesn’t seem to work.

zha:
usb_path: /dev/ttyUSB0
database_path: zigbee_new.db 


2017-11-22 16:59:15 ERROR (MainThread) [homeassistant.setup] Error during setup of component zha
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 190, in _async_setup_component
    result = yield from component.async_setup(hass, processed_config)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/zha/__init__.py", line 90, in async_setup
    APPLICATION_CONTROLLER = ControllerApplication(ezsp_, database)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/zigbee/application.py", line 29, in __init__
    self._dblistener = bellows.zigbee.appdb.PersistingListener(database_file, self)
  File "/srv/homeassistant/lib/python3.5/site-packages/bellows/zigbee/appdb.py", line 29, in __init__
    detect_types=sqlite3.PARSE_DECLTYPES)
sqlite3.OperationalError: unable to open database file

For the database path enter the complete path where your zigbee database file is starting from the root ‘/’. Also make sure the account used to run home assistant has permissions to the db file. In my case, I run HA as user homeassistant and that account is owner of the db file as shown here:

-rw-r--r-- 1 homeassistant homeassistant     45056 Nov 22 19:06 zigbee.db
zha:
  usb_path: /dev/ttyUSB1
  database_path: /home/homeassistant/.homeassistant/zigbee.db

Have you confirmed your ConBee USB stick is actually at ttyUSB0?

i checked the permission for the database file

ls -l /home/homeassistant/.homeassistant/*.db
-rw-r--r-- 1 homeassistant homeassistant 8230912 Nov 23 21:39 /home/homeassistant/.homeassistant/home-assistant_v2.db
-rw-r--r-- 1 homeassistant homeassistant   45056 Nov 23 07:39 /home/homeassistant/.homeassistant/zigbee_new.db

I checked the device path of my conbee stick

lsusb
Bus 001 Device 004: ID 0403:6015 Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO)
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

dmesg | grep tty*
usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB0

I chanced the entry in my configuration.yaml

#zigbee:
zha:
usb_path: /dev/ttyUSB0
database_path: /home/homeassistant/.homeassistant/zigbee_new.db

now I get an other error in my home-assistant.log

2017-11-23 21:39:01 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=46 from 2017-11-23 06:39:54.399178)
2017-11-23 21:39:20 WARNING (MainThread) [homeassistant.setup] Setup of zha is taking over 10 seconds.
/home/homeassistant/.homeassistant/home-assistant.log (END)

and the home-assistant service doesn’t come up

The Conbee uses a different protocol than the ZHA component expects. There is a PR awaiting merge that will improve integration for deconz devices