mirror of
https://github.com/home-assistant/core.git
synced 2026-05-30 20:24:21 +01:00
Filter unsupported soundbar devices for SamsungTV (#172126)
This commit is contained in:
@@ -537,6 +537,12 @@ class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by zeroconf discovery."""
|
||||
LOGGER.debug("Samsung device found via ZEROCONF: %s", discovery_info)
|
||||
if "Soundbar" in discovery_info.name:
|
||||
LOGGER.debug(
|
||||
"Ignoring Samsung Soundbar found via Zeroconf: %s", discovery_info
|
||||
)
|
||||
return self.async_abort(reason="not_supported")
|
||||
|
||||
self._mac = format_mac(discovery_info.properties["deviceid"])
|
||||
self._host = discovery_info.host
|
||||
self._async_start_discovery_with_mac_address()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Tests for Samsung TV config flow."""
|
||||
|
||||
from copy import deepcopy
|
||||
import dataclasses
|
||||
from ipaddress import ip_address
|
||||
import socket
|
||||
from unittest.mock import ANY, AsyncMock, Mock, call, patch
|
||||
@@ -1037,6 +1038,20 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
|
||||
|
||||
async def test_zeroconf_ignores_soundbar_by_name(hass: HomeAssistant) -> None:
|
||||
"""Test zeroconf flow aborts early when the service name contains 'Soundbar'."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=dataclasses.replace(
|
||||
MOCK_ZEROCONF_DATA, name="Q-Series Soundbar._airplay._tcp.local."
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remote_websocket", "remote_encrypted_websocket_failing")
|
||||
async def test_zeroconf_ignores_soundbar(hass: HomeAssistant, rest_api: Mock) -> None:
|
||||
"""Test starting a flow from zeroconf where the device is actually a soundbar."""
|
||||
|
||||
Reference in New Issue
Block a user