ZHA Zigbee change channel

Is there a way to change the default Zigbee channel for the zha component?
I own an Elelabs ZigBee USB adapter and woudl like to change the default channel (which, BTW I couldn’t determine: I saw a channel=15 in a form_network function, but it does not seem to be the right place).

Thank you

2 Likes

I don’t believe so. This is hard-coded into bellows, the underlying zigbee library that is used. If you need to, you can manually change the channel in the site-packages directory

/usr/local/lib/python3.7/site-packages/bellows/zigbee/application.py

at line 158

    async def form_network(self, channel=15, pan_id=None, extended_pan_id=None):
    channel = t.uint8_t(channel)

change “channel=15” to your desired channel

This will not survive an upgrade however.

EDIT: I stand corrected, see rpress reply below.

Thank you, I had found that myself and was kinda working, but I don’t want to customize that at every update.

You can use bellows to ‘form’ a new network on whatever channel you want. Once it is formed it will stay on that channel.

That’s good to know.

Where does that network information get stored? I can’t see anything in zha.storage or zigbee.db

It’s stored inside the dongle. There are encryption keys and various other things.

Can you post the exact command line to form the network?
Thanx

This is the command that I used, for channel 19:

bellows -d /dev/ttyUSB0 form -c 19

I should note too that this will require you pair your devices again.

4 Likes

You seem to be implying that if one executes the command bellows -d /dev/ttyUSB0 form -c 19 from then on, every time you restart Home Assistant the Zigbee network will remain on channel 19. Is this correct?

I seems that this should be a parameter passed in every time the form network command is executed which I would have thought would be in some startup code somewhere. How does the Zigbee network get created when the machine is powerd on? When is the ‘form network’ command issued? I certainly did not not manually do this the first time?

Is there a way to see what network the Nortek HUSBZB-1 is running on at present?

Yes.

Yeah, it should probably be a parameter somehow, I suppose. Or maybe the first time it is configured it somehow asks you what channel you want. It’s possible the HUSBZB-1 comes with a formed network when it’s purchased? I don’t know. I haven’t looked at the code, but I suppose if there is no formed network then Bellows will form one itself.

# bellows -d /dev/ttyUSB0 info
...
[0]
[<EmberNetworkStatus.JOINED_NETWORK: 2>]
[<EmberStatus.SUCCESS: 0>, <EmberNodeType.COORDINATOR: 1>, <EmberNetworkParameters extendedPanId=[15, 60, 4, 36, 250, 136, 196, 186] panId=19604 radioTxPower=8 radioChannel=19 joinMethod=EmberJoinMethod.USE_MAC_ASSOCIATION nwkManagerId=0 nwkUpdateId=0 channels=134215680>]
...

1 Like

Thanks for all the info. I tried executing the bellows command but it timed out ad gave me a string of errors…

bash-5.0# bellows -d /dev/zigbee info
Traceback (most recent call last):
  File "/usr/local/bin/bellows", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/bellows/cli/util.py", line 40, in inner
    loop.run_until_complete(f(*args, **kwargs))
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.7/site-packages/bellows/cli/ncp.py", line 75, in info
    s = await util.setup(ctx.obj['device'], ctx.obj['baudrate'])
  File "/usr/local/lib/python3.7/site-packages/bellows/cli/util.py", line 107, in setup
    await s.reset()
  File "/usr/local/lib/python3.7/site-packages/bellows/ezsp.py", line 55, in reset
    await self._gw.reset()
  File "/usr/local/lib/python3.7/site-packages/bellows/uart.py", line 208, in reset
    return await asyncio.wait_for(self._reset_future, timeout=RESET_TIMEOUT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 449, in wait_for
    raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

I am running in Docker on a Raspberry Pi. I started a shell inside Docker and issued the command changing /dev/TTYUSB0 to /dev/zigbee since that is where my stick turns up. Do I need to stop Home Assistant before I can run the Bellows command? If so, how would I do that in a Docker container?

I really appreciate all the help here as I learn my way around. I have an Aqara temperature and humidity sensor that will not stay connected so I am hoping it is a network channel issue bashing into my WifFi or something else.

Yep, they both can’t (shouldn’t) talk to the USB stick at the same time.

I’m not sure the best way to do that. Probably the easiest is to just disable the ZHA component (in the YAML or whatever) while you’re using Bellows in the terminal.

In the ZHA Configuration panel, check the LQI (Link Quality Index) and RSSI (Received Signal Strength Indicator) values. LQI less than 255 indicates packet loss. RSSI should ideally be something like -75 dB or better (e.g. -75 is better than -85).

1 Like

FYI @IanAber - I’ve had mixed results with the Aqara temp & humidity sensors. Some of the devices will drop from my network even with low RSSI. And others with a high RSSI (-90) will remain connected with no problem. I’ve been playing with moving devices around to see the impact that makes.

Good news is that getting the device to rejoin the network isn’t too bad. Just adding a new ZHA entry in HA and clicking the side button on the device. All settings are retained.

I have two Aqara Zigbee temperature and humidity sensors. One of them is very stable on a SmarThings network. The other drops of after a few hours, currently set up on Home Assistant with a HUSBZB-1 hub. The one that keeps dropping was doing the same on the SmarThings network too so I am sure it is the sensor not the hub that is the problem.
I found the same as you where opening the network to new devices and pressing the button on the sensor gets it working again but this is hardly a realistic answer to the problem. I am looking for an alternative sensor as these things are too unreliable to be anything but toys.

1 Like

I do not see anything by way of LQI in the ZHA configuration panel. Am I looking in the right place?

select a device from the device menu, the link quality will show then.

you can also use this custom lovelace panel:

1 Like

I have been trying to change my Zigbee channel to 20 and when I enter the following

bellows -d /dev/ttyUSB1 form -c 20

I get an error that the bellows command isn’t found

Am I missing something?

I think you’re not inside your venv, just try something like this before:

sudo su - homeassistant
source /opt/homeassistant/bin/activate

Please remember that HASS should be stopped when running bellows commands.

Thank you,

I’ll give that a try. After I enter the 1st command and input my password I get the following error

No passwd entry for user ‘homeassistant’

Unfortunately (or fortunately) Home Assistant allows for multiple ways to install it. Depending on how it’s installed will change how you access that bellows command. Also, bellows only works with the EmberZNet devices, like the Elelabs mentioned in the first post.

For example, on my Hass.io I can use the following to access belows:

root@hassio# docker exec -it homeassistant /bin/bash
bash-5.0# bellows -d /dev/ttyUSB0 form -c 19