Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.calendar Namespace Reference

Namespaces

 const
 
 trigger
 

Classes

class  CalendarEntity
 
class  CalendarEntityDescription
 
class  CalendarEvent
 
class  CalendarEventView
 
class  CalendarListView
 

Functions

dict[str, Any] _api_event_dict_factory (Iterable[tuple[str, Any]] obj)
 
Callable[[dict[str, Any]], dict[str, Any]] _as_local_timezone (*Any keys)
 
str|None _empty_as_none (str|None value)
 
dict[str, str] _event_dict_factory (Iterable[tuple[str, Any]] obj)
 
dict[str, str] _get_api_date (datetime.datetime|datetime.date dt_or_d)
 
datetime.datetime _get_datetime_local (datetime.datetime|datetime.date dt_or_d)
 
Callable[[dict[str, Any]], dict[str, Any]] _has_consistent_timezone (*Any keys)
 
Callable[[dict[str, Any]], dict[str, Any]] _has_min_duration (str start_key, str end_key, datetime.timedelta min_duration)
 
Callable[[dict[str, Any]], dict[str, Any]] _has_same_type (*Any keys)
 
Callable[[dict[str, Any]], dict[str, Any]] _has_timezone (*Any keys)
 
dict[str, JsonValueType] _list_events_dict_factory (Iterable[tuple[str, Any]] obj)
 
str _validate_rrule (Any value)
 
tuple[datetime.datetime|datetime.date, datetime.datetime|datetime.date] _validate_timespan (dict[str, Any] values)
 
None async_create_event (CalendarEntity entity, ServiceCall call)
 
ServiceResponse async_get_events_service (CalendarEntity calendar, ServiceCall service_call)
 
bool async_setup (HomeAssistant hass, ConfigType config)
 
bool async_setup_entry (HomeAssistant hass, ConfigEntry entry)
 
bool async_unload_entry (HomeAssistant hass, ConfigEntry entry)
 
tuple[str, datetime.timedelta] extract_offset (str summary, str offset_prefix)
 
datetime.datetime get_date (dict[str, Any] date)
 
None handle_calendar_event_create (HomeAssistant hass, ActiveConnection connection, dict[str, Any] msg)
 
None handle_calendar_event_delete (HomeAssistant hass, ActiveConnection connection, dict[str, Any] msg)
 
None handle_calendar_event_update (HomeAssistant hass, ActiveConnection connection, dict[str, Any] msg)
 
bool is_offset_reached (datetime.datetime start, datetime.timedelta offset_time)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
 CALENDAR_EVENT_SCHEMA
 
 CREATE_EVENT_SCHEMA
 
string CREATE_EVENT_SERVICE = "create_event"
 
string ENTITY_ID_FORMAT = DOMAIN + ".{}"
 
 Final
 
 MIN_EVENT_DURATION = datetime.timedelta(seconds=0)
 
 MIN_NEW_EVENT_DURATION = datetime.timedelta(seconds=1)
 
 PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
 
 PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
 
 SCAN_INTERVAL = datetime.timedelta(seconds=60)
 
dictionary VALID_FREQS = {"DAILY", "WEEKLY", "MONTHLY", "YEARLY"}
 
 WEBSOCKET_EVENT_SCHEMA
 

Detailed Description

Support for Calendar event device sensors.

Function Documentation

◆ _api_event_dict_factory()

dict[str, Any] homeassistant.components.calendar._api_event_dict_factory ( Iterable[tuple[str, Any]]  obj)
private
Convert CalendarEvent dataclass items to the API format.

Definition at line 414 of file __init__.py.

◆ _as_local_timezone()

Callable[[dict[str, Any]], dict[str, Any]] homeassistant.components.calendar._as_local_timezone ( *Any  keys)
private
Convert all datetime values to the local timezone.

Definition at line 126 of file __init__.py.

◆ _empty_as_none()

str | None homeassistant.components.calendar._empty_as_none ( str | None  value)
private
Convert any empty string values to None.

Definition at line 193 of file __init__.py.

◆ _event_dict_factory()

dict[str, str] homeassistant.components.calendar._event_dict_factory ( Iterable[tuple[str, Any]]  obj)
private
Convert CalendarEvent dataclass items to dictionary of attributes.

Definition at line 403 of file __init__.py.

◆ _get_api_date()

dict[str, str] homeassistant.components.calendar._get_api_date ( datetime.datetime | datetime.date  dt_or_d)
private
Convert a calendar event date/datetime to a datetime if needed.

Definition at line 447 of file __init__.py.

◆ _get_datetime_local()

datetime.datetime homeassistant.components.calendar._get_datetime_local ( datetime.datetime | datetime.date  dt_or_d)
private
Convert a calendar event date/datetime to a datetime if needed.

Definition at line 438 of file __init__.py.

◆ _has_consistent_timezone()

Callable[[dict[str, Any]], dict[str, Any]] homeassistant.components.calendar._has_consistent_timezone ( *Any  keys)
private
Verify that all datetime values have a consistent timezone.

Definition at line 108 of file __init__.py.

◆ _has_min_duration()

Callable[[dict[str, Any]], dict[str, Any]] homeassistant.components.calendar._has_min_duration ( str  start_key,
str  end_key,
datetime.timedelta   min_duration 
)
private
Verify that the time span between start and end has a minimum duration.

Definition at line 139 of file __init__.py.

◆ _has_same_type()

Callable[[dict[str, Any]], dict[str, Any]] homeassistant.components.calendar._has_same_type ( *Any  keys)
private
Verify that all values are of the same type.

Definition at line 156 of file __init__.py.

◆ _has_timezone()

Callable[[dict[str, Any]], dict[str, Any]] homeassistant.components.calendar._has_timezone ( *Any  keys)
private
Assert that all datetime values have a timezone.

Definition at line 91 of file __init__.py.

◆ _list_events_dict_factory()

dict[str, JsonValueType] homeassistant.components.calendar._list_events_dict_factory ( Iterable[tuple[str, Any]]  obj)
private
Convert CalendarEvent dataclass items to dictionary of attributes.

Definition at line 427 of file __init__.py.

◆ _validate_rrule()

str homeassistant.components.calendar._validate_rrule ( Any  value)
private
Validate a recurrence rule string.

Definition at line 169 of file __init__.py.

◆ _validate_timespan()

tuple[datetime.datetime | datetime.date, datetime.datetime | datetime.date] homeassistant.components.calendar._validate_timespan ( dict[str, Any]  values)
private
Parse a create event service call and convert the args ofr a create event entity call.

This converts the input service arguments into a `start` and `end` date or date time. This
exists because service calls use `start_date` and `start_date_time` whereas the
normal entity methods can take either a `datetime` or `date` as a single `start` argument.
It also handles the other service call variations like "in days" as well.

Definition at line 824 of file __init__.py.

◆ async_create_event()

None homeassistant.components.calendar.async_create_event ( CalendarEntity  entity,
ServiceCall  call 
)
Add a new event to calendar.

Definition at line 852 of file __init__.py.

◆ async_get_events_service()

ServiceResponse homeassistant.components.calendar.async_get_events_service ( CalendarEntity  calendar,
ServiceCall   service_call 
)
List events on a calendar during a time range.

Definition at line 864 of file __init__.py.

◆ async_setup()

bool homeassistant.components.calendar.async_setup ( HomeAssistant  hass,
ConfigType  config 
)
Track states and offer events for calendars.

Definition at line 287 of file __init__.py.

◆ async_setup_entry()

bool homeassistant.components.calendar.async_setup_entry ( HomeAssistant  hass,
ConfigEntry  entry 
)
Set up a config entry.

Definition at line 320 of file __init__.py.

◆ async_unload_entry()

bool homeassistant.components.calendar.async_unload_entry ( HomeAssistant  hass,
ConfigEntry  entry 
)
Unload a config entry.

Definition at line 325 of file __init__.py.

◆ extract_offset()

tuple[str, datetime.timedelta] homeassistant.components.calendar.extract_offset ( str  summary,
str  offset_prefix 
)
Extract the offset from the event summary.

Return a tuple with the updated event summary and offset time.

Definition at line 454 of file __init__.py.

◆ get_date()

datetime.datetime homeassistant.components.calendar.get_date ( dict[str, Any]  date)
Get the dateTime from date or dateTime as a local.

Definition at line 330 of file __init__.py.

◆ handle_calendar_event_create()

None homeassistant.components.calendar.handle_calendar_event_create ( HomeAssistant  hass,
ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle creation of a calendar event.

Definition at line 706 of file __init__.py.

◆ handle_calendar_event_delete()

None homeassistant.components.calendar.handle_calendar_event_delete ( HomeAssistant  hass,
ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle delete of a calendar event.

Definition at line 745 of file __init__.py.

◆ handle_calendar_event_update()

None homeassistant.components.calendar.handle_calendar_event_update ( HomeAssistant  hass,
ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle creation of a calendar event.

Definition at line 791 of file __init__.py.

◆ is_offset_reached()

bool homeassistant.components.calendar.is_offset_reached ( datetime.datetime  start,
datetime.timedelta   offset_time 
)
Have we reached the offset time specified in the event title.

Definition at line 477 of file __init__.py.

Variable Documentation

◆ _LOGGER

homeassistant.components.calendar._LOGGER = logging.getLogger(__name__)
private

Definition at line 73 of file __init__.py.

◆ CALENDAR_EVENT_SCHEMA

homeassistant.components.calendar.CALENDAR_EVENT_SCHEMA
Initial value:
1 = vol.Schema(
2  vol.All(
3  {
4  vol.Required("start"): vol.Any(cv.date, cv.datetime),
5  vol.Required("end"): vol.Any(cv.date, cv.datetime),
6  vol.Required(EVENT_SUMMARY): cv.string,
7  vol.Optional(EVENT_RRULE): _validate_rrule,
8  },
9  _has_same_type("start", "end"),
10  _has_timezone("start", "end"),
11  _as_local_timezone("start", "end"),
12  _has_min_duration("start", "end", MIN_EVENT_DURATION),
13  ),
14  extra=vol.ALLOW_EXTRA,
15 )
Callable[[dict[str, Any]], dict[str, Any]] _as_local_timezone(*Any keys)
Definition: __init__.py:126
Callable[[dict[str, Any]], dict[str, Any]] _has_min_duration(str start_key, str end_key, datetime.timedelta min_duration)
Definition: __init__.py:141
Callable[[dict[str, Any]], dict[str, Any]] _has_same_type(*Any keys)
Definition: __init__.py:156
Callable[[dict[str, Any]], dict[str, Any]] _has_timezone(*Any keys)
Definition: __init__.py:91

Definition at line 255 of file __init__.py.

◆ CREATE_EVENT_SCHEMA

homeassistant.components.calendar.CREATE_EVENT_SCHEMA

Definition at line 199 of file __init__.py.

◆ CREATE_EVENT_SERVICE

string homeassistant.components.calendar.CREATE_EVENT_SERVICE = "create_event"

Definition at line 198 of file __init__.py.

◆ ENTITY_ID_FORMAT

string homeassistant.components.calendar.ENTITY_ID_FORMAT = DOMAIN + ".{}"

Definition at line 75 of file __init__.py.

◆ Final

homeassistant.components.calendar.Final

Definition at line 271 of file __init__.py.

◆ MIN_EVENT_DURATION

homeassistant.components.calendar.MIN_EVENT_DURATION = datetime.timedelta(seconds=0)

Definition at line 88 of file __init__.py.

◆ MIN_NEW_EVENT_DURATION

homeassistant.components.calendar.MIN_NEW_EVENT_DURATION = datetime.timedelta(seconds=1)

Definition at line 84 of file __init__.py.

◆ PLATFORM_SCHEMA

homeassistant.components.calendar.PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA

Definition at line 76 of file __init__.py.

◆ PLATFORM_SCHEMA_BASE

homeassistant.components.calendar.PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE

Definition at line 77 of file __init__.py.

◆ SCAN_INTERVAL

homeassistant.components.calendar.SCAN_INTERVAL = datetime.timedelta(seconds=60)

Definition at line 78 of file __init__.py.

◆ VALID_FREQS

dictionary homeassistant.components.calendar.VALID_FREQS = {"DAILY", "WEEKLY", "MONTHLY", "YEARLY"}

Definition at line 81 of file __init__.py.

◆ WEBSOCKET_EVENT_SCHEMA

homeassistant.components.calendar.WEBSOCKET_EVENT_SCHEMA
Initial value:
1 = vol.Schema(
2  vol.All(
3  {
4  vol.Required(EVENT_START): vol.Any(cv.date, cv.datetime),
5  vol.Required(EVENT_END): vol.Any(cv.date, cv.datetime),
6  vol.Required(EVENT_SUMMARY): cv.string,
7  vol.Optional(EVENT_DESCRIPTION): cv.string,
8  vol.Optional(EVENT_LOCATION): cv.string,
9  vol.Optional(EVENT_RRULE): _validate_rrule,
10  },
11  _has_same_type(EVENT_START, EVENT_END),
12  _has_consistent_timezone(EVENT_START, EVENT_END),
13  _as_local_timezone(EVENT_START, EVENT_END),
14  _has_min_duration(EVENT_START, EVENT_END, MIN_NEW_EVENT_DURATION),
15  )
16 )
Callable[[dict[str, Any]], dict[str, Any]] _has_consistent_timezone(*Any keys)
Definition: __init__.py:108

Definition at line 237 of file __init__.py.