From a07048c1a220ccbb45ec5645218cc792670e0d20 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 18:42:29 +0000 Subject: [PATCH 1/4] Initial plan From b7fb5ed401b2596c0ed436087790e041c8852cb8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 18:47:13 +0000 Subject: [PATCH 2/4] Remove CONF_USE_THREAD override for socket:// connections Co-authored-by: puddly <32534428+puddly@users.noreply.github.com> --- tests/test_gateway.py | 6 +++--- zha/application/gateway.py | 10 ---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/tests/test_gateway.py b/tests/test_gateway.py index 7a6771ae6..1dca287b3 100644 --- a/tests/test_gateway.py +++ b/tests/test_gateway.py @@ -449,8 +449,8 @@ async def test_remove_device_cleans_up_group_membership( ("device_path", "thread_state", "config_override"), [ ("/dev/ttyUSB0", True, {}), - ("socket://192.168.1.123:9999", False, {}), - ("socket://192.168.1.123:9999", True, {"use_thread": True}), + ("socket://192.168.1.123:9999", True, {}), + ("socket://192.168.1.123:9999", False, {"use_thread": False}), ], ) async def test_gateway_initialize_bellows_thread( @@ -460,7 +460,7 @@ async def test_gateway_initialize_bellows_thread( zigpy_app_controller: ControllerApplication, zha_data: ZHAData, ) -> None: - """Test ZHA disabling the UART thread when connecting to a TCP coordinator.""" + """Test ZHA thread configuration when connecting to coordinators.""" zha_data.config.coordinator_configuration.path = device_path zha_data.zigpy_config = config_override diff --git a/zha/application/gateway.py b/zha/application/gateway.py index d6bff81a8..8761fb843 100644 --- a/zha/application/gateway.py +++ b/zha/application/gateway.py @@ -33,7 +33,6 @@ from zha.application import discovery from zha.application.const import ( - CONF_USE_THREAD, UNKNOWN_MANUFACTURER, UNKNOWN_MODEL, ZHA_GW_MSG, @@ -216,15 +215,6 @@ def get_application_controller_data(self) -> tuple[ControllerApplication, dict]: if CONF_NWK_VALIDATE_SETTINGS not in app_config: app_config[CONF_NWK_VALIDATE_SETTINGS] = True - # The bellows UART thread sometimes propagates a cancellation into the main Core - # event loop, when a connection to a TCP coordinator fails in a specific way - if ( - CONF_USE_THREAD not in app_config - and self.radio_type is RadioType.ezsp - and app_config[CONF_DEVICE][CONF_DEVICE_PATH].startswith("socket://") - ): - app_config[CONF_USE_THREAD] = False - return self.radio_type.controller, app_config @classmethod From 7b14e82676a70e96ac83f54a5f1e06c4178b35dd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 05:11:21 +0000 Subject: [PATCH 3/4] Remove test_gateway_initialize_bellows_thread test Co-authored-by: puddly <32534428+puddly@users.noreply.github.com> --- tests/test_gateway.py | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/tests/test_gateway.py b/tests/test_gateway.py index 1dca287b3..1378ec0e3 100644 --- a/tests/test_gateway.py +++ b/tests/test_gateway.py @@ -26,7 +26,6 @@ ) from zha.application import Platform from zha.application.const import ( - CONF_USE_THREAD, ZHA_GW_MSG, ZHA_GW_MSG_CONNECTION_LOST, RadioType, @@ -437,46 +436,6 @@ async def test_remove_device_cleans_up_group_membership( assert device_light_1.ieee not in zha_gateway.devices -@patch( - "zha.application.gateway.Gateway.load_devices", - AsyncMock(), -) -@patch( - "zha.application.gateway.Gateway.load_groups", - MagicMock(), -) -@pytest.mark.parametrize( - ("device_path", "thread_state", "config_override"), - [ - ("/dev/ttyUSB0", True, {}), - ("socket://192.168.1.123:9999", True, {}), - ("socket://192.168.1.123:9999", False, {"use_thread": False}), - ], -) -async def test_gateway_initialize_bellows_thread( - device_path: str, - thread_state: bool, - config_override: dict, - zigpy_app_controller: ControllerApplication, - zha_data: ZHAData, -) -> None: - """Test ZHA thread configuration when connecting to coordinators.""" - zha_data.config.coordinator_configuration.path = device_path - zha_data.zigpy_config = config_override - - with patch( - "bellows.zigbee.application.ControllerApplication.new", - return_value=zigpy_app_controller, - ) as mock_new: - zha_gw = Gateway(zha_data) - await zha_gw.async_initialize() - assert ( - mock_new.mock_calls[-1].kwargs["config"].get(CONF_USE_THREAD, True) - is thread_state - ) - await zha_gw.shutdown() - - @pytest.mark.parametrize("radio_concurrency", [1, 2, 8]) async def test_startup_concurrency_limit( radio_concurrency: int, From d81e164860a0f0d163d3ff2e5eac9152f7403a4c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 05:17:32 +0000 Subject: [PATCH 4/4] Apply pre-commit auto fixes Co-authored-by: puddly <32534428+puddly@users.noreply.github.com> --- tests/test_gateway.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test_gateway.py b/tests/test_gateway.py index 1378ec0e3..677955e71 100644 --- a/tests/test_gateway.py +++ b/tests/test_gateway.py @@ -25,11 +25,7 @@ zigpy_device_from_json, ) from zha.application import Platform -from zha.application.const import ( - ZHA_GW_MSG, - ZHA_GW_MSG_CONNECTION_LOST, - RadioType, -) +from zha.application.const import ZHA_GW_MSG, ZHA_GW_MSG_CONNECTION_LOST, RadioType from zha.application.gateway import ( ConnectionLostEvent, DeviceJoinedDeviceInfo,