Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ignored screenlogic devices to be set up from the user flow #137315

Merged
merged 2 commits into from
Feb 4, 2025
Merged
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
2 changes: 1 addition & 1 deletion homeassistant/components/screenlogic/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def async_step_dhcp(

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()
Expand Down
47 changes: 47 additions & 0 deletions tests/components/screenlogic/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down