Remove getmac from Samsung TV (#191213)

This commit is contained in:
Simone Chemelli
2026-11-08 12:10:57 +01:00
committed by GitHub
parent 37b21e5b49
commit d0cc7fae06
6 changed files with 6 additions and 33 deletions
@@ -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
@@ -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
@@ -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"
],
-1
View File
@@ -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
-7
View File
@@ -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
@@ -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")