From 3dc478a3579ebd17ceaf82bf7a3020ca3910a173 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 25 Mar 2026 02:11:38 -0400 Subject: [PATCH] Filter out WiiM devices from LinkPlay discovery (#166436) --- .../components/linkplay/config_flow.py | 4 ++++ .../components/linkplay/strings.json | 3 ++- tests/components/linkplay/conftest.py | 1 + tests/components/linkplay/test_config_flow.py | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/linkplay/config_flow.py b/homeassistant/components/linkplay/config_flow.py index 266d2fef857..9cf61ee8d66 100644 --- a/homeassistant/components/linkplay/config_flow.py +++ b/homeassistant/components/linkplay/config_flow.py @@ -7,6 +7,7 @@ from aiohttp import ClientSession from linkplay.bridge import LinkPlayBridge from linkplay.discovery import linkplay_factory_httpapi_bridge from linkplay.exceptions import LinkPlayRequestException +from linkplay.manufacturers import MANUFACTURER_WIIM import voluptuous as vol from homeassistant.config_entries import ConfigFlow, ConfigFlowResult @@ -45,6 +46,9 @@ class LinkPlayConfigFlow(ConfigFlow, domain=DOMAIN): ) return self.async_abort(reason="cannot_connect") + if bridge.device.manufacturer == MANUFACTURER_WIIM: + return self.async_abort(reason="not_linkplay_device") + self.data[CONF_HOST] = discovery_info.host self.data[CONF_MODEL] = bridge.device.name diff --git a/homeassistant/components/linkplay/strings.json b/homeassistant/components/linkplay/strings.json index 0cf28a2f98c..888d1100545 100644 --- a/homeassistant/components/linkplay/strings.json +++ b/homeassistant/components/linkplay/strings.json @@ -2,7 +2,8 @@ "config": { "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", - "already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]" + "already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]", + "not_linkplay_device": "This device should be set up with the WiiM integration." }, "error": { "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", diff --git a/tests/components/linkplay/conftest.py b/tests/components/linkplay/conftest.py index 81ae993f6c3..b0b68390810 100644 --- a/tests/components/linkplay/conftest.py +++ b/tests/components/linkplay/conftest.py @@ -41,6 +41,7 @@ def mock_linkplay_factory_bridge() -> Generator[AsyncMock]: bridge.device = AsyncMock(spec=LinkPlayDevice) bridge.device.uuid = UUID bridge.device.name = NAME + bridge.device.manufacturer = "Linkplay" conf_factory.return_value = bridge yield conf_factory diff --git a/tests/components/linkplay/test_config_flow.py b/tests/components/linkplay/test_config_flow.py index 8c0dd4af88b..b2f7b34434b 100644 --- a/tests/components/linkplay/test_config_flow.py +++ b/tests/components/linkplay/test_config_flow.py @@ -4,6 +4,7 @@ from ipaddress import ip_address from unittest.mock import AsyncMock from linkplay.exceptions import LinkPlayRequestException +from linkplay.manufacturers import MANUFACTURER_WIIM import pytest from homeassistant.components.linkplay.const import DOMAIN @@ -179,6 +180,24 @@ async def test_zeroconf_flow_errors( assert result["reason"] == "cannot_connect" +@pytest.mark.usefixtures("mock_setup_entry") +async def test_zeroconf_flow_ignores_wiim_device( + hass: HomeAssistant, + mock_linkplay_factory_bridge: AsyncMock, +) -> None: + """Test Zeroconf discovery is ignored for WiiM devices.""" + mock_linkplay_factory_bridge.return_value.device.manufacturer = MANUFACTURER_WIIM + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data=ZEROCONF_DISCOVERY, + ) + + assert result["type"] is FlowResultType.ABORT + assert result["reason"] == "not_linkplay_device" + + @pytest.mark.usefixtures("mock_setup_entry") async def test_user_flow_errors( hass: HomeAssistant,