From 2bc91e7a3e8b9e3b3bd7eb4df3605c1dceb40bf3 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Tue, 26 May 2026 20:15:43 +0200 Subject: [PATCH] Filter unsupported soundbar devices for SamsungTV (#172126) --- homeassistant/components/samsungtv/config_flow.py | 6 ++++++ tests/components/samsungtv/test_config_flow.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/homeassistant/components/samsungtv/config_flow.py b/homeassistant/components/samsungtv/config_flow.py index 3d5b3429d5f..3c0a4979d79 100644 --- a/homeassistant/components/samsungtv/config_flow.py +++ b/homeassistant/components/samsungtv/config_flow.py @@ -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() diff --git a/tests/components/samsungtv/test_config_flow.py b/tests/components/samsungtv/test_config_flow.py index be016ed6021..4c78e7e2762 100644 --- a/tests/components/samsungtv/test_config_flow.py +++ b/tests/components/samsungtv/test_config_flow.py @@ -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."""