Skip to content

Commit

Permalink
Allow ignored thermobeacon devices to be set up from the user flow (h…
Browse files Browse the repository at this point in the history
…ome-assistant#139009)

Every few days we get an issue report about a device a user ignored and forgot about, and than can no longer get set up. Sometimes its a govee device, sometimes its a switchbot device, but the pattern is consistent.

Allow ignored devices to be selected in the user step and replace the ignored entry.

Same as home-assistant#137056 and home-assistant#137052 but for thermobeacon
  • Loading branch information
bdraco authored Feb 21, 2025
1 parent 2bd9918 commit 8078e41
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion homeassistant/components/thermobeacon/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def async_step_user(
title=self._discovered_devices[address], data={}
)

current_addresses = self._async_current_ids()
current_addresses = self._async_current_ids(include_ignore=False)
for discovery_info in async_discovered_service_info(self.hass, False):
address = discovery_info.address
if address in current_addresses or address in self._discovered_devices:
Expand Down
32 changes: 32 additions & 0 deletions tests/components/thermobeacon/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,38 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"


async def test_async_step_user_replace_ignored(hass: HomeAssistant) -> None:
"""Test setup from service info can replace an ignored entry."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=THERMOBEACON_SERVICE_INFO.address,
data={},
source=config_entries.SOURCE_IGNORE,
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.thermobeacon.config_flow.async_discovered_service_info",
return_value=[THERMOBEACON_SERVICE_INFO],
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
"homeassistant.components.thermobeacon.async_setup_entry", return_value=True
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Lanyard/mini hygrometer EEFF"
assert result2["data"] == {}
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"


async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -> None:
"""Test the device gets added via another flow between steps."""
with patch(
Expand Down

0 comments on commit 8078e41

Please sign in to comment.