Overview
Package calendar is Home Assistant's calendar domain: its types.
Entity controls one calendar entity over HTTP.
No method for calendar.get_events, which only answer with data: call api.Client.CallServiceForResponse.
Home Assistant documents the domain here:
Integration: https://www.home-assistant.io/integrations/calendar/
Entity model (developers): https://contributors.home-assistant.io/core/entities/calendar/
Control
// client is an *api.Client
target := calendar.Get(client, "my_calendar")
state, err := target.State(ctx)
err = target.CreateEvent(ctx)
Commands
What each Entity method does on each transport. Home Assistant has no MQTT discovery for this domain.
| Method | Over HTTP, calls |
|---|---|
CreateEvent |
calendar.create_event |
Services without a method
Call these with the REST or WebSocket client.
| Service | Why |
|---|---|
calendar.get_events | it only answers with data |
Control
type Entity struct
Entity controls one calendar entity over HTTP (api.Client). State and Subscribe come from the embedded Handle.
Embeds entity.Handle[Attributes], whose methods it has too.
func Get(transport entity.Transport, id string) *Entity
Get returns the calendar entity with the given id: an entity id over HTTP (the "calendar." prefix may be omitted). It does no I/O.
func List(ctx context.Context, transport entity.Transport) ([]*Entity, error)
List returns every calendar entity the transport can see.
func (e *Entity) CreateEvent(ctx context.Context, options ...entity.ServiceOption) error
CreateEvent calls calendar.create_event. It has no MQTT equivalent. Core describes the service: Adds a new calendar event.
type State = entity.State[Attributes]
State is a snapshot of one calendar entity.
func Description(value string) entity.ServiceOption
Description sets the "description" service data field.
func EndDate(value string) entity.ServiceOption
EndDate sets the "end_date" service data field.
func EndDateTime(value string) entity.ServiceOption
EndDateTime sets the "end_date_time" service data field.
func In(value map[string]any) entity.ServiceOption
In sets the "in" service data field.
func Location(value string) entity.ServiceOption
Location sets the "location" service data field.
func StartDate(value string) entity.ServiceOption
StartDate sets the "start_date" service data field.
func StartDateTime(value string) entity.ServiceOption
StartDateTime sets the "start_date_time" service data field.
func Summary(value string) entity.ServiceOption
Summary sets the "summary" service data field.
State and values
type Attributes struct
Attributes are the state attributes of a calendar entity, under the names Home Assistant publishes them with.
See: https://www.home-assistant.io/integrations/calendar/
| Field | Type | Wire key | Description |
|---|---|---|---|
AllDay | bool | all_day | All day. |
Description | *string | description | Description. |
EndTime | string | end_time | End time. |
Location | *string | location | Location. |
Message | string | message | Message. |
StartTime | string | start_time | Start time. |
SupportedFeatures | Feature | supported_features | A set of Feature flags. |
type Event struct
Event is core's CalendarEvent.
See: https://www.home-assistant.io/integrations/calendar/
| Field | Type | Wire key | Description |
|---|---|---|---|
Description | *string | description | |
End | string | end | |
Location | *string | location | |
RecurrenceId | *string | recurrence_id | |
Rrule | *string | rrule | |
Start | string | start | |
Status | *EventStatus | status | |
Summary | string | summary | |
Uid | *string | uid |
EventStatus
type EventStatus string
EventStatus is core's CalendarEventStatus.
| Constant | Value |
|---|---|
EventStatusUnknown | "Unknown" |
EventStatusConfirmed | "confirmed" |
EventStatusTentative | "tentative" |
func EventStatusFromString(s string) EventStatus
EventStatusFromString returns the EventStatus spelled s, by its value or by the name of core's member, and EventStatusUnknown for anything else.
func (v *EventStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON reads any spelling EventStatusFromString accepts.
Feature
type Feature uint64
Feature is a set of calendar supported features, with the values of core's CalendarEntityFeature: the supported_features attribute decodes into it.
| Constant | Value |
|---|---|
FeatureUnknown | 0 |
FeatureCreateEvent | 1 << 0 |
FeatureDeleteEvent | 1 << 1 |
FeatureUpdateEvent | 1 << 2 |
func FeatureFromString(s string) Feature
FeatureFromString returns the Feature spelled s, by its value or by the name of core's member, and FeatureUnknown for anything else.