Skip to content

Commit 037e2bf

Browse files
TheJulianJESfrenck
authored andcommitted
Fix ZHA unable to select "none" flow control (home-assistant#153235)
1 parent c893552 commit 037e2bf

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

homeassistant/components/zha/config_flow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ async def async_step_manual_port_config(
320320
}
321321
)
322322

323-
if await self._radio_mgr.radio_type.controller.probe(user_input):
323+
if await self._radio_mgr.radio_type.controller.probe(
324+
self._radio_mgr.device_settings
325+
):
324326
return await self.async_step_verify_radio()
325327

326328
errors["base"] = "cannot_connect"

tests/components/zha/test_config_flow.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,14 @@ async def test_options_flow_creates_backup(
20352035
@pytest.mark.parametrize(
20362036
"async_unload_effect", [True, config_entries.OperationNotAllowed()]
20372037
)
2038+
@pytest.mark.parametrize(
2039+
("input_flow_control", "conf_flow_control"),
2040+
[
2041+
("hardware", "hardware"),
2042+
("software", "software"),
2043+
("none", None),
2044+
],
2045+
)
20382046
@patch(
20392047
"serial.tools.list_ports.comports",
20402048
MagicMock(
@@ -2047,7 +2055,11 @@ async def test_options_flow_creates_backup(
20472055
)
20482056
@patch("homeassistant.components.zha.async_setup_entry", return_value=True)
20492057
async def test_options_flow_defaults(
2050-
async_setup_entry, async_unload_effect, hass: HomeAssistant
2058+
async_setup_entry,
2059+
async_unload_effect,
2060+
input_flow_control,
2061+
conf_flow_control,
2062+
hass: HomeAssistant,
20512063
) -> None:
20522064
"""Test options flow defaults match radio defaults."""
20532065

@@ -2127,17 +2139,29 @@ async def test_options_flow_defaults(
21272139
"flow_control": "none",
21282140
}
21292141

2130-
with patch(f"zigpy_znp.{PROBE_FUNCTION_PATH}", AsyncMock(return_value=True)):
2142+
with patch(
2143+
f"zigpy_znp.{PROBE_FUNCTION_PATH}", AsyncMock(return_value=True)
2144+
) as mock_probe:
21312145
# Change the serial port path
21322146
result5 = await hass.config_entries.options.async_configure(
21332147
flow["flow_id"],
21342148
user_input={
21352149
# Change everything
21362150
CONF_DEVICE_PATH: "/dev/new_serial_port",
21372151
CONF_BAUDRATE: 54321,
2138-
CONF_FLOW_CONTROL: "software",
2152+
CONF_FLOW_CONTROL: input_flow_control,
21392153
},
21402154
)
2155+
# verify we passed the correct flow control to the probe function
2156+
assert mock_probe.mock_calls == [
2157+
call(
2158+
{
2159+
"path": "/dev/new_serial_port",
2160+
"baudrate": 54321,
2161+
"flow_control": conf_flow_control,
2162+
}
2163+
)
2164+
]
21412165

21422166
# The radio has been detected, we can move on to creating the config entry
21432167
assert result5["step_id"] == "choose_migration_strategy"
@@ -2164,7 +2188,7 @@ async def test_options_flow_defaults(
21642188
CONF_DEVICE: {
21652189
CONF_DEVICE_PATH: "/dev/new_serial_port",
21662190
CONF_BAUDRATE: 54321,
2167-
CONF_FLOW_CONTROL: "software",
2191+
CONF_FLOW_CONTROL: conf_flow_control,
21682192
},
21692193
CONF_RADIO_TYPE: "znp",
21702194
}

0 commit comments

Comments
 (0)