Automation is supposed to be about simplifying everyday tasks to give you more precious time doing the things you love. At XDA, we’ve shown you how you can use Tasker to secure your device, improve productivity, or make driving safer, all a part of our series called ‘Tasker Week.’
But the fun doesn’t end there. If you’ve been itching for some seriously awesome Tasker tasks (and are tired of the boring stuff like telling you how to reboot your phone or shake your phone to wake the display), then our new Tasker Pro series is for you.
We will be posting a series of highly advanced Tasker profiles that will show you just how powerful Tasker can be if you are willing to think outside of the box. Although we’ve done most of the hard work for you and you’re certainly free to import my profiles and use them as is, I highly recommend you give learning how to use Tasker a shot if you want to be able to customize these tasks yourself. Over on our Tasker Tips & Tricks forums or on Reddit’s /r/Tasker subreddit, you can share and work with others on how to implement an idea you might have (as I have done many times).
This is Week 2 of Tasker pro. Last week, we showed you how you can use Tasker to automatically create a playlist of the most recently uploaded videos from your YouTube subscription list. As promised, this week we will show you how to track your mileage using Tasker.
Tasker Pro #2: Mileage Tracker/Driving Log
If your work requires you to drive your personal vehicle or you work multiple jobs and have to travel between workplaces, then you’re probably familiar with the fact that you can deduct your mileage from your taxes. In 2016, the IRS grants you a 54c/mile deduction on your taxes if your driving is strictly for business purposes. This means if you drove 25,000 miles this year, you could claim $13,500 in tax deductions. However, many people don’t keep adequate driving logs that prove to the IRS that they drove for business as much as they claimed, resulting in them losing their entire deduction after a tax audit.
If your taxes get audited, you’ll need adequate logs proving that you drove as much as you claimed. To do so, you’ll need a log that does the following:
- Tracks your mileage
- The date of your trip
- Where you drove
- Why you drove there
The more specific you are the better. There are many mileage tracker apps on the Play Store, but all of them require a subscription service of some kind. You’re supposed to be saving money not spending it! Here, I will show you how to create a driving log using Tasker, AutoWeb, and Spreadsheet Tasker Plugin.
Requirements
- Tasker ($2.99)
- AutoWeb (free while in beta)
- Spreadsheet Tasker Plugin (free)
The following are OPTIONAL but if you decide to import my profile then you will need these installed to replicate my set-up. My tutorial will also assume that you install these:
- Snackbar Tasker Plugin (free version works just fine here)
- AutoTools (free while in beta)
Instructions
Before we do anything with Tasker, you will first need to setup the spreadsheet you will be using as your mileage log. All you need to do is sign into your Google Drive account and create a new spreadsheet. Then just add the header line (in my screenshot above, the line colored orange) and exit.
Next, we need to setup AutoWeb. Open AutoWeb, then click on “Browse Web Services.”Look for the “Google Maps Geocode” API, click on it, and import it. Then look for the “Google Travel Distance Calculator” API, click on it, and import that too. No authentication should be needed for either API.
Now, we’re ready for the actual Tasker script. We will be making a Start task as well as an End task. The start task will save the time and location of your trip before you leave, and the end task will do the rest. Let’s begin with the start task.
- Create a task and name it “Start Mileage Tracker”.
- Location –> Get Location. Get the current location in terms of GPS coordinates.
- Variables –> Variable Set. Name %StartLoc to %LOC. Save the start coordinates into a variable.
- Variables –> Variable Set. Name %Date to %TIMES. Save the beginning time, as seconds since the epoch, so we can get a nicely formatted date.
- Plugin –> AutoTools –> Time. Dates to format: %Date. Format: yyyy-MM-dd*HH:mm. Use Seconds: true. What we’re doing here is getting the start date of the trip as well as the time, in one easy to access variable.
- Variables –> Variable Split. Name %atformatteddate(1). Splitter: *. We’re splitting the formatted variable into two separate variables, a date and a time.
- Variables –> Variable Set. Name %DepartureDate to %atformatteddate11. Save the date into its own variable.
- Variables –> Variable Set. Name %DepartureTime to %atformatteddate12. Save the time into its own variable.
That’s it for the start task. Now for the task that will run when you’re done driving.
- Create a task and name it “End Mileage Tracker”.
- Location –> Get Location. Get the current location in terms of GPS coordinates.
- Variables –> Variable Set. Name %endloc to %LOC. Set the ending location to its own variable.
- Plugin –> AutoWeb. API: Google Maps Geocode. API Action: Coordinate to Address. Latitude and Longitude: %StartLoc. For the output select Formatted Address. This will turn the starting location from coordinates into an actual address.
- Variables –> Variable Set. Name %origin to %formatted_address(). Save this address into a variable we will add to the spreadsheet.
- Plugin –> AutoWeb. API: Google Maps Geocode. API Action: Coordinate to Address. Latitude and Longitude: %endloc. For the output select Formatted Address. This will turn the ending location from coordinates into an actual address.
- Variables –> Variable Set. Name %destination to %formatted_address(). Save this address into a variable we will add to the spreadsheet.
- Plugin –> AutoWeb. API: Google Travel Distance Calculator. API Action: Distance. Origin: %StartLoc. Destination: %endloc. For the output select both Distance and Duration. Calculate the distance between your starting address and the ending address. Note that this gets the estimated distance based on the best route between the two locations, and may not be the same route you took. Nevertheless, it’s adequate for our purposes.
- Variables –> Variable Set. Name %distance to %distance*0.000621371. This will convert meters to miles. If you instead want the distance in kilometers, multiply distance by 1/1000.
- Variables –> Variable Set. Name %hours to floor(%duration/3600). This will calculate the amount of hours the trip took.
- Variables –> Variable Set. Name %minute to round((%duration/60)%60). This will calculate the amount of minutes the trip took, excluding the hours.
- Variables –> Variable Set. Name %duration to %hours:%minutes. Get the duration value in a neat format.
- Plugin –> Snackbar Tasker Plugin –> Bottom Sheet. Title: Type of Trip. Items: Personal,Business. Commands: Personal,Business. You can theme it however you want. This will ask you what kind of trip it was.
- Plugin –> Spreadsheet Tasker Plugin. Select your Google account, select the spreadsheet you made in the beginning. For the cells, type in: %DepartureDate;%DepartureTime;%duration;%bs_command;%distance;%origin;%destination. For the Output mode, select Append row. Click save. This will update the spreadsheet with all the data.
Note: You will need to go back and occasionally add travel notes to the spreadsheet, as there is really no way Tasker can do this part automatically. You COULD set it to prompt you for a text input and add that to the spreadsheet, but a lot of times you would rather just leave the car and move on.
And voila! If you are able to follow along this, then congratulations, you’re pretty much a master of Tasker! Confused on a step and just want to import the script and get on with your life? I can’t blame you, this one took myself a lot of thinking to get it down right.
If you want to import these tasks, you can download it from Android File Host. Start task can be downloaded here and the second one here. In order to import the task, you need to first disable Beginner Mode in Tasker by going to the menu –> preferences. Under the UI tab, uncheck ‘Beginner Mode.’ Then back in the main Tasker menu, click on the ‘Tasks’ tab. Then long-press on the ‘Tasks’ tab and press ‘Import.’ Navigate to where you downloaded my .tsk.xml file and select it to import it. Once you import it, you’re free to play around with it as you see fit. This task is standalone and can be coupled with any context to trigger it. I would recommend pairing the “Start” task with a context that fires when you connect to your car’s bluetooth, and the “End” task should be set as the exit task.
Next week for Tasker Pro I will show you how to automatically tag new photos with a calendar event. Save and categorize your most precious moments!
What would you like to see me make with Tasker? Let us know below and we might feature your idea in a future article!
from xda-developers http://ift.tt/1XMXLi4
via IFTTT .
Aucun commentaire:
Enregistrer un commentaire