Fixing Zigbee Errors

Hi,

I have a Raspberry Pi4 with Hass.io 0.100.3. I have the Nortek HUSBZB-1 USB Hub running Zigbee and Z-Wave.

There were 2 Zigbee entities which didn’t exist anymore, and these caused the periodic discovery process from attempting to query them, which led to errors in the log.

In other posts, users were saying to delete the devices and redo the whole Zigbee discovery. After deciding that 2 issues out of 20 or so devices wasn’t worth the risk, I tried the following:

1) Backup the /conf/zigbee.db (or whatever you called it in the configuration.yaml file), and back it up offline - I used Samba to copy it to my windows machine.
2) Looking at this post - https://www.reddit.com/r/homeassistant/comments/86y1ue/question_how_to_read_zigbeedb/ I got the editor (https://portableapps.com/apps/development/sqlite_database_browser_portable) installed in windows, and ran it.
  1. I used the name of the entity, which in my config, looks like this: light.jasco_products_45857_002569b8, found the rows that containted the MAC address, i.e. 00:25:69:b8.
  2. For each entity I want to delete, there are really several entities which represent each sensor, and name field, etc. So for each of the 2 bad devices, I had to delete up to 7 other entities.
  3. I closed the database, and saved the file back under another windows file name.
  4. I loaded the file back into the hass.io RPi, while hiding the original one in an obscure directory.
  5. I rebooted the RPi…perhaps restarting Hass.io would have been enough, but I rebooted it anyway.
  6. HA started up, but looking at the log I see that the file wasn’t properly saved, in terms of permissions. It said the file was read-only. Windows save it as rw for the user, but just “r” for group NS other, so it was 644 octal. I saw the old file had an octal chmod value of 666 (-rw-rw-rw-), so I applied this to the file, and rebooted again.
  7. The offending devices are gone and the system no longer kept searching for the “bad” (non-responding) devices.
  8. I had debug logging on, so I turned it off, and I was done!

So, that worked, and it’s seems to be good. I’d recommend you screenshot the states listing in developer tools for the Zigbee integration first, as this way you’ll be sure you didn’t delete stuff you didn’t want.

If it did get goofed up, just replace the old file, and restart again. In fact, you could probably keep multiple files over time, and then it would be easier to go back. Here’s what I mean:

Copy the existing (for sake or argument) /config/zigbee.db file, and copy it to /conf/zigbee-10-20-2019.db (or however you want to mnemonically remember it). Then change the configuration.yaml to keep the proper name as a comment to remind you:

zha:
usb_path: /dev/ttyUSB1
database_path: /config/zigbee.db.
#old databases below - use for recovery by commenting out first one
#database_path: /config/zigbee-10-15-2019-troubleshot.db. # backup before deleting bad entities.

Of course, if the file has a date-value in it, the file is overwritten occasionally so maybe just keep the names on the backup copies you make of the file from time to time. But if you have an issue with Zigbee, just go back to a good DB. Maybe keep them all in another folder somewhere, so you don’t clog up the /config directory?

Let us know how you end up doing it!

Cheers,
Ambi

1 Like

Do you or anyone here knows whether its safe to remove/change your zigbee.db file? Does HA itself keep track somewhere of what happens in the zigbee.db? I seem to have a problem creating Zigbee groups from the ZHA integrations page (problem described here). I tried removing zigbee.db (renamed as backup), but did not seem to fix it. I am concerned switching zigbee.db files may corrupt my HA alltogether.