Use TargetKey and the attribute enums in camera (#193981)

This commit is contained in:
epenet
2026-11-24 06:21:49 +00:00
committed by GitHub
parent 6d28e6daad
commit 65534db5e5
2 changed files with 7 additions and 12 deletions
+2 -2
View File
@@ -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],
},
+5 -10
View File
@@ -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