mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add specific EntityDescription to describe calendar entities (#126726)
This commit is contained in:
parent
bebd1dc235
commit
49efa4d47b
@ -33,7 +33,7 @@ from homeassistant.core import (
|
|||||||
)
|
)
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv
|
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.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.event import async_track_point_in_time
|
from homeassistant.helpers.event import async_track_point_in_time
|
||||||
from homeassistant.helpers.template import DATE_STR_FORMAT
|
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)
|
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):
|
class CalendarEntity(Entity):
|
||||||
"""Base class for calendar event entities."""
|
"""Base class for calendar event entities."""
|
||||||
|
|
||||||
|
entity_description: CalendarEntityDescription
|
||||||
|
|
||||||
_entity_component_unrecorded_attributes = frozenset({"description"})
|
_entity_component_unrecorded_attributes = frozenset({"description"})
|
||||||
|
|
||||||
_alarm_unsubs: list[CALLBACK_TYPE] | None = None
|
_alarm_unsubs: list[CALLBACK_TYPE] | None = None
|
||||||
|
@ -24,6 +24,7 @@ from homeassistant.components.calendar import (
|
|||||||
EVENT_START,
|
EVENT_START,
|
||||||
EVENT_SUMMARY,
|
EVENT_SUMMARY,
|
||||||
CalendarEntity,
|
CalendarEntity,
|
||||||
|
CalendarEntityDescription,
|
||||||
CalendarEntityFeature,
|
CalendarEntityFeature,
|
||||||
CalendarEvent,
|
CalendarEvent,
|
||||||
extract_offset,
|
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.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import HomeAssistantError, PlatformNotReady
|
from homeassistant.exceptions import HomeAssistantError, PlatformNotReady
|
||||||
from homeassistant.helpers import entity_platform, entity_registry as er
|
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.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
@ -84,7 +85,7 @@ SERVICE_CREATE_EVENT = "create_event"
|
|||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class GoogleCalendarEntityDescription(EntityDescription):
|
class GoogleCalendarEntityDescription(CalendarEntityDescription):
|
||||||
"""Google calendar entity description."""
|
"""Google calendar entity description."""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
|
@ -28,7 +28,7 @@ _MODULES: dict[str, set[str]] = {
|
|||||||
"assist_satellite": {"AssistSatelliteEntity", "AssistSatelliteEntityDescription"},
|
"assist_satellite": {"AssistSatelliteEntity", "AssistSatelliteEntityDescription"},
|
||||||
"binary_sensor": {"BinarySensorEntity", "BinarySensorEntityDescription"},
|
"binary_sensor": {"BinarySensorEntity", "BinarySensorEntityDescription"},
|
||||||
"button": {"ButtonEntity", "ButtonEntityDescription"},
|
"button": {"ButtonEntity", "ButtonEntityDescription"},
|
||||||
"calendar": {"CalendarEntity"},
|
"calendar": {"CalendarEntity", "CalendarEntityDescription"},
|
||||||
"camera": {"Camera", "CameraEntityDescription"},
|
"camera": {"Camera", "CameraEntityDescription"},
|
||||||
"climate": {"ClimateEntity", "ClimateEntityDescription"},
|
"climate": {"ClimateEntity", "ClimateEntityDescription"},
|
||||||
"coordinator": {"DataUpdateCoordinator"},
|
"coordinator": {"DataUpdateCoordinator"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user