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 govee-ble devices to be set up from the user flow #137052

Merged
merged 5 commits into from
Feb 1, 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/govee_ble/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def async_step_user(
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:
Expand Down
32 changes: 32 additions & 0 deletions tests/components/govee_ble/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 == "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(
Expand Down