Overview
Package todo is Home Assistant's todo domain: its types.
Entity controls one todo entity over HTTP.
No method for todo.get_items, which only answer with data: call api.Client.CallServiceForResponse.
Home Assistant documents the domain here:
Integration: https://www.home-assistant.io/integrations/todo/
Entity model (developers): https://contributors.home-assistant.io/core/entities/todo/
Control
// client is an *api.Client
target := todo.Get(client, "my_todo")
state, err := target.State(ctx)
err = target.AddItem(ctx)
Commands
What each Entity method does on each transport. Home Assistant has no MQTT discovery for this domain.
| Method | Over HTTP, calls |
|---|---|
AddItem |
todo.add_item |
RemoveCompletedItems |
todo.remove_completed_items |
RemoveItem |
todo.remove_item |
UpdateItem |
todo.update_item |
Services without a method
Call these with the REST or WebSocket client.
| Service | Why |
|---|---|
todo.get_items | it only answers with data |
Control
type Entity struct
Entity controls one todo 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 todo entity with the given id: an entity id over HTTP (the "todo." prefix may be omitted). It does no I/O.
func List(ctx context.Context, transport entity.Transport) ([]*Entity, error)
List returns every todo entity the transport can see.
func (e *Entity) AddItem(ctx context.Context, options ...entity.ServiceOption) error
AddItem calls todo.add_item. It has no MQTT equivalent. Core describes the service: Adds a new to-do list item.
func (e *Entity) RemoveCompletedItems(ctx context.Context) error
RemoveCompletedItems calls todo.remove_completed_items. It has no MQTT equivalent. Core describes the service: Removes all to-do list items that have been completed.
func (e *Entity) RemoveItem(ctx context.Context, options ...entity.ServiceOption) error
RemoveItem calls todo.remove_item. It has no MQTT equivalent. Core describes the service: Removes an existing to-do list item by its name or UID.
func (e *Entity) UpdateItem(ctx context.Context, options ...entity.ServiceOption) error
UpdateItem calls todo.update_item. It has no MQTT equivalent. Core describes the service: Updates an existing to-do list item based on its name or UID.
type State = entity.State[Attributes]
State is a snapshot of one todo entity.
func Description(value string) entity.ServiceOption
Description sets the "description" service data field.
func DueDate(value string) entity.ServiceOption
DueDate sets the "due_date" service data field.
func DueDatetime(value string) entity.ServiceOption
DueDatetime sets the "due_datetime" service data field.
func Item(value string) entity.ServiceOption
Item sets the "item" service data field.
func Rename(value string) entity.ServiceOption
Rename sets the "rename" service data field.
func Status(value string) entity.ServiceOption
Status sets the "status" service data field.
State and values
type Attributes struct
Attributes are the state attributes of a todo entity, under the names Home Assistant publishes them with.
See: https://www.home-assistant.io/integrations/todo/
| Field | Type | Wire key | Description |
|---|---|---|---|
SupportedFeatures | Feature | supported_features | A set of Feature flags. |
Feature
type Feature uint64
Feature is a set of todo supported features, with the values of core's TodoListEntityFeature: the supported_features attribute decodes into it.
| Constant | Value |
|---|---|
FeatureUnknown | 0 |
FeatureCreateTodoItem | 1 << 0 |
FeatureDeleteTodoItem | 1 << 1 |
FeatureUpdateTodoItem | 1 << 2 |
FeatureMoveTodoItem | 1 << 3 |
FeatureSetDueDateOnItem | 1 << 4 |
FeatureSetDueDatetimeOnItem | 1 << 5 |
FeatureSetDescriptionOnItem | 1 << 6 |
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.
ItemStatus
type ItemStatus string
ItemStatus is core's TodoItemStatus.
| Constant | Value |
|---|---|
ItemStatusUnknown | "Unknown" |
ItemStatusNeedsAction | "needs_action" |
ItemStatusCompleted | "completed" |
func ItemStatusFromString(s string) ItemStatus
ItemStatusFromString returns the ItemStatus spelled s, by its value or by the name of core's member, and ItemStatusUnknown for anything else.
func (v *ItemStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON reads any spelling ItemStatusFromString accepts.
type TodoItem struct
TodoItem is core's TodoItem.
See: https://www.home-assistant.io/integrations/todo/
| Field | Type | Wire key | Description |
|---|---|---|---|
Completed | *ha.DateTime | completed | |
Description | *string | description | |
Due | *string | due | |
Status | *ItemStatus | status | |
Summary | *string | summary | |
Uid | *string | uid |