ZHA will not install!

I am trying to configure ZHA with either a Combee II for a Sonoff 3.0 USB Dongle. Both were on a long UBS extension cord. When I try to install ZHA it detects either the Sonoff or Combee (only one is plugged in at a time) and the install of ZHA starts. Right now with the Sonoff installed I get to the where HA asked if I want to upload a backup, or create a new network. I select ‘Create new network’
After a few minutes with the message ‘Loading next step for Zigbee Home Automation’ ZHA install crashes with the message ‘Error’.

I do have the Sonoff plugged into a USB 2.0, but I also have an external SSD plugged into a USB 3.0. Could this be the issue?

The error log shows the following:

Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:403
First occurred: October 14, 2023 at 20:20:54 (3 occurrences)
Last logged: 11:03:05

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 1069, in request_callback_rsp
    return await callback_rsp
           ^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 253, in start_network
    commissioning_rsp = await self.request_callback_rsp(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 1066, in request_callback_rsp
    async with async_timeout.timeout(timeout):
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 289, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 394, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/config_flow.py", line 381, in async_step_form_initial_network
    return await self.async_step_form_new_network(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/config_flow.py", line 387, in async_step_form_new_network
    await self._radio_mgr.async_form_network()
  File "/usr/src/homeassistant/homeassistant/components/zha/radio_manager.py", line 260, in async_form_network
    await app.form_network()
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 337, in form_network
    await self.form_network(fast=True)
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 291, in start_network
    raise zigpy.exceptions.FormationFailure(
zigpy.exceptions.FormationFailure: Network formation refused: there is too much RF interference. Make sure your coordinator is on a USB 2.0 extension cable and away from any sources of interference, like USB 3.0 ports, SSDs, 2.4GHz routers, motherboards, etc.

This last line seems to suggest that where ever you’ve placed the coordinator is too congested with interference. As a test, can you try moving it to somewhere else, or without the extension cable ?

If you’re powering the coordinator via a usb hub, make sure its a powered one.

As @Rofo noted, it finds too much RF interference (e.g. EMF/EMI/RMI noise), so suggest following this (especially the tips on using a very long USB extension cable to a USB 2.0 port or USB 2.0 hub and not a USB 3.x/4.x port or hub, and even be sure to keep it away from USB USB 3.x/4.x devices and cables due to the fact that they are know to cause EMF interference) → Zigbee networks: how to guide for avoiding interference and optimize for getting better range + coverage

Another related tip (that is also indirectly covered in above guide) is to upgrade firmware before starting.

I have the coordinator(s) (one at a time) on a 3 foot USB extension cable and far away from the pi itself. The cable is plugged into the PI 4 USB port. I moves the Sonoff coordinator far from everything and tried again . Here is the log from that attempt:

Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:403
First occurred: 03:30:25 (2 occurrences)
Last logged: 11:58:43

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 289, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 394, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/config_flow.py", line 381, in async_step_form_initial_network
    return await self.async_step_form_new_network(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/config_flow.py", line 387, in async_step_form_new_network
    await self._radio_mgr.async_form_network()
  File "/usr/src/homeassistant/homeassistant/components/zha/radio_manager.py", line 260, in async_form_network
    await app.form_network()
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 390, in form_network
    await self.backups.restore_backup(
  File "/usr/local/lib/python3.11/site-packages/zigpy/backups.py", line 157, in restore_backup
    await self.create_backup()
  File "/usr/local/lib/python3.11/site-packages/zigpy/backups.py", line 123, in create_backup
    await self.app.load_network_info(load_devices=load_devices)
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/zigbee/application.py", line 168, in load_network_info
    await self._znp.load_network_info(load_devices=load_devices)
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 228, in load_network_info
    await self._load_network_info(load_devices=load_devices)
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 104, in _load_network_info
    nib = await self.nvram.osal_read(OsalNvIds.NIB, item_type=t.NIB)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/nvram.py", line 168, in osal_read
    length = (await self.znp.request(c.SYS.OSALNVLength.Req(Id=nv_id))).ItemLen
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 1021, in request
    self._uart.send(frame)
    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'

Ok so here’s what happened. It was the external SSD all along. I thought for sure I had checked that, and although the SSD was plugged into the Pi it was not being used. So I took out the SSD and replaced the 16GB SD card with a 512 GB SDm andthe ZHA started to work again.

This has been frustrating and a good learning experience. Zigbee and External drives to not always play nice together.

Thank You to everyone who gave me ideas and insights!! Could not have fixed it without you.

1 Like

Yeah, Zigbee devices are very sensitive EMF interference and have a relatively short range, thus again, it is highly recommended that everyone using Zigbee devices read, understand, and try to follow all the tips here → Guide for Zigbee interference avoidance and network range/coverage optimization

Regardless of which Zigbee Coordinator USB radio adapter you use, always be sure to take active actions to avoid EMF/EMI/RFI-interference and also understand that you need to add many Zigbee Router devices to extend range and coverage (do not just add battery-powered devices ).

Especially be sure to connect the Zigbee Coordinator adapter via a long USB extension cable to a USB 2.0 port (and not a USB 3.x or USB 4.x port). If your computer only has USB 3.x/USB 4.x ports then buy a USB 2.0 hub and connect via it instead as that will in essence convert the port to USB 2.0 ports.

Once you done that, suggest starting by adding a few mains-powered Zigbee products that are known to work as good Zigbee Router devices (e.i. Zigbee signal repeater/extender) to act as the stable backbone of your Zigbee network mesh. Generally, the more Zigbee Router devices you have the more stable your Zigbee network mesh should become.

These are things needing to be addressed with any Zigbee Coordinator adapter on any Zigbee network.

@GregoryWest take note that Raspberry Pi 4 Model B have both USB 3.0 ports and USB 2.0 ports.

Do not use the Zigbee Coordinator USB radio adapter in a USB 3.0 port or close to USB 3.x devices(!), read → USB 3.0 Radio Frequency Interference Impact on 2.4 GHz Wireless Devices | USB-IFhttps://www.usb.org/sites/default/files/327216.pdf