Zigbee Error with Sonoff Zigbee 3.0 Dongle

Hello,

i get following error, if i would install the sonoff Zigbee 3.0 Dongle and Zigbee is not working:

Logger: homeassistant.config_entries
Source: components/zha/core/gateway.py:152
First occurred: 12:30:59 (2 occurrences)
Last logged: 13:29:34

Error setting up entry Sonoff Zigbee 3.0 USB Dong - /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_68a8faff66c8eb118240c5c3de5b81b4-if00-port0, s/n: 68a8faff66c8eb118240c5c3de5b81b4 - ITead - 10C4:EA60 for zha
Error setting up entry Sonoff Zigbee 3.0 USB Dongle Plus, s/n: 68a8faff66c8eb118240c5c3de5b81b4 - ITead for zha
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/zigpy_znp/api.py", line 888, 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.9/site-packages/zigpy_znp/api.py", line 282, in write_network_info
    commissioning_rsp = await self.request_callback_rsp(
  File "/usr/local/lib/python3.9/site-packages/zigpy_znp/api.py", line 888, in request_callback_rsp
    return await callback_rsp
  File "/usr/local/lib/python3.9/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.9/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 327, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 102, in async_setup_entry
    await zha_gateway.async_initialize()
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 152, in async_initialize
    self.application_controller = await app_controller_cls.new(
  File "/usr/local/lib/python3.9/site-packages/zigpy/application.py", line 69, in new
    await app.startup(auto_form)
  File "/usr/local/lib/python3.9/site-packages/zigpy_znp/zigbee/application.py", line 152, in startup
    return await self._startup(
  File "/usr/local/lib/python3.9/site-packages/zigpy_znp/zigbee/application.py", line 207, in _startup
    await self.form_network()
  File "/usr/local/lib/python3.9/site-packages/zigpy_znp/zigbee/application.py", line 393, in form_network
    await self.write_network_info(network_info=network_info, node_info=node_info)
  File "/usr/local/lib/python3.9/site-packages/zigpy_znp/zigbee/application.py", line 1149, in write_network_info
    return await self._znp.write_network_info(
  File "/usr/local/lib/python3.9/site-packages/zigpy_znp/api.py", line 311, in write_network_info
    raise RuntimeError(
RuntimeError: Network formation refused, RF environment is likely too noisy. Temporarily unscrew the antenna or shield the coordinator with metal until a network is formed.

Can someone help?
Thanks
Thomas

1 Like

Did you try that?

3 Likes

Before doing anything begin by upgrading the firmware and put dongle on a long USB extension cable:

https://community.home-assistant.io/t/sonoff-zigbee-3-0-usb-dongle-plus-by-itead-is-based-on-texas-instruments-cc2652p-can-now-be-ordered-for-10-99/340705/

Network formation refused, RF environment is likely too noisy. Temporarily unscrew the antenna or shield the coordinator with metal until a network is formed.

If “RF environment is likely too noisy” then should also take actions to avoid interference sources, see:

https://github.com/home-assistant/home-assistant.io/pull/18864

As mentioned there take note to use the dongle in either a USB 2.0 port or via a powered USB 2.0 hub because as Zigbee is especially sensitive even USB 3.0 ports/cables generate interference on 2.4GHz.

Then later after getting it working also read this before starting pairing devices:

https://www.home-assistant.io/integrations/zha#best-practices-to-avoid-pairingconnection-difficulties

PS: If it helps give PR a thumbs up https://github.com/home-assistant/home-assistant.io/pull/18864

3 Likes

Just wanted to say this happened to me too and the advise here worked thank you

2 Likes

Had the same issue, take off the antenna when setting up, add the antenna later on.
Also on Pi 4b absolutely use a USB extension cable it works wonders!

2 Likes

Hello, I followed same set up,and still have error , here is message I get, can someone help;please ?
Thank,you

Logger: homeassistant.config_entries


Source: components/zha/core/gateway.py:182 
First occurred: 16:34:32 (1 occurrences) 
Last logged: 16:34:32

Error setting up entry Sonoff Zigbee 3.0 USB Dong - /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_bab65e0845c8eb11835ac5c3de5b81b4-if00-port0, s/n: bab65e0845c8eb11835ac5c3de5b81b4 - ITead - 10C4:EA60 for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 102, in async_setup_entry
    await zha_gateway.async_initialize()
  File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 182, in async_initialize
    self.application_controller = await app_controller_cls.new(
  File "/usr/local/lib/python3.9/site-packages/zigpy/application.py", line 61, in new
    await app._load_db()
  File "/usr/local/lib/python3.9/site-packages/zigpy/application.py", line 50, in _load_db
    self._dblistener = await zigpy.appdb.PersistingListener.new(database_file, self)
  File "/usr/local/lib/python3.9/site-packages/zigpy/appdb.py", line 148, in new
    await listener.initialize_tables()
  File "/usr/local/lib/python3.9/site-packages/zigpy/appdb.py", line 127, in initialize_tables
    async with self.execute("PRAGMA integrity_check") as cursor:
  File "/usr/local/lib/python3.9/site-packages/aiosqlite/context.py", line 41, in __aenter__
    self._obj = await self._coro
  File "/usr/local/lib/python3.9/site-packages/aiosqlite/core.py", line 184, in execute
    cursor = await self._execute(self._conn.execute, sql, parameters)
  File "/usr/local/lib/python3.9/site-packages/aiosqlite/core.py", line 129, in _execute
    return await future
  File "/usr/local/lib/python3.9/site-packages/aiosqlite/core.py", line 102, in run
    result = function()
sqlite3.DatabaseError: file is not a database

Are you also gettign that same RuntimeError message in the log as the origional poster in this thread?

RuntimeError: Network formation refused, RF environment is likely too noisy. Temporarily unscrew the antenna or shield the coordinator with metal until a network is formed.

If so then as mentioned above, try removing the ZHA integration to get a clean slate, and then temporarily unscrew the antenna from the Zigbee dongle before running through the ZHA config flow for installation, only after that once setup is fully complete screw back the antenna in place. Alternativly temporarily put tinfoil around the antenna and dongle to shield it from getting any radio signal during the initial Zigbee network formation. Temporarily removing the antenna from the Zigbee Coordinator adapter or temporarily shielding it with metal prevents it from picking up any interference during the initial setup initialization of the Zigbee network.

Again, this assumes that you followed the other linked tips above, including upgrading dongle firmware.

However if problem is the database then try manually deleting the zigbee.db file after removing ZHA to make sure that it has been removed. Removing ZHA should delete that but perhaps it did not for you.

Hadda,
Thank you for your answer.
I followed all the step and did not put the antenna.
I do not have this runtime error , see at the bottom of this message what I get from the logs.

I will remove ZHA again and then delete the db

Thank you , I will keep you updated:-)

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/connection.py:96
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 19:19:31 (4 occurrences)
Last logged: 19:19:43

[547814113584] Received invalid command: zha/configuration
[547814113584] Received invalid command: zha/groups
[547814113584] Received invalid command: zha/devices

Logger: homeassistant.config_entries
Source: components/zha/core/gateway.py:182
First occurred: 10 mai 2022 à 16:34:32 (1 occurrences)
Last logged: 10 mai 2022 à 16:34:32

Error setting up entry Sonoff Zigbee 3.0 USB Dong - /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_bab65e0845c8eb11835ac5c3de5b81b4-if00-port0, s/n: bab65e0845c8eb11835ac5c3de5b81b4 - ITead - 10C4:EA60 for zha
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 335, in async_setup
result = await component.async_setup_entry(hass, self)
File “/usr/src/homeassistant/homeassistant/components/zha/init.py”, line 102, in async_setup_entry
await zha_gateway.async_initialize()
File “/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py”, line 182, in async_initialize
self.application_controller = await app_controller_cls.new(
File “/usr/local/lib/python3.9/site-packages/zigpy/application.py”, line 61, in new
await app._load_db()
File “/usr/local/lib/python3.9/site-packages/zigpy/application.py”, line 50, in _load_db
self._dblistener = await zigpy.appdb.PersistingListener.new(database_file, self)
File “/usr/local/lib/python3.9/site-packages/zigpy/appdb.py”, line 148, in new
await listener.initialize_tables()
File “/usr/local/lib/python3.9/site-packages/zigpy/appdb.py”, line 127, in initialize_tables
async with self.execute(“PRAGMA integrity_check”) as cursor:
File “/usr/local/lib/python3.9/site-packages/aiosqlite/context.py”, line 41, in aenter
self._obj = await self._coro
File “/usr/local/lib/python3.9/site-packages/aiosqlite/core.py”, line 184, in execute
cursor = await self._execute(self._conn.execute, sql, parameters)
File “/usr/local/lib/python3.9/site-packages/aiosqlite/core.py”, line 129, in _execute
return await future
File “/usr/local/lib/python3.9/site-packages/aiosqlite/core.py”, line 102, in run
result = function()
sqlite3.DatabaseError: file is not a database

Hadda,
After I cleaned the Zigbee.db, remove Zha, restart, it works!!!

THANK YOU ! So was the database :slight_smile:

file is not a database

@yann1966 Probably a good idea if you report that anyway so that the developers can at least add a runtime error in the logs with a message in the future to tell the users what to do then that sqlite3.DatabaseError: file is not a database occor.

Report as bug to → https://github.com/home-assistant/core/issues

Alternativly create developer discussion here → https://github.com/zigpy/zigpy/discussions

Such a RuntimeError message could maybe for example give a more verbose message to say:

RuntimeError: Database error, if installation is failing then consider removing the ZHA database and manually deleting the zigbee.db before trying to install ZHA again.

1 Like

Jedda, good idea, i just made a report.
Thank you for advice.

1 Like

The only way how I can make my Conbee 2 and Sonoff Zigbee 3.0 Dongle Plus stick work on my Raspberry Pi 4B is with the following setup:

  • Zigbee stick connected in an externally powered USB hub.
  • This USB hub is connected to the USB 2 (i.e. the black ports, not the blue ports).

Anything else will fail with my Raspberry Pi 4B setup:

  • Zigbee stick directly connected to any USB port → fail
  • Zigbee stick connected to any USB port with an extension USB cable → fail
  • Zigbee stick connected to an externally powered USB hub on a blue USB 3 port → fail

So if anything else fails, try connecting the Zigbee stick to an externally-powered USB hub which is connected to one of the two black USB 2 ports. Preferably do not have any other devices connected to the USB hub.

I had a zigbee network running rock solid with a conbee II for months until a few weeks ago and now it’s dead. I have replaced the entire stack - pi, zigbee stick, 6ft usb extention, ha software - even power supply. i’m still getting

Is interference the only thing left?

Buy a powered USB 2.0 hub with its own external power supply (note not to get a USB 3.x hub) as all USB 3.0 ports will cause interference on the 2.4GHz frequency where Zigbee (as well as Bluetooth, Thread, and Wi-Fi) operate, then connect a very long USB extension cable via the USB 2.0 hub (again not a USB 3.0 port or a USB 3.x hub) so that it gets far away from your computer and other peripherals with USB 3.0 ports, also update Zigbee Coordinator firmware on the Zigbee USB adapter, then connect “Zigbee Router” devices (e.g. mains-powered adapters) first before connecting any Zigbee end-devices (e.g. battery-powered devices) if you did not do that, preferably also start by adding “Zigbee Router” devices closest to the Zigbee Coordinator, see → https://github.com/zigpy/zigpy/wiki/Generic-best-practice-tips-on-improving-Zigbee-network-range-and-general-stability

Personally, I recommend also getting a few dedicated “Zigbee Router” devices such as either the IKEA Trådfri Signal Repeater and better yet ITead’s ZBDongle-E or ZBDongle-P flashed with Zigbee Router firmware, as having a few dedicated always-on “Zigbee Router” devices will make for a much more stable Zigbee network mesh.

1 Like

worked for me today. nice and easy, just took of the antenna and got it going. Thanks, this is why Home Assistant rocks.

1 Like

I’m having the following issue:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 1028, in request
    response = await response_future
               ^^^^^^^^^^^^^^^^^^^^^
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/zigbee/application.py", line 679, in _watchdog_loop
    await self._znp.request(c.SYS.Ping.Req())
  File "/usr/local/lib/python3.11/site-packages/zigpy_znp/api.py", line 1024, in request
    async with async_timeout.timeout(
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
TimeoutError
2023-09-01 17:55:33.551 ERROR (MainThread) [aiohttp.server] 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 227, 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/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, 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 292, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 392, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/config_flow.py", line 376, in async_step_form_new_network
    await self._radio_mgr.async_form_network()
  File "/usr/src/homeassistant/homeassistant/components/zha/radio_manager.py", line 224, in async_form_network
    await app.form_network()
  File "/usr/local/lib/python3.11/site-packages/zigpy/application.py", line 386, 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'

You ever get this figured out? I’m having the same issue, similar log messages.

instead of selecting to erase the network and start over, i selected to use the current settings, and now it works.

Mystery solved, thx to this thread:
Using Dongle-P with a Pi 4b and HA OS, which is running on a USB SSD. For a week, I thought this was causing the thing to throw ‘error’ during the initial setup of ZHA.
Today, I used a USB extension cable without success, then read further and disconnected the antenna. At last, it worked.
Observation:
ZHA-setup menu showed a third network option (load backup; delete all settings and setup new network; continue with existing settings). Didn’t know I had existing settings in the first place, since setup never succeeded so far. I chose the ‘continue with existing’ option, a new entity tile appeared and seconds later I was ready to go.
(And I even use a USB 3.0 extension cable since I did not have 2.0 lying around. Using this on 2.0 port, however.)

Big thx to everyone here!

1 Like

hey Albert,

Did you ever solve this?
fighting same error now for 2 days and none of advises did help.