Issue running backup. Thinks ZHA is still enabled

I recently switched from ZHA to Z2M and now I cannot perform a backup in Home Assistant. It look like it is erroring out on ZHA still being active even though it does not show in the integrations panel. However I still have the “Add Zigbee Device” button for ZHA when clicking “Add Integration”. This will lead to the ZHA config page with the “Network” “Groups” and “Visualization” tabs. The logs show unknown command each time I navigate to the page and there is no data shown in any field.

I am not sure where to look in the files to remove this ghost setup of ZHA. I even added my coordinator back and then deleted it with no change. I have tried searching around but cannot find anything related to the errors I am getting. Does any one know where this could be located in the config files so that I can remove it?

2023-01-24 18:23:31.843 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140627865470288] Received unknown command: zha/devices/permit
2023-01-24 18:23:33.096 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140627865470288] Received unknown command: zha/configuration
2023-01-24 18:23:33.097 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140627865470288] Received unknown command: zha/network/settings

2023-01-24 18:31:40.860 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140394162856352] Error handling message: Unknown error (unknown_error) from 192.168.x.x 
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/backup/websocket.py", line 70, in handle_create
    backup = await manager.generate_backup()
  File "/usr/lib/python3.10/site-packages/homeassistant/components/backup/manager.py", line 172, in generate_backup
    raise result
  File "/usr/lib/python3.10/site-packages/homeassistant/components/zha/backup.py", line 16, in async_pre_backup
    zha_gateway: ZHAGateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
KeyError: 'zha_gateway'

I have found an old entry for ZHA in core.config_entries file and have removed it. Now there is no trace of the string ‘ZHA’ in any file in the ‘.storage’ folder. This has fixed the broken ZHA page I was able to get to, it now says now that Zigbee is not setup which is what I expect. I am still receiving the error above when performing the backup though. I cannot find where this ZHA config would still be at this point.

Edit: For anyone that might have this issue in the future. Looks like I still had an entry in configuration.yaml and core.config_entries for ZHA stuff. Once both were removed the error has stopped occurring.

1 Like