Todoist
This platform allows you to connect to your Todoist Projects and generate binary sensors. A different sensor will be created for each individual project, or you can specify “custom” projects which match against criteria you set (more on that below). These sensors will be on
if you have a task due in that project or off
if all the tasks in the project are completed or if the project doesn’t have any tasks at all. All tasks get updated roughly every 15 minutes.
Prerequisites
You need to determine your Todoist API token. This is fairly simple to do; just go to the Integrations section on your Todoist settings page and find the section labeled “API token” at the bottom of the page. Copy that token and use it in your configuration file.
Basic Setup
To integrate Todoist in Home Assistant, add the following section to your configuration.yaml
file:
# Example configuration.yaml entry
calendar:
- platform: todoist
token: API_token_created_from_steps_above
Configuration variables:
- token (Required): The API token used to authorize Home Assistant to access your projects.
- custom_projects (Optional): Details on any “custom” binary sensor projects you want to create.
- name (Required): The name of your custom project. Only required if you specify that you want to create a custom project.
- due_date_days (Optional): Only include tasks due within this many days. If you don’t have any tasks with a due date set, this returns nothing.
- labels (Optional): Only include tasks with at least one of these labels (i.e., this works as an
or
statement).. - include_projects (Optional): Only include tasks in these projects. Tasks in all other projects will be ignored.
Custom Projects
Creating custom projects is super-easy and quite powerful. All you need to run the basic Todoist projects is your API token, but if you wanted, you could go even deeper. Here’s an example:
# Example configuration.yaml entry
calendar:
- platform: todoist
token: !secret todoist_token
custom_projects:
- name: 'All Projects'
- name: 'Due Today'
due_date_days: 0
- name: 'Due This Week'
due_date_days: 7
- name: 'Math Homework'
labels:
- Homework
include_projects:
- Mathematical Structures II
- Calculus II
(See here for more details about what that !secret
does – it’s not exclusive to Todoist, and can help keep your API keys and passwords a little safer!)
As you can see, there are 4 custom projects here:
-
A project containing all of the tasks on this account.
-
A project containing all the tasks on this account that are due today.
-
A project containing all the tasks on this account due within the next week.
-
A project containing everything with the label “Homework”, taking only 2 projects into account.
You can mix-and-match these attributes to create all sorts of custom projects. You can even use IFTTT to create a task with a certain label, then have Home Assistant do some kind of automation when a task with that label comes due.
Home Assistant does its best to determine what task in each project is “most” important, and it’s that task which has its state reported. You can access the other tasks you have due soon via the all_tasks
array (see below).
Sensor attributes
-
offset_reached: Not used.
-
all_day:
True
if the reported task doesn’t have a due date.False
if there is a due date set. -
message: The title of the “most important” task coming up in this project.
-
description: A URL pointing to the task on the Todoist website.
-
location: Not used.
-
start_time: The last time the Todoist component got updated. Usually within the last 15 minutes.
-
end_time: When the task is due.
-
all_tasks: A list of all tasks in this project, sorted from most important to least important.
-
priority: The priority Todoist reports this task as having. 1 means lowest priority, 4 means highest. Note that this is the opposite of how things are displayed in the Todoist app!
-
task_comments: Any comments added to this task.
-
task_labels: All labels associated with this task.
-
overdue: Whether the reported task is past its due date.
-
due_today: Whether the reported task is due today.
Services
Todoist also comes with access to a service, calendar.todoist_new_task
. This service can be used to create a new Todoist task. You can specify labels and a project, or you can leave them blank, and the task will go to your “Inbox” project.
Here’s an example JSON payload:
{
"content": "Pick up the mail",
"project": "Errands",
"labels":"Homework,School",
"priority":3,
"due_date":"2017-09-12 14:00"
}
-
content (Required): The name of the task you want to create.
-
project (Optional): The project to put the task in.
-
labels (Optional): Any labels you want to add to the task, separated by commas.
-
priority (Optional): The priority of the task, from 1-4. Again, 1 means least important, and 4 means most important.
-
due_date (Optional): When the task should be due, in either YYYY-MM-DD format or YYYY-MM-DD HH:MM format.
Note that there’s (currently) no way to mark tasks as done through Home Assistant; task names do not necessarily have to be unique, so you could find yourself in a situation where you close the wrong task.