Repository: home-assistant/core
File: homeassistant/components/samsungtv/media_player.py (Python)

Code before:


class SamsungTVDevice(SamsungTVEntity, MediaPlayerEntity):
    """Representation of a Samsung TV."""

    _attr_source_list: list[str]
    _attr_name = None
    _attr_device_class = MediaPlayerDeviceClass.TV

    def __init__(self, coordinator: SamsungTVDataUpdateCoordinator) -> None:
        """Initialize the Samsung device."""
        super().__init__(coordinator=coordinator)
        self._ssdp_rendering_control_location: str | None = (
            coordinator.config_entry.data.get(CONF_SSDP_RENDERING_CONTROL_LOCATION)
        )
        # Assume that the TV is in Play mode
        self._playing: bool = True

        self._attr_is_volume_muted: bool = False
        self._attr_source_list = list(SOURCES)
        self._app_list: dict[str, str] | None = None
        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.7.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

        self._dmr_device: DmrDevice | None = None
        self._upnp_server: AiohttpNotifyServer | None = None

    @property
    def supported_features(self) -> MediaPlayerEntityFeature:
        """Flag media player features that are supported."""
        # `turn_on` triggers are not yet registered during initialisation,
        # so this property needs to be dynamic
        if self._turn_on_action:
            return self._attr_supported_features | MediaPlayerEntityFeature.TURN_ON
        return self._attr_supported_features

    def _update_sources(self) -> None:
        self._attr_source_list = list(SOURCES)
        if app_list := self._app_list:
            self._attr_source_list.extend(app_list)

    def _app_list_callback(self, app_list: dict[str, str]) -> None:
        """App list callback."""
        self._app_list = app_list

Review comment (suggestion):
```suggestion
            # Deprecated: Implicit Wake-On-LAN, will be removed in 2026.8.0
```

Code after:


class SamsungTVDevice(SamsungTVEntity, MediaPlayerEntity):
    """Representation of a Samsung TV."""

    _attr_source_list: list[str]
    _attr_name = None
    _attr_device_class = MediaPlayerDeviceClass.TV

    def __init__(self, coordinator: SamsungTVDataUpdateCoordinator) -> None:
        """Initialize the Samsung device."""
        super().__init__(coordinator=coordinator)
        self._ssdp_rendering_control_location: str | None = (
            coordinator.config_entry.data.get(CONF_SSDP_RENDERING_CONTROL_LOCATION)
        )
        # Assume that the TV is in Play mode
        self._playing: bool = True

        self._attr_is_volume_muted: bool = False
        self._attr_source_list = list(SOURCES)
        self._app_list: dict[str, str] | None = None
        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

        self._dmr_device: DmrDevice | None = None
        self._upnp_server: AiohttpNotifyServer | None = None

    @property
    def supported_features(self) -> MediaPlayerEntityFeature:
        """Flag media player features that are supported."""
        # `turn_on` triggers are not yet registered during initialisation,
        # so this property needs to be dynamic
        if self._turn_on_action:
            return self._attr_supported_features | MediaPlayerEntityFeature.TURN_ON
        return self._attr_supported_features

    def _update_sources(self) -> None:
        self._attr_source_list = list(SOURCES)
        if app_list := self._app_list:
            self._attr_source_list.extend(app_list)

    def _app_list_callback(self, app_list: dict[str, str]) -> None:
        """App list callback."""
        self._app_list = app_list