Tasker scripts to integrate "Clockwork Tomato" Pomodoro timer for Android with Habitica
This process will require Tasker, a paid Android app, and Clockwork Tomato, which is available without payment. It will also require you to store your API Token in Tasker, and to configure Tasker and Clockwork Tomato to work together and to communicate with Habitica. Users who aren't sure they want to invest the money or time should review the steps and consider.
Create Habitica Habits Edit
The first step is to create Habitica Habits that will be triggered by the completion or interruption of a Pomodoro. This guide assumes that you want two habits:
- "Pomodoro" - a basic habit that will be incremented on the completion of a normal Pomodoro or decremented if you interrupt or stop a Pomodoro without completion; and
- "Pomodoro Set" - a habit to record the completion of the final Pomodoro in a set.
If so, create two Habits as pictured in this section.
If you use the Habitica web client as well as the Android client, I recommend that you create these tasks by installing the Habitica Chrome Extension, choosing Options in the extension, and enabling "Tomato.es Integration" and "Pomodoro Tracker Integration." This will create two Pomodoro habits in your task list. (Do not rename those tasks or you will break the Chrome Extension integration). This way, the Chrome extension and the Tasker integration will use the same habits to record Pomodori.
In order to avoid skewing your results, I also recommend that you set both Pomodoro habits to trivial difficulty. Feel free to name the Habits anything you like - later, you will be using an internal TaskID to match the habits with events on your Android device.
Install Android Apps Edit
Note: it is also possible to configure Pomodroido or any other Tasker-compatible Android Pomodoro timer to work with this method, although some of the steps required in the sections below will change. For more information on using Pomodroido instead of Clockwork Tomato, please see Blnk2007's guide.
Configure Tasker Edit
Tasker is an extremely powerful Android utility that executes user defined tasks based on changes to the phone or its applications. For this project, we will be (1) configuring Tasker to communicate with the Habitica API, and (2) configuring a set of "tasks" for Tasker to execute when a Pomodoro starts or stops.
First, enable external access to allow Clockwork Tomato to communicate with Tasker. In the Tasker app, select the three dot menu on the upper right, then select "Preferences," then the "Misc" tab, then make sure "Allow External Access" is checked.
For this step:
b. Configure the script by opening it with a text editor and uncommenting and including your data the following lines:
// // Only need to be set once; they are Global variables, and survive reboots // setGlobal('HabitrpgUserid', '########-####-####-####-############'); // setGlobal('HabitrpgApiToken', '########-####-####-####-############'); // setGlobal('HabitrpgCDS', '0'); // Custom Day Start value, 0 if not set
// // Only need to be set once; they are Global variables, and survive reboots setGlobal('HabitrpgUserid', '<your user id>'); setGlobal('HabitrpgApiToken', '<your API token>'); setGlobal('HabitrpgCDS', '0'); // Custom Day Start value, 0 if not set
After the first time you execute this integration successfully, you can remove these values from the text file, but be aware that Tasker will continue to store your API Token internally.
Create Tasks Edit
For this step, we will create a series of "Tasks" that Tasker will execute under appropriate conditions.
To import this task,
- Copy the XML information from score_a_task.tsk.xml to a text file with the same name somewhere you can find it on your Android device, like a /Tasker/Tasks directory.
- Import that file into a new task by opening Tasker, then tapping the Tasks tab and selecting Import. After selecting Import, browse to the folder where you stored the "score_a_task.tsk.xml" file and click to select it. If successful, you should have a new task labeled "Score a task". This task accepts two arguments, TaskID and direction (up or down) and then uses the Habitica API to check either the up or down button on the identified task.
Note that the fifth step in this task is to display the result of that API call, which will be the new Task Value of the identified task. Once you are satisfied that the integration is working correctly, you may want to delete that step to reduce clutter.
This task is designed to occur then Clockwork Tomato starts a Pomodoro. It does some housekeeping as follows: (1) If the Pomodoro is the first one that day, it resets the Pomorodo count to 0 and records the new date; and (2) it sets a timer to allow the Tomatostop task to check if a stopped Pomodoro was completed or interrupted.
To install and customize this task:
- Copy or download the code from the Tomatostart.tsk.xml file in this GitHub directory to a text file of the same name in the tasks folder on your Android device.
- Import that task to Tasker.
- Find the Task IDs of your two Pomodoro tasks by logging in to the Habitica Data Display Tool, selecting "Task Overview" and then selecting "Toggle Developer Data." (If you would like to record all Pomodoro events in a single habit, just use the Task ID for that habit for both %Pomoid and %Bigpomoid below).
- In Tasker, select the "Tomatostart" task, and edit the following variables:
- Set the variable %Pomoid to be the Task ID (including dashes) for your individual Pomodoro habit;
- Set the variable %Bigpomoid to be the Task ID (including dashes) for your Pomodoro Set habit;
- If you have a Pomodoro set size other than 4, set %Pomosetsize to that number; and
- If you do not want status updates appearing on your device, set %Pomoverbose to any value other than yes.
This task is designed to occur when Clockwork Tomato stops a Pomodoro. It: (1) checks to see if the Pomodoro was completed or interrupted by comparing the elapsed time since start with the goal time; (2) if the Pomodoro was completed, it increments the Pomodoro count by one and upscores either the base Pododoro habit or the combo habit by one check as appropriate; and (3) if the Pomodoro was interrupted, it downscores the base Pomodoro habit by one check.
Similar to the previous two tasks, install this task by the following steps:
- Copy or download the code from Tomatostart.tsk.xml in this GitHub directory to a text file of the same name in the tasks folder on your Android device.
- Import that task to Tasker.
Configure Clockwork Tomato EditThe final step is to configure Clockwork Tomato to activate the Tomatostart and Tomatostop tasks when a Pomodoro is started and stopped, respectively.
- In the Clockwork Tomato app, choose the gear menu in the top right and select "Tasker"
- Make sure the check box for "Call Tasker Tasks" is enabled
- Associate "When a pomodoro starts" with "Tomatostart"
- Associate "When a pomodoro stops" with "Tomatostop"
If configured successfully, this integration will (1) increment your Pomodoro Set habit for the completion of each set of Pomodori, (2) increment your basic Pomodoro habit for the completion of each Pomodoro that is not the last one in a set, and (3) decrement your basic Pomodoro habit for any Pomodoro that was stopped prior to completion. If you prefer different behavior, you can adjust the Tasker code to your preference.