Allow ignored screenlogic devices to be set up from the user flow (#137315)
Allow ignored ScreenLogic devices to be set up from the user flowpull/137390/head
parent
48c88d8fa1
commit
8de64b8b1f
|
@ -105,7 +105,7 @@ class ScreenlogicConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def async_step_gateway_select(self, user_input=None) -> ConfigFlowResult:
|
||||
"""Handle the selection of a discovered ScreenLogic gateway."""
|
||||
existing = self._async_current_ids()
|
||||
existing = self._async_current_ids(include_ignore=False)
|
||||
unconfigured_gateways = {
|
||||
mac: gateway[SL_GATEWAY_NAME]
|
||||
for mac, gateway in self.discovered_gateways.items()
|
||||
|
|
|
@ -86,6 +86,53 @@ async def test_flow_discover_none(hass: HomeAssistant) -> None:
|
|||
assert result["step_id"] == "gateway_entry"
|
||||
|
||||
|
||||
async def test_flow_replace_ignored(hass: HomeAssistant) -> None:
|
||||
"""Test we can replace ignored entries."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id="00:c0:33:01:01:01",
|
||||
source=config_entries.SOURCE_IGNORE,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
|
||||
return_value=[
|
||||
{
|
||||
SL_GATEWAY_IP: "1.1.1.1",
|
||||
SL_GATEWAY_PORT: 80,
|
||||
SL_GATEWAY_TYPE: 12,
|
||||
SL_GATEWAY_SUBTYPE: 2,
|
||||
SL_GATEWAY_NAME: "Pentair: 01-01-01",
|
||||
},
|
||||
],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "gateway_select"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={GATEWAY_SELECT_KEY: "00:c0:33:01:01:01"}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Pentair: 01-01-01"
|
||||
assert result2["data"] == {
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
CONF_PORT: 80,
|
||||
}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_flow_discover_error(hass: HomeAssistant) -> None:
|
||||
"""Test when discovery errors."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue