calendar

Go types for Home Assistant's calendar domain: control over HTTP.

Control: HTTP
import "github.com/taumatix/homeassistant-go/domains/calendar"

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.

MethodOver HTTP, calls
CreateEvent calendar.create_event

Services without a method

Call these with the REST or WebSocket client.

ServiceWhy
calendar.get_eventsit 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/

FieldTypeWire keyDescription
AllDayboolall_day

All day.

Description*stringdescription

Description.

EndTimestringend_time

End time.

Location*stringlocation

Location.

Messagestringmessage

Message.

StartTimestringstart_time

Start time.

SupportedFeaturesFeaturesupported_features

A set of Feature flags.

type Event struct

Event is core's CalendarEvent.

See: https://www.home-assistant.io/integrations/calendar/

FieldTypeWire keyDescription
Description*stringdescription
Endstringend
Location*stringlocation
RecurrenceId*stringrecurrence_id
Rrule*stringrrule
Startstringstart
Status*EventStatusstatus
Summarystringsummary
Uid*stringuid

EventStatus

type EventStatus string

EventStatus is core's CalendarEventStatus.

ConstantValue
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.

ConstantValue
FeatureUnknown0
FeatureCreateEvent1 << 0
FeatureDeleteEvent1 << 1
FeatureUpdateEvent1 << 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.