Rename DOMAIN_DATA HassKey constants to DATA_COMPONENT (#126746)

* Rename DOMAIN_DATA HassKey constant to DATA

* DATA -> DATA_COMPONENT
This commit is contained in:
epenet 2024-09-25 15:53:58 +02:00 committed by GitHub
parent 866ffcf639
commit 2699eb62bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
64 changed files with 233 additions and 233 deletions

View File

@ -19,7 +19,7 @@ from .const import DOMAIN
_LOGGER: Final = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[AirQualityEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[AirQualityEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT: Final = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -56,7 +56,7 @@ PROP_TO_ATTR: Final[dict[str, str]] = {
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the air quality component."""
component = hass.data[DOMAIN_DATA] = EntityComponent[AirQualityEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[AirQualityEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -65,12 +65,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class AirQualityEntity(Entity):

View File

@ -53,7 +53,7 @@ from .const import ( # noqa: F401
_LOGGER: Final = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[AlarmControlPanelEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[AlarmControlPanelEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT: Final = DOMAIN + ".{}"
PLATFORM_SCHEMA: Final = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE: Final = cv.PLATFORM_SCHEMA_BASE
@ -71,7 +71,7 @@ ALARM_SERVICE_SCHEMA: Final = make_entity_service_schema(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for sensors."""
component = hass.data[DOMAIN_DATA] = EntityComponent[AlarmControlPanelEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[AlarmControlPanelEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -124,12 +124,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class AlarmControlPanelEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -13,8 +13,8 @@ from homeassistant.helpers.typing import ConfigType
from .connection_test import ConnectionTestView
from .const import (
CONNECTION_TEST_DATA,
DATA_COMPONENT,
DOMAIN,
DOMAIN_DATA,
AssistSatelliteEntityFeature,
)
from .entity import (
@ -44,7 +44,7 @@ PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component = hass.data[DOMAIN_DATA] = EntityComponent[AssistSatelliteEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[AssistSatelliteEntity](
_LOGGER, DOMAIN, hass
)
await component.async_setup(config)
@ -72,9 +72,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)

View File

@ -15,7 +15,7 @@ if TYPE_CHECKING:
DOMAIN = "assist_satellite"
DOMAIN_DATA: HassKey[EntityComponent[AssistSatelliteEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[AssistSatelliteEntity]] = HassKey(DOMAIN)
CONNECTION_TEST_DATA: HassKey[dict[str, asyncio.Event]] = HassKey(
f"{DOMAIN}_connection_tests"
)

View File

@ -16,8 +16,8 @@ from homeassistant.util import uuid as uuid_util
from .connection_test import CONNECTION_TEST_URL_BASE
from .const import (
CONNECTION_TEST_DATA,
DATA_COMPONENT,
DOMAIN,
DOMAIN_DATA,
AssistSatelliteEntityFeature,
)
from .entity import AssistSatelliteEntity
@ -48,7 +48,7 @@ async def websocket_intercept_wake_word(
msg: dict[str, Any],
) -> None:
"""Intercept the next wake word from a satellite."""
satellite = hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])
satellite = hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])
if satellite is None:
connection.send_error(
msg["id"], websocket_api.ERR_NOT_FOUND, "Entity not found"
@ -86,7 +86,7 @@ def websocket_get_configuration(
msg: dict[str, Any],
) -> None:
"""Get the current satellite configuration."""
satellite = hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])
satellite = hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])
if satellite is None:
connection.send_error(
msg["id"], websocket_api.ERR_NOT_FOUND, "Entity not found"
@ -115,7 +115,7 @@ async def websocket_set_wake_words(
msg: dict[str, Any],
) -> None:
"""Set the active wake words for the satellite."""
satellite = hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])
satellite = hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])
if satellite is None:
connection.send_error(
msg["id"], websocket_api.ERR_NOT_FOUND, "Entity not found"

View File

@ -110,7 +110,7 @@ from .const import (
from .helpers import async_get_blueprints
from .trace import trace_automation
DOMAIN_DATA: HassKey[EntityComponent[BaseAutomationEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[BaseAutomationEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
@ -163,12 +163,12 @@ def _automations_with_x(
hass: HomeAssistant, referenced_id: str, property_name: str
) -> list[str]:
"""Return all automations that reference the x."""
if DOMAIN_DATA not in hass.data:
if DATA_COMPONENT not in hass.data:
return []
return [
automation_entity.entity_id
for automation_entity in hass.data[DOMAIN_DATA].entities
for automation_entity in hass.data[DATA_COMPONENT].entities
if referenced_id in getattr(automation_entity, property_name)
]
@ -177,10 +177,10 @@ def _x_in_automation(
hass: HomeAssistant, entity_id: str, property_name: str
) -> list[str]:
"""Return all x in an automation."""
if DOMAIN_DATA not in hass.data:
if DATA_COMPONENT not in hass.data:
return []
if (automation_entity := hass.data[DOMAIN_DATA].get_entity(entity_id)) is None:
if (automation_entity := hass.data[DATA_COMPONENT].get_entity(entity_id)) is None:
return []
return list(getattr(automation_entity, property_name))
@ -254,7 +254,7 @@ def automations_with_blueprint(hass: HomeAssistant, blueprint_path: str) -> list
return [
automation_entity.entity_id
for automation_entity in hass.data[DOMAIN_DATA].entities
for automation_entity in hass.data[DATA_COMPONENT].entities
if automation_entity.referenced_blueprint == blueprint_path
]
@ -262,10 +262,10 @@ def automations_with_blueprint(hass: HomeAssistant, blueprint_path: str) -> list
@callback
def blueprint_in_automation(hass: HomeAssistant, entity_id: str) -> str | None:
"""Return the blueprint the automation is based on or None."""
if DOMAIN_DATA not in hass.data:
if DATA_COMPONENT not in hass.data:
return None
if (automation_entity := hass.data[DOMAIN_DATA].get_entity(entity_id)) is None:
if (automation_entity := hass.data[DATA_COMPONENT].get_entity(entity_id)) is None:
return None
return automation_entity.referenced_blueprint
@ -273,7 +273,7 @@ def blueprint_in_automation(hass: HomeAssistant, entity_id: str) -> str | None:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up all automations."""
hass.data[DOMAIN_DATA] = component = EntityComponent[BaseAutomationEntity](
hass.data[DATA_COMPONENT] = component = EntityComponent[BaseAutomationEntity](
LOGGER, DOMAIN, hass
)
@ -1204,7 +1204,7 @@ def websocket_config(
msg: dict[str, Any],
) -> None:
"""Get automation config."""
automation = hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])
automation = hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])
if automation is None:
connection.send_error(

View File

@ -29,7 +29,7 @@ from homeassistant.util.hass_dict import HassKey
_LOGGER = logging.getLogger(__name__)
DOMAIN = "binary_sensor"
DOMAIN_DATA: HassKey[EntityComponent[BinarySensorEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[BinarySensorEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -219,7 +219,7 @@ _DEPRECATED_DEVICE_CLASS_WINDOW = DeprecatedConstantEnum(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for binary sensors."""
component = hass.data[DOMAIN_DATA] = EntityComponent[BinarySensorEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[BinarySensorEntity](
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL
)
@ -229,12 +229,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class BinarySensorEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -25,7 +25,7 @@ from .const import DOMAIN, SERVICE_PRESS
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[ButtonEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[ButtonEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -49,7 +49,7 @@ DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.Coerce(ButtonDeviceClass))
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Button entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[ButtonEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[ButtonEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -65,12 +65,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class ButtonEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -43,8 +43,8 @@ from homeassistant.util.json import JsonValueType
from .const import (
CONF_EVENT,
DATA_COMPONENT,
DOMAIN,
DOMAIN_DATA,
EVENT_DESCRIPTION,
EVENT_DURATION,
EVENT_END,
@ -286,7 +286,7 @@ SERVICE_GET_EVENTS_SCHEMA: Final = vol.All(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for calendars."""
component = hass.data[DOMAIN_DATA] = EntityComponent[CalendarEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[CalendarEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -319,12 +319,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
def get_date(date: dict[str, Any]) -> datetime.datetime:
@ -707,7 +707,7 @@ async def handle_calendar_event_create(
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
) -> None:
"""Handle creation of a calendar event."""
if not (entity := hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])):
if not (entity := hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])):
connection.send_error(msg["id"], ERR_NOT_FOUND, "Entity not found")
return
@ -747,7 +747,7 @@ async def handle_calendar_event_delete(
) -> None:
"""Handle delete of a calendar event."""
if not (entity := hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])):
if not (entity := hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])):
connection.send_error(msg["id"], ERR_NOT_FOUND, "Entity not found")
return
@ -792,7 +792,7 @@ async def handle_calendar_event_update(
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
) -> None:
"""Handle creation of a calendar event."""
if not (entity := hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])):
if not (entity := hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])):
connection.send_error(msg["id"], ERR_NOT_FOUND, "Entity not found")
return

View File

@ -13,7 +13,7 @@ if TYPE_CHECKING:
from . import CalendarEntity
DOMAIN = "calendar"
DOMAIN_DATA: HassKey[EntityComponent[CalendarEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[CalendarEntity]] = HassKey(DOMAIN)
CONF_EVENT = "event"

View File

@ -24,7 +24,7 @@ from homeassistant.helpers.typing import ConfigType
from homeassistant.util import dt as dt_util
from . import CalendarEntity, CalendarEvent
from .const import DOMAIN, DOMAIN_DATA
from .const import DATA_COMPONENT, DOMAIN
_LOGGER = logging.getLogger(__name__)
@ -95,7 +95,7 @@ type QueuedEventFetcher = Callable[[Timespan], Awaitable[list[QueuedCalendarEven
def get_entity(hass: HomeAssistant, entity_id: str) -> CalendarEntity:
"""Get the calendar entity for the provided entity_id."""
component: EntityComponent[CalendarEntity] = hass.data[DOMAIN_DATA]
component: EntityComponent[CalendarEntity] = hass.data[DATA_COMPONENT]
if not (entity := component.get_entity(entity_id)) or not isinstance(
entity, CalendarEntity
):

View File

@ -71,9 +71,9 @@ from .const import ( # noqa: F401
CONF_DURATION,
CONF_LOOKBACK,
DATA_CAMERA_PREFS,
DATA_COMPONENT,
DATA_RTSP_TO_WEB_RTC,
DOMAIN,
DOMAIN_DATA,
PREF_ORIENTATION,
PREF_PRELOAD_STREAM,
SERVICE_RECORD,
@ -366,7 +366,7 @@ def async_register_rtsp_to_web_rtc_provider(
async def _async_refresh_providers(hass: HomeAssistant) -> None:
"""Check all cameras for any state changes for registered providers."""
component = hass.data[DOMAIN_DATA]
component = hass.data[DATA_COMPONENT]
await asyncio.gather(
*(camera.async_refresh_providers() for camera in component.entities)
)
@ -382,7 +382,7 @@ def _async_get_rtsp_to_web_rtc_providers(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the camera component."""
component = hass.data[DOMAIN_DATA] = EntityComponent[Camera](
component = hass.data[DATA_COMPONENT] = EntityComponent[Camera](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -457,12 +457,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
CACHED_PROPERTIES_WITH_ATTR_ = {

View File

@ -21,7 +21,7 @@ if TYPE_CHECKING:
from .prefs import CameraPreferences
DOMAIN: Final = "camera"
DOMAIN_DATA: HassKey[EntityComponent[Camera]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[Camera]] = HassKey(DOMAIN)
DATA_CAMERA_PREFS: HassKey[CameraPreferences] = HassKey("camera_prefs")
DATA_RTSP_TO_WEB_RTC: HassKey[dict[str, RtspToWebRtcProviderType]] = HassKey(

View File

@ -18,7 +18,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from . import Camera, _async_stream_endpoint_url
from .const import DOMAIN, DOMAIN_DATA, StreamType
from .const import DATA_COMPONENT, DOMAIN, StreamType
async def async_get_media_source(hass: HomeAssistant) -> CameraMediaSource:
@ -58,7 +58,7 @@ class CameraMediaSource(MediaSource):
async def async_resolve_media(self, item: MediaSourceItem) -> PlayMedia:
"""Resolve media to a url."""
component = self.hass.data[DOMAIN_DATA]
component = self.hass.data[DATA_COMPONENT]
camera = component.get_entity(item.identifier)
if not camera:
@ -107,7 +107,7 @@ class CameraMediaSource(MediaSource):
return _media_source_for_camera(self.hass, camera, content_type)
component = self.hass.data[DOMAIN_DATA]
component = self.hass.data[DATA_COMPONENT]
results = await asyncio.gather(
*(_filter_browsable_camera(camera) for camera in component.entities),
return_exceptions=True,

View File

@ -115,7 +115,7 @@ from .const import ( # noqa: F401
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[ClimateEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[ClimateEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -152,7 +152,7 @@ SET_TEMPERATURE_SCHEMA = vol.All(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up climate entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[ClimateEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[ClimateEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -225,12 +225,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class ClimateEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -35,9 +35,9 @@ from .const import (
ATTR_CONVERSATION_ID,
ATTR_LANGUAGE,
ATTR_TEXT,
DATA_COMPONENT,
DATA_DEFAULT_ENTITY,
DOMAIN,
DOMAIN_DATA,
HOME_ASSISTANT_AGENT,
OLD_HOME_ASSISTANT_AGENT,
SERVICE_PROCESS,
@ -149,7 +149,7 @@ def async_get_conversation_languages(
agents = [agent]
else:
agents = list(hass.data[DOMAIN_DATA].entities)
agents = list(hass.data[DATA_COMPONENT].entities)
for info in agent_manager.async_get_agent_info():
agent = agent_manager.async_get_agent(info.id)
assert agent is not None
@ -210,7 +210,7 @@ async def async_prepare_agent(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Register the process service."""
entity_component = EntityComponent[ConversationEntity](_LOGGER, DOMAIN, hass)
hass.data[DOMAIN_DATA] = entity_component
hass.data[DATA_COMPONENT] = entity_component
await async_setup_default_agent(
hass, entity_component, config.get(DOMAIN, {}).get("intents", {})
@ -269,9 +269,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)

View File

@ -12,8 +12,8 @@ from homeassistant.core import Context, HomeAssistant, async_get_hass, callback
from homeassistant.helpers import config_validation as cv, singleton
from .const import (
DATA_COMPONENT,
DATA_DEFAULT_ENTITY,
DOMAIN_DATA,
HOME_ASSISTANT_AGENT,
OLD_HOME_ASSISTANT_AGENT,
)
@ -57,7 +57,7 @@ def async_get_agent(
return hass.data[DATA_DEFAULT_ENTITY]
if "." in agent_id:
return hass.data[DOMAIN_DATA].get_entity(agent_id)
return hass.data[DATA_COMPONENT].get_entity(agent_id)
manager = get_agent_manager(hass)

View File

@ -26,7 +26,7 @@ ATTR_CONVERSATION_ID = "conversation_id"
SERVICE_PROCESS = "process"
SERVICE_RELOAD = "reload"
DOMAIN_DATA: HassKey[EntityComponent[ConversationEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[ConversationEntity]] = HassKey(DOMAIN)
DATA_DEFAULT_ENTITY: HassKey[DefaultAgent] = HassKey(f"{DOMAIN}_default_entity")

View File

@ -27,7 +27,7 @@ from .agent_manager import (
async_get_agent,
get_agent_manager,
)
from .const import DATA_DEFAULT_ENTITY, DOMAIN_DATA
from .const import DATA_COMPONENT, DATA_DEFAULT_ENTITY
from .default_agent import (
METADATA_CUSTOM_FILE,
METADATA_CUSTOM_SENTENCE,
@ -114,7 +114,7 @@ async def websocket_list_agents(
language = msg.get("language")
agents = []
for entity in hass.data[DOMAIN_DATA].entities:
for entity in hass.data[DATA_COMPONENT].entities:
supported_languages = entity.supported_languages
if language and supported_languages != MATCH_ALL:
supported_languages = language_util.matches(

View File

@ -47,7 +47,7 @@ from .const import DOMAIN, INTENT_CLOSE_COVER, INTENT_OPEN_COVER # noqa: F401
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[CoverEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[CoverEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -153,7 +153,7 @@ def is_closed(hass: HomeAssistant, entity_id: str) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for covers."""
component = hass.data[DOMAIN_DATA] = EntityComponent[CoverEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[CoverEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -233,12 +233,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class CoverEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -22,7 +22,7 @@ from .const import DOMAIN, SERVICE_SET_VALUE
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[DateEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[DateEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -39,7 +39,7 @@ async def _async_set_value(entity: DateEntity, service_call: ServiceCall) -> Non
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Date entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[DateEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[DateEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -53,12 +53,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class DateEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -22,7 +22,7 @@ from .const import ATTR_DATETIME, DOMAIN, SERVICE_SET_VALUE
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[DateTimeEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[DateTimeEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -42,7 +42,7 @@ async def _async_set_value(entity: DateTimeEntity, service_call: ServiceCall) ->
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Date/Time entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[DateTimeEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[DateTimeEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -60,12 +60,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class DateTimeEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -41,7 +41,7 @@ from .const import (
SourceType,
)
DOMAIN_DATA: HassKey[EntityComponent[BaseTrackerEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[BaseTrackerEntity]] = HassKey(DOMAIN)
DATA_KEY: HassKey[dict[str, tuple[str, str]]] = HassKey(f"{DOMAIN}_mac")
# mypy: disallow-any-generics
@ -54,7 +54,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if component is not None:
return await component.async_setup_entry(entry)
component = hass.data[DOMAIN_DATA] = EntityComponent[BaseTrackerEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[BaseTrackerEntity](
LOGGER, DOMAIN, hass
)
component.register_shutdown()
@ -64,7 +64,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload an entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
@callback

View File

@ -22,7 +22,7 @@ from homeassistant.util.hass_dict import HassKey
from .const import ATTR_EVENT_TYPE, ATTR_EVENT_TYPES, DOMAIN
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[EventEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[EventEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -53,7 +53,7 @@ __all__ = [
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Event entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[EventEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[EventEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -62,12 +62,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class EventEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -43,7 +43,7 @@ from homeassistant.util.percentage import (
_LOGGER = logging.getLogger(__name__)
DOMAIN = "fan"
DOMAIN_DATA: HassKey[EntityComponent[FanEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[FanEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -121,7 +121,7 @@ def is_on(hass: HomeAssistant, entity_id: str) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Expose fan control via statemachine and services."""
component = hass.data[DOMAIN_DATA] = EntityComponent[FanEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[FanEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -203,12 +203,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class FanEntityDescription(ToggleEntityDescription, frozen_or_thawed=True):

View File

@ -19,7 +19,7 @@ from homeassistant.util.hass_dict import HassKey
_LOGGER = logging.getLogger(__name__)
DOMAIN = "geo_location"
DOMAIN_DATA: HassKey[EntityComponent[GeolocationEvent]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[GeolocationEvent]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -34,7 +34,7 @@ ATTR_SOURCE = "source"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Geolocation component."""
component = hass.data[DOMAIN_DATA] = EntityComponent[GeolocationEvent](
component = hass.data[DATA_COMPONENT] = EntityComponent[GeolocationEvent](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -43,12 +43,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
CACHED_PROPERTIES_WITH_ATTR_ = {

View File

@ -48,8 +48,8 @@ from .const import ( # noqa: F401
ATTR_ORDER,
ATTR_REMOVE_ENTITIES,
CONF_HIDE_MEMBERS,
DATA_COMPONENT,
DOMAIN,
DOMAIN_DATA,
GROUP_ORDER,
REG_KEY,
)
@ -131,7 +131,7 @@ def groups_with_entity(hass: HomeAssistant, entity_id: str) -> list[str]:
return [
group.entity_id
for group in hass.data[DOMAIN_DATA].entities
for group in hass.data[DATA_COMPONENT].entities
if entity_id in group.tracking
]

View File

@ -16,7 +16,7 @@ CONF_HIDE_MEMBERS = "hide_members"
CONF_IGNORE_NON_NUMERIC = "ignore_non_numeric"
DOMAIN = "group"
DOMAIN_DATA: HassKey[EntityComponent[Group]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[Group]] = HassKey(DOMAIN)
REG_KEY: HassKey[GroupIntegrationRegistry] = HassKey(f"{DOMAIN}_registry")
GROUP_ORDER: HassKey[int] = HassKey("group_order")

View File

@ -22,7 +22,7 @@ from homeassistant.helpers.entity import Entity, async_generate_entity_id
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import async_track_state_change_event
from .const import ATTR_AUTO, ATTR_ORDER, DOMAIN, DOMAIN_DATA, GROUP_ORDER, REG_KEY
from .const import ATTR_AUTO, ATTR_ORDER, DATA_COMPONENT, DOMAIN, GROUP_ORDER, REG_KEY
from .registry import GroupIntegrationRegistry, SingleStateType
ENTITY_ID_FORMAT = DOMAIN + ".{}"
@ -478,8 +478,8 @@ class Group(Entity):
def async_get_component(hass: HomeAssistant) -> EntityComponent[Group]:
"""Get the group entity component."""
if (component := hass.data.get(DOMAIN_DATA)) is None:
component = hass.data[DOMAIN_DATA] = EntityComponent[Group](
if (component := hass.data.get(DATA_COMPONENT)) is None:
component = hass.data[DATA_COMPONENT] = EntityComponent[Group](
_PACKAGE_LOGGER, DOMAIN, hass
)
return component

View File

@ -62,7 +62,7 @@ from .const import ( # noqa: F401
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[HumidifierEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[HumidifierEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -96,7 +96,7 @@ def is_on(hass: HomeAssistant, entity_id: str) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up humidifier devices."""
component = hass.data[DOMAIN_DATA] = EntityComponent[HumidifierEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[HumidifierEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -125,12 +125,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class HumidifierEntityDescription(ToggleEntityDescription, frozen_or_thawed=True):

View File

@ -30,7 +30,7 @@ from homeassistant.helpers.event import (
from homeassistant.helpers.httpx_client import get_async_client
from homeassistant.helpers.typing import UNDEFINED, ConfigType, UndefinedType
from .const import DOMAIN, DOMAIN_DATA, IMAGE_TIMEOUT
from .const import DATA_COMPONENT, DOMAIN, IMAGE_TIMEOUT
_LOGGER = logging.getLogger(__name__)
@ -88,7 +88,7 @@ async def _async_get_image(image_entity: ImageEntity, timeout: int) -> Image:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the image component."""
component = hass.data[DOMAIN_DATA] = EntityComponent[ImageEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[ImageEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -120,12 +120,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
CACHED_PROPERTIES_WITH_ATTR_ = {

View File

@ -13,6 +13,6 @@ if TYPE_CHECKING:
DOMAIN: Final = "image"
DOMAIN_DATA: HassKey[EntityComponent[ImageEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[ImageEntity]] = HassKey(DOMAIN)
IMAGE_TIMEOUT: Final = 10

View File

@ -15,7 +15,7 @@ from homeassistant.components.media_source import (
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.core import HomeAssistant, State
from .const import DOMAIN, DOMAIN_DATA
from .const import DATA_COMPONENT, DOMAIN
async def async_get_media_source(hass: HomeAssistant) -> ImageMediaSource:
@ -35,7 +35,7 @@ class ImageMediaSource(MediaSource):
async def async_resolve_media(self, item: MediaSourceItem) -> PlayMedia:
"""Resolve media to a url."""
image = self.hass.data[DOMAIN_DATA].get_entity(item.identifier)
image = self.hass.data[DATA_COMPONENT].get_entity(item.identifier)
if not image:
raise Unresolvable(f"Could not resolve media item: {item.identifier}")
@ -65,7 +65,7 @@ class ImageMediaSource(MediaSource):
can_play=True,
can_expand=False,
)
for image in self.hass.data[DOMAIN_DATA].entities
for image in self.hass.data[DATA_COMPONENT].entities
]
return BrowseMediaSource(

View File

@ -26,7 +26,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[LawnMowerEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[LawnMowerEntity]] = HassKey(DOMAIN)
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
SCAN_INTERVAL = timedelta(seconds=60)
@ -34,7 +34,7 @@ SCAN_INTERVAL = timedelta(seconds=60)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the lawn_mower component."""
component = hass.data[DOMAIN_DATA] = EntityComponent[LawnMowerEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[LawnMowerEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -57,12 +57,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up lawn mower devices."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class LawnMowerEntityEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -32,7 +32,7 @@ import homeassistant.util.color as color_util
from homeassistant.util.hass_dict import HassKey
DOMAIN = "light"
DOMAIN_DATA: HassKey[EntityComponent[LightEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[LightEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -395,7 +395,7 @@ def filter_turn_on_params(light: LightEntity, params: dict[str, Any]) -> dict[st
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: C901
"""Expose light control via state machine and services."""
component = hass.data[DOMAIN_DATA] = EntityComponent[LightEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[LightEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -672,12 +672,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
def _coerce_none(value: str) -> None:

View File

@ -45,7 +45,7 @@ from .const import DOMAIN, LockState
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[LockEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[LockEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -78,7 +78,7 @@ PROP_TO_ATTR = {"changed_by": ATTR_CHANGED_BY, "code_format": ATTR_CODE_FORMAT}
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for locks."""
component = hass.data[DOMAIN_DATA] = EntityComponent[LockEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[LockEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -102,12 +102,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class LockEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -139,7 +139,7 @@ from .errors import BrowseError
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[MediaPlayerEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[MediaPlayerEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -278,7 +278,7 @@ def _rename_keys(**keys: Any) -> Callable[[dict[str, Any]], dict[str, Any]]:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for media_players."""
component = hass.data[DOMAIN_DATA] = EntityComponent[MediaPlayerEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[MediaPlayerEntity](
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL
)
@ -452,12 +452,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class MediaPlayerEntityDescription(EntityDescription, frozen_or_thawed=True):
@ -1294,7 +1294,7 @@ async def websocket_browse_media(
To use, media_player integrations can implement
MediaPlayerEntity.async_browse_media()
"""
player = hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])
player = hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])
if player is None:
connection.send_error(msg["id"], "entity_not_found", "Entity not found")

View File

@ -47,7 +47,7 @@ from .repairs import migrate_notify_issue # noqa: F401
# Platform specific data
ATTR_TITLE_DEFAULT = "Home Assistant"
DOMAIN_DATA: HassKey[EntityComponent[NotifyEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[NotifyEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
@ -78,7 +78,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
# legacy platforms to finish setting up.
hass.async_create_task(setup, eager_start=True)
component = hass.data[DOMAIN_DATA] = EntityComponent[NotifyEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[NotifyEntity](
_LOGGER, DOMAIN, hass
)
component.async_register_entity_service(
@ -117,12 +117,12 @@ class NotifyEntityDescription(EntityDescription, frozen_or_thawed=True):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class NotifyEntity(RestoreEntity):

View File

@ -50,7 +50,7 @@ from .websocket_api import async_setup as async_setup_ws_api
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[NumberEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[NumberEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -83,7 +83,7 @@ __all__ = [
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Number entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[NumberEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[NumberEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
async_setup_ws_api(hass)
@ -126,12 +126,12 @@ async def async_set_value(entity: NumberEntity, service_call: ServiceCall) -> No
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class NumberEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -37,7 +37,7 @@ from homeassistant.util.hass_dict import HassKey
_LOGGER = logging.getLogger(__name__)
DOMAIN = "remote"
DOMAIN_DATA: HassKey[EntityComponent[RemoteEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[RemoteEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -100,7 +100,7 @@ def is_on(hass: HomeAssistant, entity_id: str) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for remotes."""
component = hass.data[DOMAIN_DATA] = EntityComponent[RemoteEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[RemoteEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -157,12 +157,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class RemoteEntityDescription(ToggleEntityDescription, frozen_or_thawed=True):

View File

@ -20,7 +20,7 @@ from homeassistant.util import dt as dt_util
from homeassistant.util.hass_dict import HassKey
DOMAIN: Final = "scene"
DOMAIN_DATA: HassKey[EntityComponent[Scene]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[Scene]] = HassKey(DOMAIN)
STATES: Final = "states"
@ -62,7 +62,7 @@ PLATFORM_SCHEMA = vol.Schema(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the scenes."""
component = hass.data[DOMAIN_DATA] = EntityComponent[Scene](
component = hass.data[DATA_COMPONENT] = EntityComponent[Scene](
logging.getLogger(__name__), DOMAIN, hass
)
@ -85,12 +85,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class Scene(RestoreEntity):

View File

@ -32,7 +32,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[SelectEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[SelectEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -61,7 +61,7 @@ __all__ = [
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Select entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[SelectEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[SelectEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -101,12 +101,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class SelectEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -89,7 +89,7 @@ from .websocket_api import async_setup as async_setup_ws_api
_LOGGER: Final = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[SensorEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[SensorEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT: Final = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -117,7 +117,7 @@ __all__ = [
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for sensors."""
component = hass.data[DOMAIN_DATA] = EntityComponent[SensorEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[SensorEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -128,12 +128,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class SensorEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -39,7 +39,7 @@ from .const import ( # noqa: F401
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[SirenEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[SirenEntity]] = HassKey(DOMAIN)
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
SCAN_INTERVAL = timedelta(seconds=60)
@ -106,7 +106,7 @@ def process_turn_on_params(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up siren devices."""
component = hass.data[DOMAIN_DATA] = EntityComponent[SirenEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[SirenEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -145,12 +145,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class SirenEntityDescription(ToggleEntityDescription, frozen_or_thawed=True):

View File

@ -30,9 +30,9 @@ from homeassistant.loader import async_suggest_report_issue
from homeassistant.util import dt as dt_util, language as language_util
from .const import (
DATA_COMPONENT,
DATA_PROVIDERS,
DOMAIN,
DOMAIN_DATA,
AudioBitRates,
AudioChannels,
AudioCodecs,
@ -75,7 +75,7 @@ def async_default_engine(hass: HomeAssistant) -> str | None:
"""Return the domain or entity id of the default engine."""
default_entity_id: str | None = None
for entity in hass.data[DOMAIN_DATA].entities:
for entity in hass.data[DATA_COMPONENT].entities:
if entity.platform and entity.platform.platform_name == "cloud":
return entity.entity_id
@ -90,7 +90,7 @@ def async_get_speech_to_text_entity(
hass: HomeAssistant, entity_id: str
) -> SpeechToTextEntity | None:
"""Return stt entity."""
return hass.data[DOMAIN_DATA].get_entity(entity_id)
return hass.data[DATA_COMPONENT].get_entity(entity_id)
@callback
@ -108,7 +108,7 @@ def async_get_speech_to_text_languages(hass: HomeAssistant) -> set[str]:
"""Return a set with the union of languages supported by stt engines."""
languages = set()
for entity in hass.data[DOMAIN_DATA].entities:
for entity in hass.data[DATA_COMPONENT].entities:
for language_tag in entity.supported_languages:
languages.add(language_tag)
@ -123,7 +123,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up STT."""
websocket_api.async_register_command(hass, websocket_list_engines)
component = hass.data[DOMAIN_DATA] = EntityComponent[SpeechToTextEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[SpeechToTextEntity](
_LOGGER, DOMAIN, hass
)
@ -145,12 +145,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class SpeechToTextEntity(RestoreEntity):
@ -424,7 +424,7 @@ def websocket_list_engines(
providers = []
provider_info: dict[str, Any]
for entity in hass.data[DOMAIN_DATA].entities:
for entity in hass.data[DATA_COMPONENT].entities:
provider_info = {
"engine_id": entity.entity_id,
"supported_languages": entity.supported_languages,

View File

@ -14,7 +14,7 @@ if TYPE_CHECKING:
from .legacy import Provider
DOMAIN = "stt"
DOMAIN_DATA: HassKey[EntityComponent[SpeechToTextEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[SpeechToTextEntity]] = HassKey(DOMAIN)
DATA_PROVIDERS: HassKey[dict[str, Provider]] = HassKey(f"{DOMAIN}_providers")

View File

@ -34,7 +34,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[SwitchEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[SwitchEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -76,7 +76,7 @@ def is_on(hass: HomeAssistant, entity_id: str) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for switches."""
component = hass.data[DOMAIN_DATA] = EntityComponent[SwitchEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[SwitchEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -90,12 +90,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class SwitchEntityDescription(ToggleEntityDescription, frozen_or_thawed=True):

View File

@ -34,7 +34,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[TextEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[TextEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -48,7 +48,7 @@ __all__ = ["DOMAIN", "TextEntity", "TextEntityDescription", "TextMode"]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Text entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[TextEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[TextEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -83,12 +83,12 @@ async def _async_set_value(entity: TextEntity, service_call: ServiceCall) -> Non
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class TextMode(StrEnum):

View File

@ -22,7 +22,7 @@ from .const import DOMAIN, SERVICE_SET_VALUE
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[TimeEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[TimeEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -39,7 +39,7 @@ async def _async_set_value(entity: TimeEntity, service_call: ServiceCall) -> Non
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Time entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[TimeEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[TimeEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -53,12 +53,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class TimeEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -38,8 +38,8 @@ from .const import (
ATTR_ITEM,
ATTR_RENAME,
ATTR_STATUS,
DATA_COMPONENT,
DOMAIN,
DOMAIN_DATA,
TodoItemStatus,
TodoListEntityFeature,
TodoServices,
@ -114,7 +114,7 @@ def _validate_supported_features(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Todo entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[TodoListEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[TodoListEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -197,12 +197,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
@dataclasses.dataclass
@ -334,7 +334,7 @@ async def websocket_handle_subscribe_todo_items(
"""Subscribe to To-do list item updates."""
entity_id: str = msg["entity_id"]
if not (entity := hass.data[DOMAIN_DATA].get_entity(entity_id)):
if not (entity := hass.data[DATA_COMPONENT].get_entity(entity_id)):
connection.send_error(
msg["id"],
"invalid_entity_id",
@ -389,7 +389,7 @@ async def websocket_handle_todo_item_list(
"""Handle the list of To-do items in a To-do- list."""
if (
not (entity_id := msg[CONF_ENTITY_ID])
or not (entity := hass.data[DOMAIN_DATA].get_entity(entity_id))
or not (entity := hass.data[DATA_COMPONENT].get_entity(entity_id))
or not isinstance(entity, TodoListEntity)
):
connection.send_error(msg["id"], ERR_NOT_FOUND, "Entity not found")
@ -422,7 +422,7 @@ async def websocket_handle_todo_item_move(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any]
) -> None:
"""Handle move of a To-do item within a To-do list."""
if not (entity := hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])):
if not (entity := hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])):
connection.send_error(msg["id"], ERR_NOT_FOUND, "Entity not found")
return

View File

@ -13,7 +13,7 @@ if TYPE_CHECKING:
from . import TodoListEntity
DOMAIN = "todo"
DOMAIN_DATA: HassKey[EntityComponent[TodoListEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[TodoListEntity]] = HassKey(DOMAIN)
ATTR_DUE = "due"
ATTR_DUE_DATE = "due_date"

View File

@ -8,7 +8,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import intent
from . import TodoItem, TodoItemStatus, TodoListEntity
from .const import DOMAIN, DOMAIN_DATA
from .const import DATA_COMPONENT, DOMAIN
INTENT_LIST_ADD_ITEM = "HassListAddItem"
@ -49,7 +49,7 @@ class ListAddItemIntent(intent.IntentHandler):
result=match_result, constraints=match_constraints
)
target_list = hass.data[DOMAIN_DATA].get_entity(
target_list = hass.data[DATA_COMPONENT].get_entity(
match_result.states[0].entity_id
)
if target_list is None:

View File

@ -57,12 +57,12 @@ from .const import (
CONF_CACHE,
CONF_CACHE_DIR,
CONF_TIME_MEMORY,
DATA_COMPONENT,
DATA_TTS_MANAGER,
DEFAULT_CACHE,
DEFAULT_CACHE_DIR,
DEFAULT_TIME_MEMORY,
DOMAIN,
DOMAIN_DATA,
TtsAudioType,
)
from .helper import get_engine_instance
@ -140,7 +140,7 @@ def async_default_engine(hass: HomeAssistant) -> str | None:
"""
default_entity_id: str | None = None
for entity in hass.data[DOMAIN_DATA].entities:
for entity in hass.data[DATA_COMPONENT].entities:
if entity.platform and entity.platform.platform_name == "cloud":
return entity.entity_id
@ -158,7 +158,7 @@ def async_resolve_engine(hass: HomeAssistant, engine: str | None) -> str | None:
"""
if engine is not None:
if (
not hass.data[DOMAIN_DATA].get_entity(engine)
not hass.data[DATA_COMPONENT].get_entity(engine)
and engine not in hass.data[DATA_TTS_MANAGER].providers
):
return None
@ -200,7 +200,7 @@ def async_get_text_to_speech_languages(hass: HomeAssistant) -> set[str]:
"""Return a set with the union of languages supported by tts engines."""
languages = set()
for entity in hass.data[DOMAIN_DATA].entities:
for entity in hass.data[DATA_COMPONENT].entities:
for language_tag in entity.supported_languages:
languages.add(language_tag)
@ -317,7 +317,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return False
hass.data[DATA_TTS_MANAGER] = tts
component = hass.data[DOMAIN_DATA] = EntityComponent[TextToSpeechEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[TextToSpeechEntity](
_LOGGER, DOMAIN, hass
)
@ -365,12 +365,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
CACHED_PROPERTIES_WITH_ATTR_ = {
@ -1101,7 +1101,7 @@ def websocket_list_engines(
provider_info: dict[str, Any]
entity_domains: set[str] = set()
for entity in hass.data[DOMAIN_DATA].entities:
for entity in hass.data[DATA_COMPONENT].entities:
provider_info = {
"engine_id": entity.entity_id,
"supported_languages": entity.supported_languages,
@ -1149,7 +1149,7 @@ def websocket_get_engine(
provider: TextToSpeechEntity | Provider | None = next(
(
entity
for entity in hass.data[DOMAIN_DATA].entities
for entity in hass.data[DATA_COMPONENT].entities
if entity.entity_id == engine_id
),
None,

View File

@ -26,7 +26,7 @@ DEFAULT_CACHE_DIR = "tts"
DEFAULT_TIME_MEMORY = 300
DOMAIN = "tts"
DOMAIN_DATA: HassKey[EntityComponent[TextToSpeechEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[TextToSpeechEntity]] = HassKey(DOMAIN)
DATA_TTS_MANAGER: HassKey[SpeechManager] = HassKey("tts_manager")

View File

@ -6,7 +6,7 @@ from typing import TYPE_CHECKING
from homeassistant.core import HomeAssistant
from .const import DATA_TTS_MANAGER, DOMAIN_DATA
from .const import DATA_COMPONENT, DATA_TTS_MANAGER
if TYPE_CHECKING:
from . import TextToSpeechEntity
@ -17,7 +17,7 @@ def get_engine_instance(
hass: HomeAssistant, engine: str
) -> TextToSpeechEntity | Provider | None:
"""Get engine instance."""
if entity := hass.data[DOMAIN_DATA].get_entity(engine):
if entity := hass.data[DATA_COMPONENT].get_entity(engine):
return entity
return hass.data[DATA_TTS_MANAGER].providers.get(engine)

View File

@ -20,7 +20,7 @@ from homeassistant.components.media_source import (
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from .const import DATA_TTS_MANAGER, DOMAIN, DOMAIN_DATA
from .const import DATA_COMPONENT, DATA_TTS_MANAGER, DOMAIN
from .helper import get_engine_instance
URL_QUERY_TTS_OPTIONS = "tts_options"
@ -146,7 +146,7 @@ class TTSMediaSource(MediaSource):
for engine in self.hass.data[DATA_TTS_MANAGER].providers
] + [
self._engine_item(entity.entity_id)
for entity in self.hass.data[DOMAIN_DATA].entities
for entity in self.hass.data[DATA_COMPONENT].entities
]
return BrowseMediaSource(
domain=DOMAIN,

View File

@ -42,7 +42,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[UpdateEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[UpdateEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT: Final = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -80,7 +80,7 @@ __all__ = [
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Select entities."""
component = hass.data[DOMAIN_DATA] = EntityComponent[UpdateEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[UpdateEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -113,12 +113,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
async def async_install(entity: UpdateEntity, service_call: ServiceCall) -> None:
@ -492,7 +492,7 @@ async def websocket_release_notes(
msg: dict[str, Any],
) -> None:
"""Get the full release notes for a entity."""
entity = hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])
entity = hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])
if entity is None:
connection.send_error(

View File

@ -40,7 +40,7 @@ from .const import DOMAIN, STATE_CLEANING, STATE_DOCKED, STATE_ERROR, STATE_RETU
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[StateVacuumEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[StateVacuumEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -134,7 +134,7 @@ def is_on(hass: HomeAssistant, entity_id: str) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the vacuum component."""
component = hass.data[DOMAIN_DATA] = EntityComponent[StateVacuumEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[StateVacuumEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -197,12 +197,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class StateVacuumEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -33,7 +33,7 @@ from .const import DOMAIN, ValveState
_LOGGER = logging.getLogger(__name__)
DOMAIN_DATA: HassKey[EntityComponent[ValveEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[ValveEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -67,7 +67,7 @@ ATTR_POSITION = "position"
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Track states and offer events for valves."""
component = hass.data[DOMAIN_DATA] = EntityComponent[ValveEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[ValveEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
@ -111,12 +111,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
@dataclass(frozen=True, kw_only=True)

View File

@ -36,7 +36,7 @@ __all__ = [
_LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
DOMAIN_DATA: HassKey[EntityComponent[WakeWordDetectionEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[WakeWordDetectionEntity]] = HassKey(DOMAIN)
TIMEOUT_FETCH_WAKE_WORDS = 10
@ -52,14 +52,14 @@ def async_get_wake_word_detection_entity(
hass: HomeAssistant, entity_id: str
) -> WakeWordDetectionEntity | None:
"""Return wake word entity."""
return hass.data[DOMAIN_DATA].get_entity(entity_id)
return hass.data[DATA_COMPONENT].get_entity(entity_id)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up wake word."""
websocket_api.async_register_command(hass, websocket_entity_info)
component = hass.data[DOMAIN_DATA] = EntityComponent[WakeWordDetectionEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[WakeWordDetectionEntity](
_LOGGER, DOMAIN, hass
)
component.register_shutdown()
@ -69,12 +69,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class WakeWordDetectionEntity(RestoreEntity):
@ -141,7 +141,7 @@ async def websocket_entity_info(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
) -> None:
"""Get info about wake word entity."""
entity = hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])
entity = hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])
if entity is None:
connection.send_error(

View File

@ -40,7 +40,7 @@ from homeassistant.util.unit_conversion import TemperatureConverter
from .const import DOMAIN
DOMAIN_DATA: HassKey[EntityComponent[WaterHeaterEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[WaterHeaterEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@ -111,7 +111,7 @@ SET_OPERATION_MODE_SCHEMA: VolDictType = {
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up water_heater devices."""
component = hass.data[DOMAIN_DATA] = EntityComponent[WaterHeaterEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[WaterHeaterEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
@ -139,12 +139,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class WaterHeaterEntityEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -62,8 +62,8 @@ from .const import ( # noqa: F401
ATTR_WEATHER_WIND_GUST_SPEED,
ATTR_WEATHER_WIND_SPEED,
ATTR_WEATHER_WIND_SPEED_UNIT,
DATA_COMPONENT,
DOMAIN,
DOMAIN_DATA,
INTENT_GET_WEATHER,
UNIT_CONVERSIONS,
VALID_UNITS,
@ -197,7 +197,7 @@ class Forecast(TypedDict, total=False):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the weather component."""
component = hass.data[DOMAIN_DATA] = EntityComponent[WeatherEntity](
component = hass.data[DATA_COMPONENT] = EntityComponent[WeatherEntity](
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
component.async_register_entity_service(
@ -218,12 +218,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
class WeatherEntityDescription(EntityDescription, frozen_or_thawed=True):

View File

@ -54,7 +54,7 @@ ATTR_WEATHER_CLOUD_COVERAGE = "cloud_coverage"
ATTR_WEATHER_UV_INDEX = "uv_index"
DOMAIN: Final = "weather"
DOMAIN_DATA: HassKey[EntityComponent[WeatherEntity]] = HassKey(DOMAIN)
DATA_COMPONENT: HassKey[EntityComponent[WeatherEntity]] = HassKey(DOMAIN)
INTENT_GET_WEATHER = "HassGetWeather"

View File

@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.util.json import JsonValueType
from .const import DOMAIN, DOMAIN_DATA, VALID_UNITS, WeatherEntityFeature
from .const import DATA_COMPONENT, DOMAIN, VALID_UNITS, WeatherEntityFeature
FORECAST_TYPE_TO_FLAG = {
"daily": WeatherEntityFeature.FORECAST_DAILY,
@ -58,7 +58,7 @@ async def ws_subscribe_forecast(
entity_id: str = msg["entity_id"]
forecast_type: Literal["daily", "hourly", "twice_daily"] = msg["forecast_type"]
if not (entity := hass.data[DOMAIN_DATA].get_entity(msg["entity_id"])):
if not (entity := hass.data[DATA_COMPONENT].get_entity(msg["entity_id"])):
connection.send_error(
msg["id"],
"invalid_entity_id",