ZHA/Zigbee unable to set up ZHA with HUSBZB-1: "Error setting up entry /dev/ttyUSB1 for zha" and "unable to open database file"

I have Home Assistant 0.96.2 running in a docker image, and am trying to get my HUSBZB-1 stick set up. I have z-wave working fine from /dev/ttyUSB0, and am seeking to set up Zigbee control.

In my configuration.yaml I have:

zwave:
    usb_path: /dev/ttyUSB0
    network_key: <removed>
    
zha:
    usb_path: /dev/ttyUSB1
    database_path: /srv/homeautomation/hass-config/zigbee.db

Z-wave works fine, but the ZHA does not. If I go to Configuration (on the main Lovelace screen), I can click ZHA to add devices. If I click Add Devices it scans but never finds any of my devices (which I admit I do not know whether or not are working). If I try to call the service “zha.permit” the service does not exist and no zha* services appear in the dropdown. When I check “Developer Tools” there is an error entry that is generated during startup of HA:

Error setting up entry /dev/ttyUSB1 for zha
7:50 PM components/zha/core/gateway.py (ERROR)

When I click this error, the log details are the following:

Error setting up entry /dev/ttyUSB1 for zha
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/config_entries.py", line 153, in async_setup
    hass, self)
  File "/usr/src/app/homeassistant/components/zha/__init__.py", line 94, in async_setup_entry
    await zha_gateway.async_initialize()
  File "/usr/src/app/homeassistant/components/zha/core/gateway.py", line 89, in async_initialize
    radio, database)
  File "/usr/local/lib/python3.7/site-packages/bellows/zigbee/application.py", line 34, in __init__
    super().__init__(database_file=database_file)
  File "/usr/local/lib/python3.7/site-packages/zigpy/application.py", line 26, in __init__
    self._dblistener = zigpy.appdb.PersistingListener(database_file, self)
  File "/usr/local/lib/python3.7/site-packages/zigpy/appdb.py", line 34, in __init__
    detect_types=sqlite3.PARSE_DECLTYPES)
sqlite3.OperationalError: unable to open database file

At first I thought there may be a problem because I only had a /usr/local/lib/python3.6/ folder, but I installed python 3.7 and now have a /python3.7 folder, but this changed nothing.

This makes me think it is unable to access zigbee.db, which is not automatically created. So I ran “> zigbee.db” to create a file and used “chmod a-rwx” to make sure everyone can access that file just to be safe. Restarting HA yields the same error. I’ve also tried creating zigbee.db using the text editor and saving a file with that name, and then right-clicking that file and giving everyone read+write access. No luck. Maybe I need to install sqlite and manually create a blank .db file?

Running “ls -l /dev/serial/by-id/" confirms that the device "/dev/serial/by-id/usb-Silicon-Labs_HubZ_Smart_Home_Controller-612011F2-if0-port0” corresponds to …/…/ttyUSB*, for USB0 and USB1. As ttyUSB0 works for Z-wave, I am assuming I should be sticking to ttyUSB1 for ZHA.

I’m lost. I’m not sure where to go from here.

try setting the owner (chown command) to your HA docker user.

I have to do that occassionally for other file operations I need to perform.

in my case it’s (/home/finity/docker/ is the location of all my docker config files in sub-directories):

sudo chown -R finity:finity /home/finity/docker/

@finity, I am trying that now. I have created a new “zigbee.db” file at the location specified in my configuration.yaml using a text editor. I right clicked the file and gave everyone “read and write” access. The HA docker user is “ha”. I have run

# sudo chmod a+rwx /srv/homeautomation/hass-config/zigbee.db
# sudo chown -R ha:ha /srv/homeautomation/hass-config/zigbee.db
# stat -c "%U %G" /srv/homeautomation/hass-config/zigbee.db

The latest command outputs “ha ha” which I believe tells me that “ha” is the file owner. I then restarted Home Assistant. The same error as previously described appears: No change.

If you are speaking of the Linear/GoControl HUSBZB-1 you should verify your model as well as it’s true capabilities.

I think there is a similar controller that supports Z-Wave only… not sure of the model.

(As far as for my HUSBZB-1… after plugging it in and adding the config snippet everything just worked… ie: I didn’t have to create the db file… At most I had to add the integrations…)

What is the location of your HA configuration.yaml file in docker?

As from above mine is located at /home/finity/docker/hass-config/configuration.yaml. which is mapped into the docker container as /config/…

If the db file isn’t inside the same folder as your configuration.yaml you might have to whitelist the directory where the db file is located in HA in the “homeassistant:” section so that HA has access to it…

Per the Amazon listing and associated comments, this stick has both Z-Wave and Zigbee.

GoControl CECOMINOD016164 HUSBZB-1 USB Hub https://www.amazon.com/dp/B01GJ826F8/ref=cm_sw_r_cp_apa_i_.SasDbCQKC06K

Two ports show up when it’s plugged in: One works for Z-Wave, the other is presumably Zigbee. Good idea to check though!

Configuration.yaml and zigbee.db are in the same directory. There have seemed to be permission issues while setting it up, but they were always solved by what I have already done: giving the user “ha” read/write access to the file and it’s parent folder.

Just sayin’… because you did kinda mistype the model up top… but if two serial ports show up… that’s pretty conclusive.

Beyond that, not sure I can be of much help since I’m running mine through Hass.io on a Pi and mine ‘just worked’

You’re right, I did completely misspell that, which means it’s a good idea to double check. I have fixed the spelling mistake. Thank you!

Anyone know of anywhere else to pursue support of this issue?

Database path: /config

Is what I have mine set to on docker

This was the solution, thank you!

I changed my configuration.yaml entry from:

zha:
    usb_path: /dev/ttyUSB1
    database_path: /srv/homeautomation/hass-config/zigbee.db

to:

zha:
    usb_path: /dev/ttyUSB1
    database_path: /config/zigbee.db

I am now able to call the zha.permit service, and have successfully tied a Zigbee smart outlet to Home Assistant. Thank you!

finity, this was it, setting the docker container to /config/, thank you!