Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.todoist.calendar.TodoistProjectData Class Reference

Public Member Functions

None __init__ (self, ProjectData project_data, list[Label] labels, TodoistCoordinator coordinator, int|None due_date_days=None, list[str]|None whitelisted_labels=None, list[str]|None whitelisted_projects=None)
 
list[CalendarEventasync_get_events (self, datetime start_date, datetime end_date)
 
CalendarEvent|None calendar_event (self)
 
def create_todoist_task (self, Task data)
 
None update (self)
 

Static Public Member Functions

TodoistEvent select_best_task (list[TodoistEvent] project_tasks)
 

Public Attributes

 event
 

Private Attributes

 _coordinator
 
 _due_date_days
 
 _id
 
 _label_whitelist
 
 _labels
 
 _name
 
 _project_id_whitelist
 

Detailed Description

Class used by the Task Entity service object to hold all Todoist Tasks.

This is analogous to the GoogleCalendarData found in the Google Calendar
component.

Takes an object with a 'name' field and optionally an 'id' field (either
user-defined or from the Todoist API), a Todoist API token, and an optional
integer specifying the latest number of days from now a task can be due (7
means everything due in the next week, 0 means today, etc.).

This object has an exposed 'event' property (used by the Calendar platform
to determine the next calendar event) and an exposed 'update' method (used
by the Calendar platform to poll for new calendar events).

The 'event' is a representation of a Todoist Task, with defined parameters
of 'due_today' (is the task due today?), 'all_day' (does the task have a
due date?), 'task_labels' (all labels assigned to the task), 'message'
(the content of the task, e.g. 'Fetch Mail'), 'description' (a URL pointing
to the task on the Todoist website), 'end_time' (what time the event is
due), 'start_time' (what time this event was last updated), 'overdue' (is
the task past its due date?), 'priority' (1-4, how important the task is,
with 4 being the most important), and 'all_tasks' (all tasks in this
project, sorted by how important they are).

'offset_reached', 'location', and 'friendly_name' are defined by the
platform itself, but are not used by this component at all.

The 'update' method polls the Todoist API for new projects/tasks, as well
as any updates to current projects/tasks. This occurs every SCAN_INTERVAL minutes.

Definition at line 429 of file calendar.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.todoist.calendar.TodoistProjectData.__init__ (   self,
ProjectData  project_data,
list[Label]  labels,
TodoistCoordinator  coordinator,
int | None   due_date_days = None,
list[str] | None   whitelisted_labels = None,
list[str] | None   whitelisted_projects = None 
)
Initialize a Todoist Project.

Definition at line 461 of file calendar.py.

Member Function Documentation

◆ async_get_events()

list[CalendarEvent] homeassistant.components.todoist.calendar.TodoistProjectData.async_get_events (   self,
datetime  start_date,
datetime   end_date 
)
Get all tasks in a specific time frame.

Definition at line 664 of file calendar.py.

◆ calendar_event()

CalendarEvent | None homeassistant.components.todoist.calendar.TodoistProjectData.calendar_event (   self)
Return the next upcoming calendar event.

Definition at line 501 of file calendar.py.

◆ create_todoist_task()

def homeassistant.components.todoist.calendar.TodoistProjectData.create_todoist_task (   self,
Task  data 
)
Create a dictionary based on a Task passed from the Todoist API.

Will return 'None' if the task is to be filtered out.

Definition at line 518 of file calendar.py.

◆ select_best_task()

TodoistEvent homeassistant.components.todoist.calendar.TodoistProjectData.select_best_task ( list[TodoistEvent project_tasks)
static
Search through a list of events for the "best" event to select.

The "best" event is determined by the following criteria:
  * A proposed event must not be completed
  * A proposed event must have an end date (otherwise we go with
    the event at index 0, selected above)
  * A proposed event must be on the same day or earlier as our
    current event
  * If a proposed event is an earlier day than what we have so
    far, select it
  * If a proposed event is on the same day as our current event
    and the proposed event has a higher priority than our current
    event, select it
  * If a proposed event is on the same day as our current event,
    has the same priority as our current event, but is due earlier
    in the day, select it

Definition at line 599 of file calendar.py.

◆ update()

None homeassistant.components.todoist.calendar.TodoistProjectData.update (   self)
Get the latest data.

Definition at line 695 of file calendar.py.

Member Data Documentation

◆ _coordinator

homeassistant.components.todoist.calendar.TodoistProjectData._coordinator
private

Definition at line 473 of file calendar.py.

◆ _due_date_days

homeassistant.components.todoist.calendar.TodoistProjectData._due_date_days
private

Definition at line 488 of file calendar.py.

◆ _id

homeassistant.components.todoist.calendar.TodoistProjectData._id
private

Definition at line 476 of file calendar.py.

◆ _label_whitelist

homeassistant.components.todoist.calendar.TodoistProjectData._label_whitelist
private

Definition at line 493 of file calendar.py.

◆ _labels

homeassistant.components.todoist.calendar.TodoistProjectData._labels
private

Definition at line 479 of file calendar.py.

◆ _name

homeassistant.components.todoist.calendar.TodoistProjectData._name
private

Definition at line 474 of file calendar.py.

◆ _project_id_whitelist

homeassistant.components.todoist.calendar.TodoistProjectData._project_id_whitelist
private

Definition at line 498 of file calendar.py.

◆ event

homeassistant.components.todoist.calendar.TodoistProjectData.event

Definition at line 711 of file calendar.py.


The documentation for this class was generated from the following file: