Time Tracking With NFC Tags On Android

Overview

NFC tags are relatively cheap solution to start timers (or any other tasks in Tasker) where GPS has an accuracy up to 50 metres. An NFC tag is down to the centimetres. NFC is less of a power draw however the trade off is it does not run in the background.

Requirements

I use Toggl Track as the time tracking software of choice. There’s a generous free tier and great API support.

I use the following apps on my mobile:
Tasker is needed like in the previous post to start timers.
AutoWeb aids calling web services and in this case Toggl
Trigger is another app which sets a unique ID on the NFC tags and then reads them and starts a task in Tasker.

AutoWeb Setup

The first and hardest part to set up was AutoWeb. There is a built in integration so set that up first.

Either download, unzip and import this or follow the basic manual configuration below.

Create a new Web Service and see the details below:

The username should be your API key which you can get from your profile. The password should be api_key.

Then click on the Web Service and add an API Action as per below which will start a timer:
AutoWeb Start Toggl Timer Settings

For other API end points, see Toggl’s documentation for more details.

Tasker

Next create all the supporting tasks to before a timer can be started. To start a timer, the API needs/wants the following which needs to come from Toggl API’s:

To make it as dynamic as possible, these will be pulled from Toggl so any new workspace / projects that are created will automatically be available in future tasks to start timers.

To save time, I have exported the tasks to file which can be downloaded from here. Unzip the file and copy the XML files and import them to tasker on your phone.

I’ll go through in order what each task does based on their file name:

  1. Refresh_Toggl_Project_Id_Array.tsk.xml(Refresh Toggl Project ID Array) – Fetches all projects in Toggl and saves them into a varable called %TOGGL_PROJECTS. It stores them as an array and can be used by other automations when there is no internet connection. The downside is the list needs it’s own automation to update the list of projects. My projects are faily stable so it runs every night. If you need to use a new project then run the task and it will update automatically.
  2. Get_Workspace_ID.tsk.xml(Get Workspace ID) – Gets the default Workspace ID for a given logged in user.
  3. Get_Project_Id.tsk.xml(Get Project ID) – Gets the ID for a given project based on the project name.
  4. Get_Project_Id_And_Workspace_Id.tsk.xml(Get Project ID And Workspace ID) – A task that uses the get workspace and project ID above in a single task to make any task that needs both to easier.
  5. Start_Timer_By_Project_Name.tsk.xml(Start Timer By Project Name) – Task to start a timer that has an associated project.
  6. Start_Work_Timer.tsk.xml(Start Work Timer) – Example task that will start my work timer. It uses all the above to achieve this.

Trigger

Trigger is freemium app but for my use I haven’t had to pay (yet). This app will manage the NFC tags. Make sure you have a task set up in task and run through the wizard to trigger a task in Tasker.

Summary


NFC are great way to trigger automations. It’s a shame it takes all the steps above to achieve it.

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Home Automation, Mobile Phone, Workflow and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *.

All comments must go through an approval and anti-spam process before appearing on the website. Please be patience and do not re-submit your comment if it does not appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.