Allow ignored govee-ble devices to be set up from the user flow (#137052)

* Allow ignored govee-ble devices to be setup up from the user flow

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. Allow ignored devices to be selected in
the user step and replace the ignored entry.

* Add the ability to skip ignored config entries when calling _abort_if_unique_id_configured

see https://github.com/home-assistant/core/pull/137052

* coverage

* revert
This commit is contained in:
J. Nick Koston 2025-01-31 20:24:01 -06:00 committed by GitHub
parent 5da9bfe0e3
commit 84e15e10ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 1 deletions

View File

@ -78,7 +78,7 @@ class GoveeConfigFlow(ConfigFlow, domain=DOMAIN):
title=title, data={CONF_DEVICE_TYPE: device.device_type}
)
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:

View File

@ -79,6 +79,38 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
assert result2["result"].unique_id == "4125DDBA-2774-4851-9889-6AADDD4CAC3D"
async def test_async_step_user_replace_ignored_device(hass: HomeAssistant) -> None:
"""Test setup user step can replace an ignored device."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=GVH5177_SERVICE_INFO.address,
data={},
source=config_entries.SOURCE_IGNORE,
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.govee_ble.config_flow.async_discovered_service_info",
return_value=[GVH5177_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.govee_ble.async_setup_entry", return_value=True
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "4125DDBA-2774-4851-9889-6AADDD4CAC3D"},
)
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "H5177 2EC8"
assert result2["data"] == {CONF_DEVICE_TYPE: "H5177"}
assert result2["result"].unique_id == "4125DDBA-2774-4851-9889-6AADDD4CAC3D"
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(