mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 00:20:30 +01:00
Filter out WiiM devices from LinkPlay discovery (#166436)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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%]",
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user