From 6fc764330f0a15c291e62df186c3f88a87c3c191 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 19 Feb 2024 02:58:32 -0600 Subject: [PATCH] Fix steamist not setting unique id when discovered in user flow (#110915) --- homeassistant/components/steamist/config_flow.py | 3 +++ tests/components/steamist/test_config_flow.py | 1 + 2 files changed, 4 insertions(+) diff --git a/homeassistant/components/steamist/config_flow.py b/homeassistant/components/steamist/config_flow.py index f182189a9c7..3d5fe000f35 100644 --- a/homeassistant/components/steamist/config_flow.py +++ b/homeassistant/components/steamist/config_flow.py @@ -170,6 +170,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors["base"] = "unknown" else: if discovery := await async_discover_device(self.hass, host): + await self.async_set_unique_id( + dr.format_mac(discovery.mac), raise_on_progress=False + ) return self._async_create_entry_from_device(discovery) self._async_abort_entries_match({CONF_HOST: host}) return self.async_create_entry(title=host, data=user_input) diff --git a/tests/components/steamist/test_config_flow.py b/tests/components/steamist/test_config_flow.py index 63785b006e0..9664eb7323f 100644 --- a/tests/components/steamist/test_config_flow.py +++ b/tests/components/steamist/test_config_flow.py @@ -91,6 +91,7 @@ async def test_form_with_discovery(hass: HomeAssistant) -> None: assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["title"] == DEVICE_NAME assert result2["data"] == DEFAULT_ENTRY_DATA + assert result2["context"]["unique_id"] == FORMATTED_MAC_ADDRESS assert len(mock_setup_entry.mock_calls) == 1