Use HassKey in core components (a-c) (#126258)

* Use HassKey in conversation

* Use HassKey in assist_satellite

* automation

* More

* Unrelated

* Improve
This commit is contained in:
epenet
2024-09-20 12:07:15 +02:00
committed by GitHub
parent ef94fcf873
commit 8b44c16b57
20 changed files with 125 additions and 108 deletions

View File

@@ -24,10 +24,12 @@ from homeassistant.helpers.deprecation import (
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.hass_dict import HassKey
_LOGGER = logging.getLogger(__name__)
DOMAIN = "binary_sensor"
DOMAIN_DATA: HassKey[EntityComponent[BinarySensorEntity]] = HassKey(DOMAIN)
ENTITY_ID_FORMAT = DOMAIN + ".{}"
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
@@ -217,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] = EntityComponent[BinarySensorEntity](
component = hass.data[DOMAIN_DATA] = EntityComponent[BinarySensorEntity](
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL
)
@@ -227,14 +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."""
component: EntityComponent[BinarySensorEntity] = hass.data[DOMAIN]
return await component.async_setup_entry(entry)
return await hass.data[DOMAIN_DATA].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
component: EntityComponent[BinarySensorEntity] = hass.data[DOMAIN]
return await component.async_unload_entry(entry)
return await hass.data[DOMAIN_DATA].async_unload_entry(entry)
class BinarySensorEntityDescription(EntityDescription, frozen_or_thawed=True):