Cleanup deprecated wake-on-lan for SamsungTV (#182771)

This commit is contained in:
Simone Chemelli
2026-09-22 16:29:34 +02:00
committed by GitHub
parent f50d777440
commit 3bc9cf09eb
8 changed files with 26 additions and 70 deletions
+11 -37
View File
@@ -2,8 +2,6 @@
from typing import Any, override
from wakeonlan import send_magic_packet
from homeassistant.const import (
ATTR_CONNECTIONS,
ATTR_IDENTIFIERS,
@@ -12,7 +10,7 @@ from homeassistant.const import (
CONF_MODEL,
)
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, issue_registry as ir
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.trigger import PluggableAction
@@ -22,8 +20,6 @@ from .const import CONF_MANUFACTURER, DOMAIN, LOGGER
from .coordinator import SamsungTVDataUpdateCoordinator
from .triggers.turn_on import async_get_turn_on_trigger
DEPRECATED_IMPLICIT_WAKE_ON_LAN = "deprecated_implicit_wake_on_lan_{}"
class SamsungTVEntity(CoordinatorEntity[SamsungTVDataUpdateCoordinator], Entity):
"""Defines a base SamsungTV entity."""
@@ -77,13 +73,6 @@ class SamsungTVEntity(CoordinatorEntity[SamsungTVDataUpdateCoordinator], Entity)
)
)
def _wake_on_lan(self) -> None:
"""Wake the device via wake on lan."""
send_magic_packet(self._mac, ip_address=self._host) # type: ignore[arg-type]
# If the ip address changed since we last saw the device
# broadcast a packet as well
send_magic_packet(self._mac) # type: ignore[arg-type]
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
await self._bridge.async_power_off()
@@ -94,28 +83,13 @@ class SamsungTVEntity(CoordinatorEntity[SamsungTVDataUpdateCoordinator], Entity)
if self._turn_on_action:
LOGGER.debug("Attempting to turn on %s via automation", self.entity_id)
await self._turn_on_action.async_run(self.hass, self._context)
elif self._mac:
ir.async_create_issue(
self.hass,
DOMAIN,
DEPRECATED_IMPLICIT_WAKE_ON_LAN.format(self._mac),
is_fixable=False,
breaks_in_ha_version="2026.8.0",
severity=ir.IssueSeverity.WARNING,
translation_key="deprecated_implicit_wake_on_lan",
translation_placeholders={
"mac_address": self._mac,
"wol_documentation_url": "https://www.home-assistant.io/integrations/wake_on_lan/",
},
)
await self.hass.async_add_executor_job(self._wake_on_lan)
else:
LOGGER.error(
"Unable to turn on %s, as it does not have an automation configured",
self.entity_id,
)
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="service_unsupported",
translation_placeholders={"entity": self.entity_id},
)
return
LOGGER.error(
"Unable to turn on %s, as it does not have an automation configured",
self.entity_id,
)
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="service_unsupported",
translation_placeholders={"entity": self.entity_id},
)
@@ -39,7 +39,6 @@
"getmac==0.9.5",
"samsungctl[websocket]==0.7.1",
"samsungtvws[async,encrypted]==3.0.6",
"wakeonlan==3.3.0",
"async-upnp-client==0.48.2"
],
"ssdp": [
@@ -94,10 +94,6 @@ class SamsungTVDevice(SamsungTVEntity, MediaPlayerEntity):
self._app_list_event: asyncio.Event = asyncio.Event()
self._attr_supported_features = SUPPORT_SAMSUNGTV
if self._mac:
# Deprecated: Implicit Wake-On-LAN, will be removed in 2026.8.0
# Triggers have not yet been registered so this is adjusted in the property
self._attr_supported_features |= MediaPlayerEntityFeature.TURN_ON
if self._ssdp_rendering_control_location:
self._attr_supported_features |= MediaPlayerEntityFeature.VOLUME_SET
@@ -94,11 +94,5 @@
"unhandled_trigger_type": {
"message": "Unhandled trigger type {trigger_type}."
}
},
"issues": {
"deprecated_implicit_wake_on_lan": {
"description": "Implicit Wake-On-LAN is deprecated and will be removed in a future version of Home Assistant. Please create an explicit Wake-On-LAN automation to turn on your TV, targeting MAC address `{mac_address}`.\n\nFor more information, see the [Wake-On-LAN documentation]({wol_documentation_url}).",
"title": "Implicit Wake-On-LAN is deprecated"
}
}
}
-1
View File
@@ -3426,7 +3426,6 @@ vsure==2.10.0
# homeassistant.components.vasttrafik
vtjp==0.2.1
# homeassistant.components.samsungtv
# homeassistant.components.wake_on_lan
wakeonlan==3.3.0
@@ -1023,8 +1023,9 @@ async def test_media_previous_track(hass: HomeAssistant, remote_legacy: Mock) ->
@pytest.mark.usefixtures("remote_websocket", "rest_api")
async def test_turn_on_wol(hass: HomeAssistant) -> None:
"""Test turn on."""
async def test_turn_on_without_turnon_with_mac(hass: HomeAssistant) -> None:
"""Test turn on is not supported even when a MAC address is configured."""
await async_setup_component(hass, "homeassistant", {})
entry = MockConfigEntry(
domain=DOMAIN,
data=ENTRYDATA_WEBSOCKET,
@@ -1033,14 +1034,10 @@ async def test_turn_on_wol(hass: HomeAssistant) -> None:
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.samsungtv.entity.send_magic_packet"
) as mock_send_magic_packet:
with pytest.raises(ServiceNotSupported, match="does not support action"):
await hass.services.async_call(
MP_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
await hass.async_block_till_done()
assert mock_send_magic_packet.called
async def test_turn_on_without_turnon(hass: HomeAssistant, remote_legacy: Mock) -> None:
+6 -8
View File
@@ -1,6 +1,6 @@
"""The tests for the SamsungTV remote platform."""
from unittest.mock import Mock, patch
from unittest.mock import Mock
import pytest
from samsungtvws.encrypted.remote import SamsungTVEncryptedCommand
@@ -103,8 +103,8 @@ async def test_send_command_service(
@pytest.mark.usefixtures("remote_websocket", "rest_api")
async def test_turn_on_wol(hass: HomeAssistant) -> None:
"""Test turn on."""
async def test_turn_on_without_turnon_with_mac(hass: HomeAssistant) -> None:
"""Test turn on fails even when a MAC address is configured."""
entry = MockConfigEntry(
domain=DOMAIN,
data=ENTRYDATA_WEBSOCKET,
@@ -113,14 +113,12 @@ async def test_turn_on_wol(hass: HomeAssistant) -> None:
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
with patch(
"homeassistant.components.samsungtv.entity.send_magic_packet"
) as mock_send_magic_packet:
with pytest.raises(HomeAssistantError) as exc_info:
await hass.services.async_call(
REMOTE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
await hass.async_block_till_done()
assert mock_send_magic_packet.called
assert exc_info.value.translation_domain == DOMAIN
assert exc_info.value.translation_key == "service_unsupported"
async def test_turn_on_without_turnon(hass: HomeAssistant, remote_legacy: Mock) -> None:
+5 -6
View File
@@ -8,6 +8,7 @@ from homeassistant.components import automation
from homeassistant.components.samsungtv.const import DOMAIN
from homeassistant.const import SERVICE_RELOAD, SERVICE_TURN_ON
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
@@ -71,17 +72,15 @@ async def test_turn_on_trigger_device_id(
service_calls.clear()
# Ensure WOL backup is called when trigger not present
with patch(
"homeassistant.components.samsungtv.entity.send_magic_packet"
) as mock_send_magic_packet:
# Turn on fails when trigger not present
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
entity_domain, SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True
)
await hass.async_block_till_done()
await hass.async_block_till_done()
# Only the turn_on call itself was recorded, the automation did not fire
assert len(service_calls) == 1
mock_send_magic_packet.assert_called()
@pytest.mark.usefixtures("remote_encrypted_websocket", "rest_api")