GETTING ACCESS TO SMARTAPP ENDPOINTS
In order to get SmartThings working with Tasker on Android, I will assume you’ve completed Danny’s Endpoint API tutorial here. (old link sorry) You will need to be able to host your own PHP file as per Danny’s instructions, because at the time of this post, Danny’s hosted PHP file is down.
PREPPING TASKER
Once you have finished Danny’s tutorial, the first thing we need to do on our Android smartphone is allow External Access, which will allow apps like NFC Task Launcher (see Part 2: NFC) to initiate Tasker tasks.
Step 1: Open Tasker, tap the Menu button and go to Preferences.
Step 2: Check the “Allow External Access” option and click the X in the top right corner.
AUTHORIZING ACCESS TO YOUR DEVICES
Now it’s time to get the Endpoint URL(s) that we’ll use to send commands to our devices. We’ll do this through the Android smartphone, so that we can copy/paste the long URLs instead of having to type them out.
Step 3: Open the browser on your phone and navigate to your hosted PHP file. Login to your ST account.
Step 4: Select your Hub from the dropdown, check the devices you want to create URLs for, and tap “Authorize”.
Step 5: Find the first device you’d like to control with Tasker and tap-and-hold the “Toggle” button. I’ll be using my living room light as an example.
Step 6: Tap “Copy Link Address” to copy the full URL to the clipboard.
CREATING TASKER TASKS
This is where the magic happens. We’re now going to create the task in Tasker that can be used for an infinite number of purposes: Location-based triggering, Phone state-based triggering, NFC triggering, Voice control, and so on…the possibilities are endless. (I’ll be talking about NFC more in Part 2 and Voice control in Part 3, coming soon.)
Step 7: Open Tasker again, go to the Tasks tab and tap the “+” to create a new task.
Step 8: Name the task something memorable, like “Living Room Toggle” and tap the Check mark to save.
Step 9: Tap the “+” at the bottom of the page to add a new Action.
Step 10: Tap “Net”.
Step 11: Tap “HTTP Get”.
Step 12a: In the “Server:Port” field, type graph.api.smartthings.com (leave off the http://).
Step 12b: Tap-and-hold on the “Path” field and tap “Paste” to paste the URL we copied earlier.
Step 13: Drag the cursor up to the beginning of the URL and delete the “http://graph.api.smartthings.com/” portion of the URL. IMPORTANT: Make sure to remove the “/” before “api/…”
Step 14a: Tap the back arrow at the top-left to save the Action.
Step 14b: I also add a Flash (+ > Alert > Flash) to let me know what action is taking place. You can also hit the “Play” button in the bottom left to test out the task. Each time you tap Play, your device should turn on/off.
THAT’S IT!
That’s all there is to creating a Tasker task that will toggle your device on and off each time it’s triggered. You can now use this task with any type of Tasker Profile you’d like.
If you would rather have a task that simply turns ON or OFF your device, rather than TOGGLING it, feel free to copy/paste the On or Off URL, rather than the Toggle URL.
Next up…Using NFC Task Launcher with your newly-created Tasker task to bring NFC control to SmartThings!!