Move definition of attributes excluded from history to entity classes (#100430)

* Move definition of attributes excluded from history to entity classes

* Revert change which should be in a follow-up PR

* Fix sun unrecorded attributes

* Fix input_select unrecorded attributes
pull/100678/head
Erik Montnemery 2023-09-21 15:02:47 +02:00 committed by GitHub
parent aed3ba3acd
commit df73850f56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 143 additions and 558 deletions

View File

@ -57,9 +57,6 @@ from homeassistant.helpers import condition
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.script import (
@ -249,10 +246,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
LOGGER, DOMAIN, hass
)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
# Register automation as valid domain for Blueprint
async_get_blueprints(hass)

View File

@ -481,6 +481,8 @@ def is_offset_reached(
class CalendarEntity(Entity):
"""Base class for calendar event entities."""
_entity_component_unrecorded_attributes = frozenset({"description"})
_alarm_unsubs: list[CALLBACK_TYPE] = []
@property

View File

@ -1,10 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude potentially large attributes from being recorded in the database."""
return {"description"}

View File

@ -449,6 +449,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
class Camera(Entity):
"""The base class for camera entities."""
_entity_component_unrecorded_attributes = frozenset(
{"access_token", "entity_picture"}
)
# Entity Properties
_attr_brand: str | None = None
_attr_frame_interval: float = MIN_STREAM_INTERVAL

View File

@ -1,10 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude access_token and entity_picture from being recorded in the database."""
return {"access_token", "entity_picture"}

View File

@ -209,6 +209,20 @@ class ClimateEntityDescription(EntityDescription):
class ClimateEntity(Entity):
"""Base class for climate entities."""
_entity_component_unrecorded_attributes = frozenset(
{
ATTR_HVAC_MODES,
ATTR_FAN_MODES,
ATTR_SWING_MODES,
ATTR_MIN_TEMP,
ATTR_MAX_TEMP,
ATTR_MIN_HUMIDITY,
ATTR_MAX_HUMIDITY,
ATTR_TARGET_TEMP_STEP,
ATTR_PRESET_MODES,
}
)
entity_description: ClimateEntityDescription
_attr_current_humidity: int | None = None
_attr_current_temperature: float | None = None

View File

@ -1,32 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from .const import (
ATTR_FAN_MODES,
ATTR_HVAC_MODES,
ATTR_MAX_HUMIDITY,
ATTR_MAX_TEMP,
ATTR_MIN_HUMIDITY,
ATTR_MIN_TEMP,
ATTR_PRESET_MODES,
ATTR_SWING_MODES,
ATTR_TARGET_TEMP_STEP,
)
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {
ATTR_HVAC_MODES,
ATTR_FAN_MODES,
ATTR_SWING_MODES,
ATTR_MIN_TEMP,
ATTR_MAX_TEMP,
ATTR_MIN_HUMIDITY,
ATTR_MAX_HUMIDITY,
ATTR_TARGET_TEMP_STEP,
ATTR_PRESET_MODES,
}

View File

@ -105,6 +105,8 @@ class EventExtraStoredData(ExtraStoredData):
class EventEntity(RestoreEntity):
"""Representation of an Event entity."""
_entity_component_unrecorded_attributes = frozenset({ATTR_EVENT_TYPES})
entity_description: EventEntityDescription
_attr_device_class: EventDeviceClass | None
_attr_event_types: list[str]

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_EVENT_TYPES
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {ATTR_EVENT_TYPES}

View File

@ -183,6 +183,8 @@ class FanEntityDescription(ToggleEntityDescription):
class FanEntity(ToggleEntity):
"""Base class for fan entities."""
_entity_component_unrecorded_attributes = frozenset({ATTR_PRESET_MODES})
entity_description: FanEntityDescription
_attr_current_direction: str | None = None
_attr_oscillating: bool | None = None

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_PRESET_MODES
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {ATTR_PRESET_MODES}

View File

@ -42,7 +42,6 @@ from homeassistant.helpers.event import (
async_track_state_change_event,
)
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
async_process_integration_platforms,
)
from homeassistant.helpers.reload import async_reload_integration_platforms
@ -285,8 +284,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
if DOMAIN not in hass.data:
hass.data[DOMAIN] = EntityComponent[Group](_LOGGER, DOMAIN, hass)
await async_process_integration_platform_for_component(hass, DOMAIN)
component: EntityComponent[Group] = hass.data[DOMAIN]
hass.data[REG_KEY] = GroupIntegrationRegistry()
@ -472,6 +469,8 @@ async def _async_process_config(hass: HomeAssistant, config: ConfigType) -> None
class GroupEntity(Entity):
"""Representation of a Group of entities."""
_unrecorded_attributes = frozenset({ATTR_ENTITY_ID})
_attr_should_poll = False
_entity_ids: list[str]
@ -560,6 +559,8 @@ class GroupEntity(Entity):
class Group(Entity):
"""Track a group of entity ids."""
_unrecorded_attributes = frozenset({ATTR_ENTITY_ID, ATTR_ORDER, ATTR_AUTO})
_attr_should_poll = False
tracking: tuple[str, ...]
trackable: tuple[str, ...]

View File

@ -122,6 +122,8 @@ def async_create_preview_media_player(
class MediaPlayerGroup(MediaPlayerEntity):
"""Representation of a Media Group."""
_unrecorded_attributes = frozenset({ATTR_ENTITY_ID})
_attr_available: bool = False
_attr_should_poll = False

View File

@ -1,16 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_AUTO, ATTR_ENTITY_ID, ATTR_ORDER
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {
ATTR_ENTITY_ID,
ATTR_ORDER,
ATTR_AUTO,
}

View File

@ -134,6 +134,10 @@ class HumidifierEntityDescription(ToggleEntityDescription):
class HumidifierEntity(ToggleEntity):
"""Base class for humidifier entities."""
_entity_component_unrecorded_attributes = frozenset(
{ATTR_MIN_HUMIDITY, ATTR_MAX_HUMIDITY, ATTR_AVAILABLE_MODES}
)
entity_description: HumidifierEntityDescription
_attr_action: HumidifierAction | None = None
_attr_available_modes: list[str] | None

View File

@ -1,16 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_AVAILABLE_MODES, ATTR_MAX_HUMIDITY, ATTR_MIN_HUMIDITY
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {
ATTR_MIN_HUMIDITY,
ATTR_MAX_HUMIDITY,
ATTR_AVAILABLE_MODES,
}

View File

@ -126,6 +126,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
class ImageEntity(Entity):
"""The base class for image entities."""
_entity_component_unrecorded_attributes = frozenset(
{"access_token", "entity_picture"}
)
# Entity Properties
_attr_content_type: str = DEFAULT_CONTENT_TYPE
_attr_image_last_updated: datetime | None = None

View File

@ -1,10 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude access_token and entity_picture from being recorded in the database."""
return {"access_token", "entity_picture"}

View File

@ -22,9 +22,6 @@ from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
@ -94,10 +91,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input boolean."""
component = EntityComponent[InputBoolean](_LOGGER, DOMAIN, hass)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
@ -156,6 +149,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
class InputBoolean(collection.CollectionEntity, ToggleEntity, RestoreEntity):
"""Representation of a boolean input."""
_unrecorded_attributes = frozenset({ATTR_EDITABLE})
_attr_should_poll = False
editable: bool

View File

@ -1,11 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, callback
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude editable hint from being recorded in the database."""
return {ATTR_EDITABLE}

View File

@ -18,9 +18,6 @@ from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
@ -79,10 +76,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input button."""
component = EntityComponent[InputButton](_LOGGER, DOMAIN, hass)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
@ -137,6 +130,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
class InputButton(collection.CollectionEntity, ButtonEntity, RestoreEntity):
"""Representation of a button."""
_unrecorded_attributes = frozenset({ATTR_EDITABLE})
_attr_should_poll = False
editable: bool

View File

@ -1,11 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, callback
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude editable hint from being recorded in the database."""
return {ATTR_EDITABLE}

View File

@ -20,9 +20,6 @@ from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
@ -132,10 +129,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input datetime."""
component = EntityComponent[InputDatetime](_LOGGER, DOMAIN, hass)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
@ -225,6 +218,8 @@ class DateTimeStorageCollection(collection.DictStorageCollection):
class InputDatetime(collection.CollectionEntity, RestoreEntity):
"""Representation of a datetime input."""
_unrecorded_attributes = frozenset({ATTR_EDITABLE, CONF_HAS_DATE, CONF_HAS_TIME})
_attr_should_poll = False
editable: bool

View File

@ -1,13 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, callback
from . import CONF_HAS_DATE, CONF_HAS_TIME
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude some attributes from being recorded in the database."""
return {ATTR_EDITABLE, CONF_HAS_DATE, CONF_HAS_TIME}

View File

@ -21,9 +21,6 @@ from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
@ -110,10 +107,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input slider."""
component = EntityComponent[InputNumber](_LOGGER, DOMAIN, hass)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
@ -209,6 +202,10 @@ class NumberStorageCollection(collection.DictStorageCollection):
class InputNumber(collection.CollectionEntity, RestoreEntity):
"""Representation of a slider."""
_unrecorded_attributes = frozenset(
{ATTR_EDITABLE, ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_STEP}
)
_attr_should_poll = False
editable: bool

View File

@ -1,19 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, callback
from . import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_STEP
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude editable hint from being recorded in the database."""
return {
ATTR_EDITABLE,
ATTR_MAX,
ATTR_MIN,
ATTR_MODE,
ATTR_STEP,
}

View File

@ -29,9 +29,6 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
@ -138,10 +135,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input select."""
component = EntityComponent[InputSelect](_LOGGER, DOMAIN, hass)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
@ -255,6 +248,11 @@ class InputSelectStorageCollection(collection.DictStorageCollection):
class InputSelect(collection.CollectionEntity, SelectEntity, RestoreEntity):
"""Representation of a select input."""
_entity_component_unrecorded_attributes = (
SelectEntity._entity_component_unrecorded_attributes - {ATTR_OPTIONS}
)
_unrecorded_attributes = frozenset({ATTR_EDITABLE})
_attr_should_poll = False
editable: bool

View File

@ -1,11 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, callback
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude editable hint from being recorded in the database."""
return {ATTR_EDITABLE}

View File

@ -20,9 +20,6 @@ from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
@ -110,10 +107,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input text."""
component = EntityComponent[InputText](_LOGGER, DOMAIN, hass)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
@ -187,6 +180,10 @@ class InputTextStorageCollection(collection.DictStorageCollection):
class InputText(collection.CollectionEntity, RestoreEntity):
"""Represent a text box."""
_unrecorded_attributes = frozenset(
{ATTR_EDITABLE, ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN}
)
_attr_should_poll = False
editable: bool

View File

@ -1,19 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, callback
from . import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude editable hint from being recorded in the database."""
return {
ATTR_EDITABLE,
ATTR_MAX,
ATTR_MIN,
ATTR_MODE,
ATTR_PATTERN,
}

View File

@ -785,6 +785,17 @@ class LightEntityDescription(ToggleEntityDescription):
class LightEntity(ToggleEntity):
"""Base class for light entities."""
_entity_component_unrecorded_attributes = frozenset(
{
ATTR_SUPPORTED_COLOR_MODES,
ATTR_EFFECT_LIST,
ATTR_MIN_MIREDS,
ATTR_MAX_MIREDS,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_MAX_COLOR_TEMP_KELVIN,
}
)
entity_description: LightEntityDescription
_attr_brightness: int | None = None
_attr_color_mode: ColorMode | str | None = None

View File

@ -1,26 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import (
ATTR_EFFECT_LIST,
ATTR_MAX_COLOR_TEMP_KELVIN,
ATTR_MAX_MIREDS,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_MIN_MIREDS,
ATTR_SUPPORTED_COLOR_MODES,
)
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {
ATTR_SUPPORTED_COLOR_MODES,
ATTR_EFFECT_LIST,
ATTR_MIN_MIREDS,
ATTR_MAX_MIREDS,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_MAX_COLOR_TEMP_KELVIN,
}

View File

@ -27,6 +27,7 @@ from homeassistant.components.http import KEY_AUTHENTICATED, HomeAssistantView
from homeassistant.components.websocket_api import ERR_NOT_SUPPORTED, ERR_UNKNOWN_ERROR
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( # noqa: F401
ATTR_ENTITY_PICTURE,
SERVICE_MEDIA_NEXT_TRACK,
SERVICE_MEDIA_PAUSE,
SERVICE_MEDIA_PLAY,
@ -458,6 +459,17 @@ class MediaPlayerEntityDescription(EntityDescription):
class MediaPlayerEntity(Entity):
"""ABC for media player entities."""
_entity_component_unrecorded_attributes = frozenset(
{
ATTR_ENTITY_PICTURE_LOCAL,
ATTR_ENTITY_PICTURE,
ATTR_INPUT_SOURCE_LIST,
ATTR_MEDIA_POSITION_UPDATED_AT,
ATTR_MEDIA_POSITION,
ATTR_SOUND_MODE_LIST,
}
)
entity_description: MediaPlayerEntityDescription
_access_token: str | None = None

View File

@ -1,26 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_ENTITY_PICTURE
from homeassistant.core import HomeAssistant, callback
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_ENTITY_PICTURE_LOCAL,
ATTR_ENTITY_PICTURE,
ATTR_INPUT_SOURCE_LIST,
ATTR_MEDIA_POSITION_UPDATED_AT,
ATTR_MEDIA_POSITION,
ATTR_SOUND_MODE_LIST,
}

View File

@ -156,6 +156,10 @@ def floor_decimal(value: float, precision: float = 0) -> float:
class NumberEntity(Entity):
"""Representation of a Number entity."""
_entity_component_unrecorded_attributes = frozenset(
{ATTR_MIN, ATTR_MAX, ATTR_STEP, ATTR_MODE}
)
entity_description: NumberEntityDescription
_attr_device_class: NumberDeviceClass | None
_attr_max_value: None

View File

@ -1,17 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_STEP
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {
ATTR_MIN,
ATTR_MAX,
ATTR_STEP,
ATTR_MODE,
}

View File

@ -47,9 +47,6 @@ from homeassistant.helpers import (
)
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import async_track_state_change_event
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType
@ -333,9 +330,6 @@ The following persons point at invalid users:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the person component."""
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
entity_component = EntityComponent[Person](_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
@ -397,6 +391,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
class Person(collection.CollectionEntity, RestoreEntity):
"""Represent a tracked person."""
_entity_component_unrecorded_attributes = frozenset({ATTR_DEVICE_TRACKERS})
_attr_should_poll = False
editable: bool

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_DEVICE_TRACKERS
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude large and chatty update attributes from being recorded."""
return {ATTR_DEVICE_TRACKERS}

View File

@ -30,9 +30,6 @@ from homeassistant.helpers.collection import (
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType
@ -157,10 +154,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input select."""
component = EntityComponent[Schedule](LOGGER, DOMAIN, hass)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
id_manager = IDManager()
yaml_collection = YamlCollection(LOGGER, id_manager)
@ -240,6 +233,10 @@ class ScheduleStorageCollection(DictStorageCollection):
class Schedule(CollectionEntity):
"""Schedule entity."""
_entity_component_unrecorded_attributes = frozenset(
{ATTR_EDITABLE, ATTR_NEXT_EVENT}
)
_attr_has_entity_name = True
_attr_should_poll = False
_attr_state: Literal["on", "off"]

View File

@ -1,16 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, callback
from .const import ATTR_NEXT_EVENT
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude configuration to be recorded in the database."""
return {
ATTR_EDITABLE,
ATTR_NEXT_EVENT,
}

View File

@ -42,9 +42,6 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import make_entity_service_schema
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.script import (
ATTR_CUR,
@ -188,10 +185,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
LOGGER, DOMAIN, hass
)
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
# Register script as valid domain for Blueprint
async_get_blueprints(hass)
@ -382,6 +375,10 @@ async def _async_process_config(
class BaseScriptEntity(ToggleEntity, ABC):
"""Base class for script entities."""
_entity_component_unrecorded_attributes = frozenset(
{ATTR_LAST_TRIGGERED, ATTR_MODE, ATTR_CUR, ATTR_MAX, ATTR_LAST_ACTION}
)
raw_config: ConfigType | None
@property

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_CUR, ATTR_LAST_ACTION, ATTR_LAST_TRIGGERED, ATTR_MAX, ATTR_MODE
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude extra attributes from being recorded in the database."""
return {ATTR_LAST_TRIGGERED, ATTR_MODE, ATTR_CUR, ATTR_MAX, ATTR_LAST_ACTION}

View File

@ -128,6 +128,8 @@ class SelectEntityDescription(EntityDescription):
class SelectEntity(Entity):
"""Representation of a Select entity."""
_entity_component_unrecorded_attributes = frozenset({ATTR_OPTIONS})
entity_description: SelectEntityDescription
_attr_current_option: str | None
_attr_options: list[str]

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_OPTIONS
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {ATTR_OPTIONS}

View File

@ -149,6 +149,8 @@ class SensorEntityDescription(EntityDescription):
class SensorEntity(Entity):
"""Base class for sensor entities."""
_entity_component_unrecorded_attributes = frozenset({ATTR_OPTIONS})
entity_description: SensorEntityDescription
_attr_device_class: SensorDeviceClass | None
_attr_last_reset: datetime | None

View File

@ -30,19 +30,13 @@ from homeassistant.const import (
UnitOfSoundPressure,
UnitOfVolume,
)
from homeassistant.core import HomeAssistant, State, callback, split_entity_id
from homeassistant.core import HomeAssistant, State, split_entity_id
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity import entity_sources
from homeassistant.util import dt as dt_util
from homeassistant.util.enum import try_parse_enum
from .const import (
ATTR_LAST_RESET,
ATTR_OPTIONS,
ATTR_STATE_CLASS,
DOMAIN,
SensorStateClass,
)
from .const import ATTR_LAST_RESET, ATTR_STATE_CLASS, DOMAIN, SensorStateClass
_LOGGER = logging.getLogger(__name__)
@ -790,9 +784,3 @@ def validate_statistics(
)
return validation_result
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude attributes from being recorded in the database."""
return {ATTR_OPTIONS}

View File

@ -159,6 +159,8 @@ class SirenEntityDescription(ToggleEntityDescription):
class SirenEntity(ToggleEntity):
"""Representation of a siren device."""
_entity_component_unrecorded_attributes = frozenset({ATTR_AVAILABLE_TONES})
entity_description: SirenEntityDescription
_attr_available_tones: list[int | str] | dict[int, str] | None
_attr_supported_features: SirenEntityFeature = SirenEntityFeature(0)

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_AVAILABLE_TONES
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {ATTR_AVAILABLE_TONES}

View File

@ -17,9 +17,6 @@ from homeassistant.const import (
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, event
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.sun import (
get_astral_location,
get_location_astral_event_next,
@ -97,9 +94,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up from a config entry."""
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
hass.data[DOMAIN] = Sun(hass)
await hass.config_entries.async_forward_entry_setups(entry, [Platform.SENSOR])
return True
@ -119,6 +113,20 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
class Sun(Entity):
"""Representation of the Sun."""
_unrecorded_attributes = frozenset(
{
STATE_ATTR_AZIMUTH,
STATE_ATTR_ELEVATION,
STATE_ATTR_RISING,
STATE_ATTR_NEXT_DAWN,
STATE_ATTR_NEXT_DUSK,
STATE_ATTR_NEXT_MIDNIGHT,
STATE_ATTR_NEXT_NOON,
STATE_ATTR_NEXT_RISING,
STATE_ATTR_NEXT_SETTING,
}
)
_attr_name = "Sun"
entity_id = ENTITY_ID
# This entity is legacy and does not have a platform.
@ -143,6 +151,12 @@ class Sun(Entity):
self.hass = hass
self.phase: str | None = None
# This is normally done by async_internal_added_to_hass which is not called
# for sun because sun has no platform
self._state_info = {
"unrecorded_attributes": self._Entity__combined_unrecorded_attributes # type: ignore[attr-defined]
}
self._config_listener: CALLBACK_TYPE | None = None
self._update_events_listener: CALLBACK_TYPE | None = None
self._update_sun_position_listener: CALLBACK_TYPE | None = None

View File

@ -1,32 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import (
STATE_ATTR_AZIMUTH,
STATE_ATTR_ELEVATION,
STATE_ATTR_NEXT_DAWN,
STATE_ATTR_NEXT_DUSK,
STATE_ATTR_NEXT_MIDNIGHT,
STATE_ATTR_NEXT_NOON,
STATE_ATTR_NEXT_RISING,
STATE_ATTR_NEXT_SETTING,
STATE_ATTR_RISING,
)
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude sun attributes from being recorded in the database."""
return {
STATE_ATTR_AZIMUTH,
STATE_ATTR_ELEVATION,
STATE_ATTR_RISING,
STATE_ATTR_NEXT_DAWN,
STATE_ATTR_NEXT_DUSK,
STATE_ATTR_NEXT_MIDNIGHT,
STATE_ATTR_NEXT_NOON,
STATE_ATTR_NEXT_RISING,
STATE_ATTR_NEXT_SETTING,
}

View File

@ -111,6 +111,10 @@ class TextEntityDescription(EntityDescription):
class TextEntity(Entity):
"""Representation of a Text entity."""
_entity_component_unrecorded_attributes = frozenset(
{ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN}
)
entity_description: TextEntityDescription
_attr_mode: TextMode
_attr_native_value: str | None

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN}

View File

@ -4,10 +4,6 @@ from __future__ import annotations
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.integration_platform import (
async_process_integration_platform_for_component,
)
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN, PLATFORMS
from .coordinator import TVDataUpdateCoordinator
@ -15,14 +11,6 @@ from .coordinator import TVDataUpdateCoordinator
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up trafikverket_camera."""
# Process integration platforms right away since
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Trafikverket Camera from a config entry."""

View File

@ -37,6 +37,8 @@ async def async_setup_entry(
class TVCamera(TrafikverketCameraEntity, Camera):
"""Implement Trafikverket camera."""
_unrecorded_attributes = frozenset({ATTR_DESCRIPTION, ATTR_LOCATION})
_attr_name = None
_attr_translation_key = "tv_camera"
coordinator: TVDataUpdateCoordinator

View File

@ -1,13 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_LOCATION
from homeassistant.core import HomeAssistant, callback
from .const import ATTR_DESCRIPTION
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude description and location from being recorded in the database."""
return {ATTR_DESCRIPTION, ATTR_LOCATION}

View File

@ -311,6 +311,8 @@ class ProtectNVREntity(ProtectDeviceEntity):
class EventEntityMixin(ProtectDeviceEntity):
"""Adds motion event attributes to sensor."""
_unrecorded_attributes = frozenset({ATTR_EVENT_ID, ATTR_EVENT_SCORE})
entity_description: ProtectEventMixin
def __init__(

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from .const import ATTR_EVENT_ID, ATTR_EVENT_SCORE
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude event_id and event_score from being recorded in the database."""
return {ATTR_EVENT_ID, ATTR_EVENT_SCORE}

View File

@ -13,7 +13,7 @@ import voluptuous as vol
from homeassistant.components import websocket_api
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_ON, EntityCategory
from homeassistant.const import ATTR_ENTITY_PICTURE, STATE_OFF, STATE_ON, EntityCategory
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv
@ -192,6 +192,10 @@ def _version_is_newer(latest_version: str, installed_version: str) -> bool:
class UpdateEntity(RestoreEntity):
"""Representation of an update entity."""
_entity_component_unrecorded_attributes = frozenset(
{ATTR_ENTITY_PICTURE, ATTR_IN_PROGRESS, ATTR_RELEASE_SUMMARY}
)
entity_description: UpdateEntityDescription
_attr_auto_update: bool = False
_attr_installed_version: str | None = None

View File

@ -1,13 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.const import ATTR_ENTITY_PICTURE
from homeassistant.core import HomeAssistant, callback
from .const import ATTR_IN_PROGRESS, ATTR_RELEASE_SUMMARY
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude large and chatty update attributes from being recorded."""
return {ATTR_ENTITY_PICTURE, ATTR_IN_PROGRESS, ATTR_RELEASE_SUMMARY}

View File

@ -228,6 +228,8 @@ class _BaseVacuum(Entity):
Contains common properties and functions for all vacuum devices.
"""
_entity_component_unrecorded_attributes = frozenset({ATTR_FAN_SPEED_LIST})
_attr_battery_icon: str
_attr_battery_level: int | None = None
_attr_fan_speed: str | None = None

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_FAN_SPEED_LIST
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {ATTR_FAN_SPEED_LIST}

View File

@ -164,6 +164,10 @@ class WaterHeaterEntityEntityDescription(EntityDescription):
class WaterHeaterEntity(Entity):
"""Base class for water heater entities."""
_entity_component_unrecorded_attributes = frozenset(
{ATTR_OPERATION_LIST, ATTR_MIN_TEMP, ATTR_MAX_TEMP}
)
entity_description: WaterHeaterEntityEntityDescription
_attr_current_operation: str | None = None
_attr_current_temperature: float | None = None

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_MAX_TEMP, ATTR_MIN_TEMP, ATTR_OPERATION_LIST
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude static attributes from being recorded in the database."""
return {ATTR_OPERATION_LIST, ATTR_MIN_TEMP, ATTR_MAX_TEMP}

View File

@ -264,6 +264,8 @@ class PostInit(metaclass=PostInitMeta):
class WeatherEntity(Entity, PostInit):
"""ABC for weather data."""
_entity_component_unrecorded_attributes = frozenset({ATTR_FORECAST})
entity_description: WeatherEntityDescription
_attr_condition: str | None = None
# _attr_forecast is deprecated, implement async_forecast_daily,

View File

@ -1,12 +0,0 @@
"""Integration platform for recorder."""
from __future__ import annotations
from homeassistant.core import HomeAssistant, callback
from . import ATTR_FORECAST
@callback
def exclude_attributes(hass: HomeAssistant) -> set[str]:
"""Exclude (often large) forecasts from being recorded in the database."""
return {ATTR_FORECAST}