diff --git a/homeassistant/components/zha/config_flow.py b/homeassistant/components/zha/config_flow.py index 473d39c6f7a..f59f53c7995 100644 --- a/homeassistant/components/zha/config_flow.py +++ b/homeassistant/components/zha/config_flow.py @@ -45,6 +45,10 @@ class ZhaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): + (f" - {p.manufacturer}" if p.manufacturer else "") for p in ports ] + + if not list_of_ports: + return await self.async_step_pick_radio() + list_of_ports.append(CONF_MANUAL_PATH) if user_input is not None: diff --git a/tests/components/zha/test_config_flow.py b/tests/components/zha/test_config_flow.py index fe65def839d..b3dbefbdbf0 100644 --- a/tests/components/zha/test_config_flow.py +++ b/tests/components/zha/test_config_flow.py @@ -74,6 +74,7 @@ async def test_user_flow_not_detected(detect_mock, hass): assert detect_mock.await_args[0][0] == port.device +@patch("serial.tools.list_ports.comports", MagicMock(return_value=[com_port()])) async def test_user_flow_show_form(hass): """Test user step form.""" result = await hass.config_entries.flow.async_init( @@ -85,6 +86,17 @@ async def test_user_flow_show_form(hass): assert result["step_id"] == "user" +async def test_user_flow_show_manual(hass): + """Test user flow manual entry when no comport detected.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + ) + + assert result["type"] == RESULT_TYPE_FORM + assert result["step_id"] == "pick_radio" + + async def test_user_flow_manual(hass): """Test user flow manual entry."""