From 65534db5e5f36de9ccabdadd88004cb49e378b88 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 24 Nov 2026 07:21:49 +0100 Subject: [PATCH] Use TargetKey and the attribute enums in camera (#193981) --- homeassistant/components/camera/services.py | 4 ++-- tests/components/camera/test_recorder.py | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/camera/services.py b/homeassistant/components/camera/services.py index f7ac1ce71180..096be92be95e 100644 --- a/homeassistant/components/camera/services.py +++ b/homeassistant/components/camera/services.py @@ -12,7 +12,7 @@ from homeassistant.components.media_player import ( MediaPlayerServiceArgument, ) from homeassistant.components.stream import FORMAT_CONTENT_TYPE, OUTPUT_FORMATS -from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.const import TargetKey from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import HomeAssistantError, ServiceValidationError from homeassistant.helpers import config_validation as cv @@ -114,7 +114,7 @@ async def _async_handle_play_stream_service( MP_DOMAIN, MediaPlayerService.PLAY_MEDIA, { - ATTR_ENTITY_ID: service_call.data[CameraServiceArgument.MEDIA_PLAYER], + TargetKey.ENTITY_ID: service_call.data[CameraServiceArgument.MEDIA_PLAYER], MediaPlayerServiceArgument.MEDIA_CONTENT_ID: url, MediaPlayerServiceArgument.MEDIA_CONTENT_TYPE: FORMAT_CONTENT_TYPE[fmt], }, diff --git a/tests/components/camera/test_recorder.py b/tests/components/camera/test_recorder.py index b84c82e5b96d..8bc656f330f1 100644 --- a/tests/components/camera/test_recorder.py +++ b/tests/components/camera/test_recorder.py @@ -9,12 +9,7 @@ from pytest_homeassistant.components.recorder.common import async_wait_recording from homeassistant.components import camera from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states -from homeassistant.const import ( - ATTR_ATTRIBUTION, - ATTR_ENTITY_PICTURE, - ATTR_FRIENDLY_NAME, - ATTR_SUPPORTED_FEATURES, -) +from homeassistant.const import EntityStateAttribute from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component from homeassistant.util import dt as dt_util @@ -44,7 +39,7 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) for entity_states in states.values(): for state in entity_states: assert "access_token" not in state.attributes - assert ATTR_ENTITY_PICTURE not in state.attributes - assert ATTR_ATTRIBUTION not in state.attributes - assert ATTR_SUPPORTED_FEATURES not in state.attributes - assert ATTR_FRIENDLY_NAME in state.attributes + assert EntityStateAttribute.ENTITY_PICTURE not in state.attributes + assert EntityStateAttribute.ATTRIBUTION not in state.attributes + assert EntityStateAttribute.SUPPORTED_FEATURES not in state.attributes + assert EntityStateAttribute.FRIENDLY_NAME in state.attributes