core icon indicating copy to clipboard operation
core copied to clipboard

ZHA failed to set up on kernel 6.14

Open a-baturin opened this issue 7 months ago • 7 comments

The problem

ZHA failed to start on 6.14 kernels on ArchLinux (could not test other OS) Rollback to 6.13 solves the issue, but it's not a real solution.

What version of Home Assistant Core has the issue?

core-2025.5.0,core-2025.4.*

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

ZHA

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zha/

Diagnostics information

Example YAML snippet


Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:749
First occurred: 07:11:27 (1 occurrence)
Last logged: 07:11:27

Error setting up entry /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 for zha
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 701, in _skip_bootloader
    result = await responses.get()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 744, in connect
    self.capabilities = (await self._skip_bootloader()).Capabilities
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 700, in _skip_bootloader
    async with asyncio_timeout(CONNECT_PROBE_TIMEOUT):
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/asyncio/timeouts.py", line 116, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/config_entries.py", line 749, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/components/zha/__init__.py", line 156, in async_setup_entry
    await zha_gateway.async_initialize()
  File "/srv/homeassistant/lib/python3.13/site-packages/zha/application/gateway.py", line 271, in async_initialize
    await self._async_initialize()
  File "/srv/homeassistant/lib/python3.13/site-packages/zha/application/gateway.py", line 254, in _async_initialize
    await self.application_controller.startup(auto_form=True)
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy/application.py", line 220, in startup
    await self.connect()
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/zigbee/application.py", line 82, in connect
    await znp.connect()
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 757, in connect
    await self.disconnect()
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 804, in disconnect
    await self._uart.wait_until_closed()
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy/serial.py", line 71, in wait_until_closed
    await self._disconnected_event.wait()
  File "/usr/lib/python3.13/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError: Global task timeout

Additional information

No response

a-baturin avatar May 08 '25 05:05 a-baturin

Hey there @dmulcahey, @adminiuga, @puddly, @thejulianjes, mind taking a look at this issue as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zha can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zha Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


zha documentation zha source (message by IssueLinks)

home-assistant[bot] avatar May 08 '25 05:05 home-assistant[bot]

@a-baturin - May need to specify more info, and may want to look at your dmesg.

I am running Proxmox and just switched to their 6.14 kernel today and I have a Sonoff USB dongle, passed through to an LXC running Docker with HA as a container and it's functioning.

esand avatar May 09 '25 21:05 esand

Please attach debug info. You need to specify what exact environment you're using, how you're running Home Assistant, what adapter you're using, and what's in your logs and kernel log.

If you run Home Assistant Core on Arch Linux, you're sort of on your own when it comes to dependency management. That being said, I can't think of any reason why a kernel upgrade would affect ZHA unless there's a serious regression with a Linux serial port driver. ZHA just opens a serial port and talks to the coordinator, it really doesn't depend on anything this low-level.

puddly avatar May 09 '25 22:05 puddly

I have CC2652P2 USB dongle (ch341) which worked good enough so far. HA in venv. Kernel log attached. Will the full HA log be helpful or I'd better do some pre-selection?

kernel.log

If you run Home Assistant Core on Arch Linux, you're sort of on your own when it comes to dependency management.

That's clear :-) I just hoped that someone faced the same and solved it.

That being said, I can't think of any reason why a kernel upgrade would affect ZHA unless there's a serious regression with a Linux serial port driver. ZHA just opens a serial port and talks to the coordinator, it really doesn't depend on anything this low-level.

I'm not a kernel developer, so I could miss something but I don't see anything in kernel release notes what could lead to behaviour I observe.

a-baturin avatar May 10 '25 06:05 a-baturin

I tried without HA, zigpy directly. Works with 6.13, bot with 6.14:

(homeassistant) [homeassistant@ha-server homeassistant]$ python -m zigpy_znp.tools.energy_scan /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 
2025-05-10 19:51:19.820 ha-server __main__ INFO Starting up zigpy-znp
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 1079, in request
    response = await response_future
               ^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/tools/energy_scan.py", line 96, in <module>
    asyncio.run(main(sys.argv[1:]))  # pragma: no cover
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/tools/energy_scan.py", line 92, in main
    await perform_energy_scan(args.serial, num_scans=args.num_scans)
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/tools/energy_scan.py", line 22, in perform_energy_scan
    await app.connect()
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/zigbee/application.py", line 82, in connect
    await znp.connect()
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 744, in connect
    self.capabilities = (await self._skip_bootloader()).Capabilities
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 723, in _skip_bootloader
    return await self.request(c.SYS.Ping.Req())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/zigpy_znp/api.py", line 1075, in request
    async with asyncio_timeout(
               ~~~~~~~~~~~~~~~^
        timeout or self._znp_config[conf.CONF_SREQ_TIMEOUT]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ):
    ^
  File "/usr/lib/python3.13/asyncio/timeouts.py", line 116, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

a-baturin avatar May 10 '25 17:05 a-baturin

Or with -v

zigpy.log

a-baturin avatar May 10 '25 18:05 a-baturin

I would take a look at the kernel diff between those two versions, specifically for the CH340/341 drivers. From the zigpy side, the serial port is there and functional, your device just isn't responding.

puddly avatar May 10 '25 18:05 puddly

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

I have same problem with onboard usb - serial on Homeassistant OS installed on a generic MiniPc with onboard leds (Acemagic T9). Not in zha but I was able to control leds from python script. It was working since some months ago but stopped working with kernel update.

Can you help? Thank you!

DjMayone avatar Aug 11 '25 07:08 DjMayone

Some development. Kernel 6.16.6-arch1-1 Same command as before now works

(homeassistant) [homeassistant@ha-server homeassistant]$ python -m zigpy_znp.tools.energy_scan /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 
2025-09-12 11:14:14.005 ha-server __main__ INFO Starting up zigpy-znp
2025-09-12 11:14:19.463 ha-server zigpy.device INFO [0x0000] Requesting 'Node Descriptor'
2025-09-12 11:14:19.485 ha-server zigpy.device INFO [0x0000] Got Node Descriptor: NodeDescriptor(logical_type=<LogicalType.Coordinator: 0>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AlternatePanCoordinator|FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 143>, manufacturer_code=0, maximum_buffer_size=80, maximum_incoming_transfer_size=160, server_mask=11265, maximum_outgoing_transfer_size=160, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=True, *is_coordinator=True, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=False, *is_security_capable=False)
2025-09-12 11:14:19.487 ha-server zigpy.device INFO [0x0000] Discovering endpoints
2025-09-12 11:14:19.504 ha-server zigpy.device INFO [0x0000] Discovered endpoints: [2, 1]
2025-09-12 11:14:19.505 ha-server zigpy.device INFO [0x0000] Initializing endpoints [<Endpoint id=2 in=[] out=[] status=<Status.NEW: 0>>, <Endpoint id=1 in=[] out=[] status=<Status.NEW: 0>>]
2025-09-12 11:14:19.505 ha-server zigpy.endpoint INFO [0x0000:2] Discovering endpoint information
2025-09-12 11:14:19.525 ha-server zigpy.endpoint INFO [0x0000:2] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=2, profile=49246, device_type=2080, device_version=0, input_clusters=[0], output_clusters=[])
2025-09-12 11:14:19.526 ha-server zigpy.endpoint INFO [0x0000:1] Discovering endpoint information
2025-09-12 11:14:19.549 ha-server zigpy.endpoint INFO [0x0000:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=1024, device_version=0, input_clusters=[0, 6, 10, 25, 1281], output_clusters=[1, 32, 1280, 1282])
2025-09-12 11:14:19.551 ha-server zigpy.device INFO [0x0000] Already have model and manufacturer info
2025-09-12 11:14:19.551 ha-server zigpy.device INFO [0x0000] Discovered basic device information for <ZNPCoordinator model='Coordinator' manuf='Texas Instruments' nwk=0x0000 ieee=00:12:4b:00:22:98:1e:03 is_initialized=True>
2025-09-12 11:14:19.552 ha-server __main__ INFO Running scan...
Channel energy (mean of 1 / 5):
------------------------------------------------
 + Lower energy is better
 + Active Zigbee networks on a channel may still cause congestion
 + TX on 26 in North America may be with lower power due to regulations
 + Zigbee channels 15, 20, 25 fall between WiFi channels 1, 6, 11
 + Some Zigbee devices only join networks on channels 15, 20, and 25
------------------------------------------------
 - 11    17.65%  #################
 - 12    10.59%  ##########
 - 13     2.35%  ##
 - 14     0.00%  
 - 15     0.00%  
 - 16     0.00%  
 - 17     0.00%  
 - 18     0.00%  
 - 19     0.00%  
 - 20    11.76%  ###########
 - 21    34.12%  ##################################
 - 22    21.18%  #####################
 - 23     0.00%  
 - 24     0.00%  
 - 25     0.00%  
 - 26*    0.00%  

But HA still does not

a-baturin avatar Sep 12 '25 09:09 a-baturin

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.