Skip to main content

To-do list entity

A To-do list entity is an entity that represents a To-do list. A To-do list contains To-do items which are ordered and have a status (complete or in progress). A To-do list entity is derived from the homeassistant.components.todo.TodoListEntity.

Properties

tip

Properties should only return information from memory and not do I/O (like network requests). Implement update() or async_update() to fetch data.

NameTypeDefaultDescription
todo_itemslist[TodoItem] | NoneNoneRequired. The ordered contents of the To-do list.

States

A TodoListEntity state is the count of incomplete items in the To-do list.

Supported features

Supported features are defined by using values in the TodoListEntityFeature enum and are combined using the bitwise or (|) operator.

ValueDescription
CREATE_TODO_ITEMEntity implements the methods to allow creation of to-do items.
DELETE_TODO_ITEMEntity implements the methods to allow deletion of to-do items.
UPDATE_TODO_ITEMEntity implements the methods to allow update of to-do items.
MOVE_TODO_ITEMEntity implements the methods to re-order to-do items.
DUE_DATEEntity implements to-do item due field as a datetime.date.
DUE_DATETIMEEntity implements to-do item due field as a datetime.datetime.
DESCRIPTIONEntity implements to-do item description field.

Methods

Create to-do items

A to-do list entity may support creating to-do items by specifying the CREATE_TODO_ITEM supported feature.

from homeassistant.components.todo import TodoListEntity

class MyTodoListEntity(TodoListEntity):

async def async_create_todo_item(self, item: TodoItem) -> None:
"""Add an item to the To-do list."""

Delete to-do items

A To-do list entity may support deleting to-do items by specifying the DELETE_TODO_ITEM supported feature. Integrations must support deleting multiple items.

from homeassistant.components.todo import TodoListEntity

class MyTodoListEntity(TodoListEntity):

async def async_delete_todo_items(self, uids: list[str]) -> None:
"""Delete an item from the to-do list."""

Update to-do items

A to-do list entity may support updating to-do items by specifying the UPDATE_TODO_ITEM supported feature. The TodoItem field uid is always present and indicates which item should be updated. The item passed to update is a copy of the original item with fields updated or cleared.

from homeassistant.components.todo import TodoListEntity

class MyTodoListEntity(TodoListEntity):

async def async_update_todo_item(self, item: TodoItem) -> None:
"""Add an item to the To-do list."""

Move to-do items

A to-do list entity may support re-ordering to-do items in the list by specifying the MOVE_TODO_ITEM supported feature. The to-do item with the specified uid should be moved to the position in the list after the one specified by previous_uid (None means move to the first position in the to-do list).

from homeassistant.components.todo import TodoListEntity

class MyTodoListEntity(TodoListEntity):

async def async_move_todo_item(
self,
uid: str,
previous_uid: str | None = None
) -> None:
"""Move an item in the To-do list."""

TodoItem

A TodoItem represents an individual item on a To-do list. The methods above describe any differences about which fields are optional on create or update.

NameTypeDefaultDescription
uidstring | NoneNoneA unique identifier for the to-do item. This field is required for updates and the entity state.
summarystring | NoneNoneA title or summary of the to-do item. This field is required for the entity state.
statusTodoItemStatus | NoneNoneDefines the overall status for the to-do item, either NEEDS_ACTION or COMPLETE. This field is required for the entity state.
duedatetime.date | datetime.datetime | NoneNoneThe date and time that a to-do is expected to be completed. The types supported depend on TodoListEntityFeature.DUE_DATE or TodoListEntityFeature.DUE_DATETIME or both being set. As a datetime, must have a timezone.
descriptionstring | NoneNoneA more complete description of the to-do item than that provided by the summary. Only supported when TodoListEntityFeature.DESCRIPTION is set.