Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 1 addition & 46 deletions tests/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
zigpy_device_from_json,
)
from zha.application import Platform
from zha.application.const import (
CONF_USE_THREAD,
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,
Expand Down Expand Up @@ -437,46 +432,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", False, {}),
("socket://192.168.1.123:9999", True, {"use_thread": True}),
],
)
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 disabling the UART thread when connecting to a TCP coordinator."""
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,
Expand Down
10 changes: 0 additions & 10 deletions zha/application/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

from zha.application import discovery
from zha.application.const import (
CONF_USE_THREAD,
UNKNOWN_MANUFACTURER,
UNKNOWN_MODEL,
ZHA_GW_MSG,
Expand Down Expand Up @@ -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
Expand Down
Loading