Activate manual ZHA config flow when no comports detected (#46077)

This commit is contained in:
Franck Nijhof 2021-02-05 23:23:47 +01:00 committed by GitHub
parent 434b4dfa58
commit 67392338da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -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:

View File

@ -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."""