Add specific EntityDescription to describe calendar entities (#126726)

pull/126725/head
epenet 2024-09-25 11:57:11 +02:00 committed by GitHub
parent bebd1dc235
commit 49efa4d47b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View File

@ -33,7 +33,7 @@ from homeassistant.core import (
)
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import async_track_point_in_time
from homeassistant.helpers.template import DATE_STR_FORMAT
@ -483,9 +483,15 @@ def is_offset_reached(
return start + offset_time <= dt_util.now(start.tzinfo)
class CalendarEntityDescription(EntityDescription, frozen_or_thawed=True):
"""A class that describes calendar entities."""
class CalendarEntity(Entity):
"""Base class for calendar event entities."""
entity_description: CalendarEntityDescription
_entity_component_unrecorded_attributes = frozenset({"description"})
_alarm_unsubs: list[CALLBACK_TYPE] | None = None

View File

@ -24,6 +24,7 @@ from homeassistant.components.calendar import (
EVENT_START,
EVENT_SUMMARY,
CalendarEntity,
CalendarEntityDescription,
CalendarEntityFeature,
CalendarEvent,
extract_offset,
@ -34,7 +35,7 @@ from homeassistant.const import CONF_DEVICE_ID, CONF_ENTITIES, CONF_NAME, CONF_O
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError, PlatformNotReady
from homeassistant.helpers import entity_platform, entity_registry as er
from homeassistant.helpers.entity import EntityDescription, generate_entity_id
from homeassistant.helpers.entity import generate_entity_id
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import dt as dt_util
@ -84,7 +85,7 @@ SERVICE_CREATE_EVENT = "create_event"
@dataclass(frozen=True, kw_only=True)
class GoogleCalendarEntityDescription(EntityDescription):
class GoogleCalendarEntityDescription(CalendarEntityDescription):
"""Google calendar entity description."""
name: str

View File

@ -28,7 +28,7 @@ _MODULES: dict[str, set[str]] = {
"assist_satellite": {"AssistSatelliteEntity", "AssistSatelliteEntityDescription"},
"binary_sensor": {"BinarySensorEntity", "BinarySensorEntityDescription"},
"button": {"ButtonEntity", "ButtonEntityDescription"},
"calendar": {"CalendarEntity"},
"calendar": {"CalendarEntity", "CalendarEntityDescription"},
"camera": {"Camera", "CameraEntityDescription"},
"climate": {"ClimateEntity", "ClimateEntityDescription"},
"coordinator": {"DataUpdateCoordinator"},