From d0cc7fae06cf2bfc82ea1d78d47f0a656f0db28e Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Sun, 8 Nov 2026 12:10:57 +0100 Subject: [PATCH] Remove getmac from Samsung TV (#191213) --- homeassistant/components/samsungtv/__init__.py | 8 -------- homeassistant/components/samsungtv/config_flow.py | 12 ++---------- homeassistant/components/samsungtv/manifest.json | 1 - requirements_all.txt | 1 - tests/components/samsungtv/conftest.py | 7 ------- tests/components/samsungtv/test_config_flow.py | 10 ++++------ 6 files changed, 6 insertions(+), 33 deletions(-) diff --git a/homeassistant/components/samsungtv/__init__.py b/homeassistant/components/samsungtv/__init__.py index e06fb4bd6dc5..db3a1160fe4f 100644 --- a/homeassistant/components/samsungtv/__init__.py +++ b/homeassistant/components/samsungtv/__init__.py @@ -1,12 +1,9 @@ """The Samsung TV integration.""" from collections.abc import Coroutine, Mapping -from functools import partial from typing import Any from urllib.parse import urlparse -import getmac - from homeassistant.components import ssdp from homeassistant.const import ( CONF_HOST, @@ -186,11 +183,6 @@ async def _async_create_bridge_with_updated_data( if info: mac = mac_from_device_info(info) - if not mac: - mac = await hass.async_add_executor_job( - partial(getmac.get_mac_address, ip=host) - ) - if mac and mac != "none": # Samsung sometimes returns a value of "none" for the mac address # this should be ignored diff --git a/homeassistant/components/samsungtv/config_flow.py b/homeassistant/components/samsungtv/config_flow.py index c5156ede19e9..a2450623af6e 100644 --- a/homeassistant/components/samsungtv/config_flow.py +++ b/homeassistant/components/samsungtv/config_flow.py @@ -1,12 +1,10 @@ """Config flow for Samsung TV.""" from collections.abc import Mapping -from functools import partial import socket from typing import Any, Self, override from urllib.parse import urlparse -import getmac import probatio from samsungtvws.encrypted.authenticator import SamsungTVEncryptedWSAsyncAuthenticator @@ -250,14 +248,8 @@ class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN): self._name = name.replace("[TV] ", "") if name else device_type self._title = f"{self._name} ({self._model})" self._udn = _strip_uuid(dev_info.get("udn", info["id"])) - if mac := mac_from_device_info(info): - # Samsung sometimes returns a value of "none" for the mac address - # this should be ignored - but also shouldn't trigger getmac - if mac != "none": - self._mac = mac - elif mac := await self.hass.async_add_executor_job( - partial(getmac.get_mac_address, ip=self._host) - ): + # Samsung sometimes returns a value of "none" for the mac address + if (mac := mac_from_device_info(info)) and mac != "none": self._mac = mac return True diff --git a/homeassistant/components/samsungtv/manifest.json b/homeassistant/components/samsungtv/manifest.json index 42fe20e047d6..aca6f18fce8d 100644 --- a/homeassistant/components/samsungtv/manifest.json +++ b/homeassistant/components/samsungtv/manifest.json @@ -38,7 +38,6 @@ "loggers": ["samsungtvws"], "quality_scale": "gold", "requirements": [ - "getmac==0.9.6", "samsungtvws[async,encrypted]==3.0.7", "async-upnp-client==0.49.0" ], diff --git a/requirements_all.txt b/requirements_all.txt index 6a0aae71e905..92fdb07bf500 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1169,7 +1169,6 @@ georss-qld-bushfire-alert-client==0.8 # homeassistant.components.dlna_dmr # homeassistant.components.kef # homeassistant.components.nmap_tracker -# homeassistant.components.samsungtv # homeassistant.components.upnp getmac==0.9.6 diff --git a/tests/components/samsungtv/conftest.py b/tests/components/samsungtv/conftest.py index aa880fd19773..84017f26a91c 100644 --- a/tests/components/samsungtv/conftest.py +++ b/tests/components/samsungtv/conftest.py @@ -287,10 +287,3 @@ def remote_encrypted_websocket_fixture() -> Generator[Mock]: ) as remotews_class: remotews_class.return_value = remote_encrypted_websocket yield remote_encrypted_websocket - - -@pytest.fixture(name="mac_address", autouse=True) -def mac_address_fixture() -> Generator[Mock]: - """Patch getmac.get_mac_address.""" - with patch("getmac.get_mac_address", return_value=None) as mac: - yield mac diff --git a/tests/components/samsungtv/test_config_flow.py b/tests/components/samsungtv/test_config_flow.py index dffe6dc8f26d..0491cff99a61 100644 --- a/tests/components/samsungtv/test_config_flow.py +++ b/tests/components/samsungtv/test_config_flow.py @@ -1386,10 +1386,8 @@ async def test_autodetect_websocket(hass: HomeAssistant) -> None: @pytest.mark.usefixtures("remote_encrypted_websocket_failing") -async def test_websocket_no_mac(hass: HomeAssistant, mac_address: Mock) -> None: - """Test for send key with autodetection of protocol.""" - mac_address.return_value = "gg:ee:tt:mm:aa:cc" - +async def test_websocket_no_mac(hass: HomeAssistant) -> None: + """Test websocket setup when the device info has no mac address.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) @@ -1434,7 +1432,7 @@ async def test_websocket_no_mac(hass: HomeAssistant, mac_address: Mock) -> None: assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"][CONF_METHOD] == "websocket" assert result["data"][CONF_TOKEN] == "123456789" - assert result["data"][CONF_MAC] == "gg:ee:tt:mm:aa:cc" + assert result["data"][CONF_MAC] is None assert result["data"][CONF_PORT] == 8002 remote_websocket.assert_called_once_with(**AUTODETECT_WEBSOCKET_SSL) rest_api_class.assert_called_once_with(**DEVICEINFO_WEBSOCKET_SSL) @@ -1442,7 +1440,7 @@ async def test_websocket_no_mac(hass: HomeAssistant, mac_address: Mock) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 - assert entries[0].data[CONF_MAC] == "gg:ee:tt:mm:aa:cc" + assert entries[0].data[CONF_MAC] is None @pytest.mark.usefixtures("rest_api_failing")