mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Exclude more media player attributes from recorder (#69209)
This commit is contained in:
parent
40fba130e8
commit
bd1d7bdbb7
@ -70,6 +70,7 @@ from .browse_media import BrowseMedia, async_process_play_media_url # noqa: F40
|
||||
from .const import ( # noqa: F401
|
||||
ATTR_APP_ID,
|
||||
ATTR_APP_NAME,
|
||||
ATTR_ENTITY_PICTURE_LOCAL,
|
||||
ATTR_GROUP_MEMBERS,
|
||||
ATTR_INPUT_SOURCE,
|
||||
ATTR_INPUT_SOURCE_LIST,
|
||||
@ -954,7 +955,7 @@ class MediaPlayerEntity(Entity):
|
||||
state_attr[attr] = value
|
||||
|
||||
if self.media_image_remotely_accessible:
|
||||
state_attr["entity_picture_local"] = self.media_image_local
|
||||
state_attr[ATTR_ENTITY_PICTURE_LOCAL] = self.media_image_local
|
||||
|
||||
return state_attr
|
||||
|
||||
|
@ -6,6 +6,7 @@ CONTENT_AUTH_EXPIRY_TIME = 3600 * 24
|
||||
|
||||
ATTR_APP_ID = "app_id"
|
||||
ATTR_APP_NAME = "app_name"
|
||||
ATTR_ENTITY_PICTURE_LOCAL = "entity_picture_local"
|
||||
ATTR_GROUP_MEMBERS = "group_members"
|
||||
ATTR_INPUT_SOURCE = "source"
|
||||
ATTR_INPUT_SOURCE_LIST = "source_list"
|
||||
|
@ -4,10 +4,23 @@ from __future__ import annotations
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
from . import ATTR_INPUT_SOURCE_LIST, ATTR_SOUND_MODE_LIST
|
||||
from . import (
|
||||
ATTR_ENTITY_PICTURE_LOCAL,
|
||||
ATTR_INPUT_SOURCE_LIST,
|
||||
ATTR_MEDIA_POSITION,
|
||||
ATTR_MEDIA_POSITION_UPDATED_AT,
|
||||
ATTR_SOUND_MODE_LIST,
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
def exclude_attributes(hass: HomeAssistant) -> set[str]:
|
||||
"""Exclude static and token attributes from being recorded in the database."""
|
||||
return {ATTR_SOUND_MODE_LIST, ATTR_ENTITY_PICTURE, ATTR_INPUT_SOURCE_LIST}
|
||||
return {
|
||||
ATTR_ENTITY_PICTURE_LOCAL,
|
||||
ATTR_ENTITY_PICTURE,
|
||||
ATTR_INPUT_SOURCE_LIST,
|
||||
ATTR_MEDIA_POSITION_UPDATED_AT,
|
||||
ATTR_MEDIA_POSITION,
|
||||
ATTR_SOUND_MODE_LIST,
|
||||
}
|
||||
|
@ -5,7 +5,10 @@ from datetime import timedelta
|
||||
|
||||
from homeassistant.components import media_player
|
||||
from homeassistant.components.media_player.const import (
|
||||
ATTR_ENTITY_PICTURE_LOCAL,
|
||||
ATTR_INPUT_SOURCE_LIST,
|
||||
ATTR_MEDIA_POSITION,
|
||||
ATTR_MEDIA_POSITION_UPDATED_AT,
|
||||
ATTR_SOUND_MODE_LIST,
|
||||
)
|
||||
from homeassistant.components.recorder.models import StateAttributes, States
|
||||
@ -42,7 +45,10 @@ async def test_exclude_attributes(hass):
|
||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
||||
assert len(states) > 1
|
||||
for state in states:
|
||||
assert ATTR_SOUND_MODE_LIST not in state.attributes
|
||||
assert ATTR_ENTITY_PICTURE not in state.attributes
|
||||
assert ATTR_INPUT_SOURCE_LIST not in state.attributes
|
||||
assert ATTR_ENTITY_PICTURE_LOCAL not in state.attributes
|
||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||
assert ATTR_INPUT_SOURCE_LIST not in state.attributes
|
||||
assert ATTR_MEDIA_POSITION not in state.attributes
|
||||
assert ATTR_MEDIA_POSITION_UPDATED_AT not in state.attributes
|
||||
assert ATTR_SOUND_MODE_LIST not in state.attributes
|
||||
|
Loading…
x
Reference in New Issue
Block a user