ZHA Integration Not Starting with XBee3 USB

Tags: #<Tag:0x00007f739082a860>

Manually installed HA 0.113.3 on Ubuntu 20.04.1 in a virtual Python3 environment. HA starts fine and can locate and connect to devices it discovers on the local network (Chromecast, Samsung TV, weather integration).

I added a Digi XBee3 USB to the host, then added the integration for Zigbee using the web UI. It couldn’t communicate, but after adding the user that HA is running under (wbb) to the dialout group, the ZHA integration appeared to talk to the XBee3 USB and the integration installation success dialog showed in the web UI. When attempting to add a Zigbee device however it always times out.

I enabled the debug level logging for Zigbee in the HA configuration. When attempting to add a device to the ZHA integration through the web UI I saw the logged error:

Received invalid command: zha/devices/permit

Taking a step back, I removed the Zigbee integration and then added it back in. I noticed that by default it was attempting communication at baud 115200 with some communication timeout warnings in the log. I re-added the integration with manual entry of port path which allowed setting the baud rate to the recommended 57600 for the XBee3. This eliminated the timeouts, but I consistently see the following in the log when adding the integration:

2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] at command: AP (2,)
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] Command at (b'AP', b'\x02')
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] Frame received: at_response
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy.appdb] Loading application state from /home/wbb/.homeassistant/zigbee.db
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] at command: AP (2,)
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] Command at (b'AP', b'\x02')
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] Frame received: at_response
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] at command: AO (3,)
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] Command at (b'AO', b'\x03')
2020-08-01 17:58:29 DEBUG (MainThread) [zigpy_xbee.api] Frame received: at_response
2020-08-01 17:58:29 ERROR (MainThread) [zigpy.application] Couldn't start application
2020-08-01 17:58:29 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ANZ22CD2-if00-port0 for zha
Traceback (most recent call last):
  File "/home/wbb/homeassistant/lib/python3.8/site-packages/homeassistant/config_entries.py", line 219, in async_setup
    result = await component.async_setup_entry(  £ type: ignore
  File "/home/wbb/homeassistant/lib/python3.8/site-packages/homeassistant/components/zha/__init__.py", line 100, in async_setup_entry
    await zha_gateway.async_initialize()
  File "/home/wbb/homeassistant/lib/python3.8/site-packages/homeassistant/components/zha/core/gateway.py", line 146, in async_initialize
    self.application_controller = await app_controller_cls.new(
  File "/home/wbb/homeassistant/lib/python3.8/site-packages/zigpy/application.py", line 65, in new
    await app.startup(auto_form)
  File "/home/wbb/homeassistant/lib/python3.8/site-packages/zigpy_xbee/zigbee/application.py", line 62, in startup
    await self._api._at_command("AO", 0x03)
  File "/home/wbb/homeassistant/lib/python3.8/site-packages/zigpy_xbee/api.py", line 381, in _at_partial
    return await asyncio.wait_for(
  File "/usr/lib/python3.8/asyncio/tasks.py", line 483, in wait_for
    return fut.result()
RuntimeError: AT Command response: ERROR

I tried removing the zigbee.db and adding back the integration and tried adding back after rebooting the host, but always get the same error above. Any suggestions for other things to try would be welcome as I am truly stuck at this point.