Tasker Wink Integration Project by Craig Trunzo

From Wink@Home Wiki
Jump to: navigation, search

Wink Hub Tasker integration!

This project, when imported in the Tasker app on an Android device, allows you to use Voice Control to control Wink devices, as well as set up IFTTT like robots based on just about any type of input or event you can image.

Most Recent Release: 11/15/2017



YouTube channel:* http://goo.gl/uy2B5o Here there be videos referenced in the configuration section below. I will add other instructional videos as time allows.

DISCLAIMER

This project is written around a few devices that I own and can test and may not work correctly for other devices. I've tried to write the tasks as generically as possible, so the project SHOULD work with most basic devices. As my z-wave system grows, I will be sure to change this project to make them work, but for now I just don't have the money to buy every device that is compatible with the Wink system.

If you have a device that doesn't work correctly, don't hesitate to ask below. If you are willing to spend the time to help me test, I'm willing to make every effort to get it working. This has already been done to add support for a MyQ garage door opener and the Power Pivot Genius power strip.


REQUIREMENTS

Required Hardware

  1. An Android powered Device
  2. A Wink Hub
  3. Stuff to control

Required Software

  1. Craig Trunzo's Wink Tasker Project
    • Download then import this project into Tasker...
  2. Tasker
    • Tasker is the heart of the project and is required to act as the intermediary between your Device, AutoVoice, and Wink.
    • If Tasker is not available in the Play Store using the links below, you can download it directly from the developer's website. They play store version is more convenient because of automatic updates, but essentially the same as the version here... Tasker Download
    • (you MIGHT need the latest beta as that is what I usually have installed) Tasker Beta
  3. AutoVoice
    • AutoVoice integrates with Google Now to take "OK Google" commands and send them to Tasker
    • AutoVoice is free to install, but you must purchase the unlocker in the app to be able to use it for our purposes here. I believe it's $.99
  4. AutoWear
    • Optional, but highly recommended if you have an Android Wear watch
  5. AutoNotification
    • Optional. This allows Tasker to receive remote commands from other things. Chrome browser, IFTTT, other phones, etc...

PROJECT INSTALLATION AND CONFIGURATION

PLEASE NOTE: The videos are a bit out of date. They can give you the general idea, but the written instructions should take precedence when there is inconcistency.

  1. Install Tasker and go to Menu -> Preferences. On the UI tab, make sure "Beginner Mode" is NOT checked. I also turn tips off. That part is up to you. While is Preferences, go over to the MISC tab. Make sure "Allow External Access IS checked. Make sure "Reduce Resource Usage" is NOT checked.
  2. Install AutoVoice and follow the instructions in the app to get Google Now Integration turned on.
  3. Go Back to Tasker
  4. Long Press one of the icons on the project bar along the bottom of the screen. default is a house icon. When the menu pops up, choose Import and navigate to where you downloaded my project. Once selected, you will now have a "Wink" tab on the bottom. Tap the wink tab to get into project.
  5. Back completely out of Tasker using the back button. Not doing this, or just pressing home, will result in the process not completing.
  6. When you are back at your home screen you will get a popup asking for your username.
    • Enter your Wink username the same as you would if signing into the real Wink app.
    • Your username should be in the form of an email address.
    • Tap the check mark when you are done.
  7. Next, you will get a popup asking for your password.
    • Enter your Wink password the same as you would if signing into the real Wink app.
    • Tap the check mark when you are done.
  8. You will get a popup stating that everything worked (if everything worked)


OPTIONAL:

  1. If you want to set a customer trigger word or phrase for Wink Shortcuts...
    1. Alter the Variable Set -> %WinkSceneWords action in the "Wink Set Variables" task. NOTE: Prior to the 10/19/2015 update, this variable was stored in the "Wink Get Devices" Task
      • THIS IS FOR SHORTCUTS ONLY, NOT DEVICES, GROUPS, OR ROBOTS
      • This task sets a variable named "%WinkSceneWords".
      • The default value is "activate|engage|wink please".
    2. Expand the Value field by adding a bar "|" to the end of the string and adding a new word or phrase after that.
      • Let's say you want to channel your inner Batman, you can add another value for "Alfred" by adding another bar. "activate|engage|wink please|alfred".
      • You would then say "Alfred secure the house" where "Secure the house" is the name of a shortcut in your Wink app.
      • Add as many as you like.
  2. If you plan on running this as a wall mounted device, you can set it up to turn on automatically when it senses motion using Detect Motion with an Android device

EXPLANATION

Tasker Profiles

Profiles in Tasker are used to intercept various events from the device to be acted upon.

WinkVoiceReceived

  • The "WinkVoiceReceived" Profile is used to respond to the AutoVoice commands.
  • The basic command is "Turn/Lock/Unlock/Open/Close <device name as it appears in the Hub app> <action you want performed>"
    • "Turn the Living Room Light on"
    • "Turn the Library Light Off"
    • "Lock the Front Door"
    • "Unlock the back door"
    • "Open the garage door"
    • etc...
  • You can also use groups created in the Wink app in the same way as devices.
    • "Turn All Internal Lights Off"
    • "Turn Kitchen Lights on"
    • etc...
  • Control Shortcuts from your Wink App by saying "Activate/Engage/Wink please <shortcut name>" (see step #3 above)
    • "Activate All Lights On"
    • "Wink please Lock The Doors"
    • "Engage Movie Time"
    • etc...
  • Thermostat commands:
    • "Set Thermostat to 72 degrees"
    • "Set thermostat to heating"
    • "Set thermostat to cooling"
    • "Set Thermostat to auto"
    • "Set thermostat minimum temperature at 70 degrees"
    • "Set Thermostat max temp at 75 degrees"
    • Please note that all thermostat commands might not work with every thermostat model
  • Schlage Lock enhanced commands:
    • "Set <lock name> beeper enabled to <true or false>"
    • "Set <lock name> vacation mode enabled to <true or false>"
    • "Set <lock name> auto lock enabled to <true or false>"
    • "Set <lock name> alarm enabled to <true or false>"
  • Robots can be turned on an off by using "Enable (or Disable) Robot <robot name>"
    • "Enable Robot Front Door Unlocked" where "Front Door Unlocked" is the exact name of your robot.
    • "Disable Robot A Light Was Turned On" where "A Light Was Turned On" is the exact name of your robot.
  • You can also use "And" or "Then" to send multiple commands at once...
    • "Turn the bathroom light off then turn the master bedroom light on"
    • "Turn the kitchen light off and turn the basement light on"
    • "Turn the Bedroom Light Off and activate Movie Time"
    • "Close the Garage Door and Set Thermostat to 72 degrees"
    • "Activate I'm Home and Disable Robot Any Light On" ("I'm Home" is a shortcut and "Any Light On" is a robot)
    • etc...

WinkDailyRefresh

Simply runs refresh of your access token and device list daily at 2am. You can change the time as you see fit.

WinkSetup

This is a Run-Once profile used for initial setup. It can be deleted after the initial setup process if you see the need.


Tasker Tasks

"WINK SET VARIABLES" IS THE ONLY TASKS YOU SHOULD EVER CHANGE

Wink Set Variables

This task will set your trigger words, response preferences, as well as a few other customer variables needed for the project.

  •  %WinkSceneWords sets the custom phrases used to indicate that you are attempting to activate a shortcut.
  •  %WinkDeviceWords sets the commands needed to alter devices in your Wink profile. IT IS BEST IF YOU DO NOT ALTER THIS
  •  %WinkRobotWords sets the commands needed to enable or disable a robot. IT IS BEST IF YOU DO NOT ALTER THIS
  •  %WinkFlashConfirm controls whether a flash/toast is show upon success or failure. 1 = show it, 0 = don't.
  •  %WinkVibrateConfirm controls whether the phone vibrates on success or failure. 1 = buzz, 0 = don't.
  •  %WinkVoiceConfirm controls whether voice output is enabled for success or failure. 1 = talk, 0 = don't.
  •  %WinkDeviceResponses contains the phrases to be spoken when a device state is successfully changed.
  •  %WinkShorcutResponses contains the phrases to be spoken when a shortcut is successfully activated.
  •  %WinkRobotResponses contains the phrases to be spoken when a robot is successfully enabled or disabled.
  •  %CRLF DO NOT EVER TOUCH THIS

TO EDIT RESPONSES To add new responses to %WinkDeviceResponses, %WinkShorcutResponses, or %WinkRobotResponses...

  1. Make sure the current last character in the variable is a bar "|". This is how Tasker separates each phrase in the variable.
  2. Add your new phrase after the "|", make sure you add another "|" at the end of the newly added phrase.
  3. There are two "magic words" that can be inserted to reference the object and action of your command in the voice output.
    • "<object>" (no quotes) can be inserted into the response. At run-time, this will be replaced with the name of the Device, Shortcut, or Robot used in the command. "<object> was successfully activated" would be changed to "Sleepy Time was successfully activated" where you said "Activate Sleepy Time". This example was for a shortcut, but the same principal applied to a device or robot command.
    • "<action>" (no quotes) can be inserted into the response. At run-time, this will be replaced with the requested action used in the command. "The Robot was <action>" would be changed to "The Robot was enabled" where you said "Enable Robot Front Door Motion". This example was for a robot, but the same principal applied to a device command. Shortcut commands don;t really have an action.
    • When combined together "I have set the <object> to <action>" would be changed to "I have set the Dining Room Light to On" where you gave the command "Turn the dining room light on"

Wink Setup

  • Runs tasks for the initial setup but should be left in place and not deleted.
  • Will be run again if your stored credentials are ever corrupted or deleted.

Wink Get OAuth

  • Gets your Wink Authorization Token.

Wink Get Devices

  • Uses the Wink API to get a list of all devices, groups, robots and shortcuts connected to your Hub. It then generates a variable string that is used elsewhere in the Wink tasks.

Wink Voice Received

  • Parses voice commands, breaking a multi-command request into individual commands and looping through each one to pass them on to "Wink Process Command"

Wink Process Command

  • This takes the individual commands and rips them apart to determine the proper device to control, and how to control it.
  • It send this information to "Wink Send Commands".
  • This is also the task you would use to skip voice control.
    • Instead of saying "Turn the light on" using voice, you would pass "turn the light on" into this task as %par1.
    • You also need to pass in a %par2 if what you are trying to control is a Wink Shortcut. Leaving %par2 empty will work for a device or group, but if you are controlling a Wink Shortcut, you must set %par2 to "shortcut" (no quotes)

Wink Send Command

  • Uses the lower level data created earlier to communicate directly with the Wink API to control the requested device or group.

Wink Send Shortcut

  • Uses the lower level data created earlier to communicate directly with the Wink API to control the requested shortcut.

Wink Send Robot

  • Uses the lower level data created earlier to communicate directly with the Wink API to control the requested robot.

Wink Get Device By Name

  • This task translates a device name, such as "Kitchen Light", and find the full device variable with all required info to be used by the other tasks.

Wink Get Device Status

  • Used to query the hub to get current information about a device, robot, or group, then returns it to the calling task.
    • If you don't pass in a specific device/robot/group, this will look up the status of all devices/robots registered with you hub. It will not return group status as tht is just a collection of individual devices.
    • If you pass in just a device/robot/group name, "Dining Room Light", it will use the "Wink Get Device By Name" task to get the full variable for that device/robot/group, then send the request and return the result.
    • If you pass in a device/robot, it will look up and return the status of just that device/robot.
    • If you pass in a group, it will get the status of all devices in the group and return them all.

OK, YOU CAN EDIT "WINK TEST TASK" AS WELL

Wink Test Task

  • Shows you an example of how to manually control an object without voice control. This has no function other than that.

TASKER POWER USERS

TASKER POWER USERS, OR THOSE LOOKING TO EXPAND THIS PROJECT TO MEET THEIR OWN NEEDS...

  • I often update this project. The easiest way for you to stay updated is to completely delete the old "Wink" project from your Tasker, import the new one, then go through setup again.
  • If you make changes or create other tasks dependent on this project, I highly recommend that you create a new project in Tasker to hold that stuff instead of keeping it within the "Wink" project that gets created when you import this. That way, if you can freely delete and upgrade my project without needing to recreate your stuff as well.


ADDITIONAL PROFILES & TASKS

Please see the note section above, #TASKER POWER USERS

Get Wink Commands from IFTTT

This is exceptionally useful to make the Amazon Echo be able to do anything you want it to in Tasker, in this case, control Wink. This can be used to unlock door and open garages, which Echo cannot do at this point

This is a pretty lengthy write-up, so I am linking to another page where I have more room to work.

Supercharge your Echo with Tasker and IFTTT


Slow fade a light or group on

This task will turn a device or group of your choice on over a slow period of time determined by you.
The task will send a command every 30 seconds with the appropriate dim level to slowing increase the light.
THIS WILL ONLY WORK WITH DIMMABLE DEVICES OR GROUPS

  • The best way of calling this is to make a profile with your criteria, then add a new unnamed task that calls an action:
    • Task -> Perform Task
    • Name: WinkFadeOn
    • Parameter 1: Name of the device or group to fade on
    • Parameter 2: Length, in minutes, that you'd like the fade on to take. (This is an estimate. Lag across the cloud can increase the time it takes to perform the task)

File Link

Sample Profile that will turn on the Dining Room Light at 6:30am and take 5 minutes to do it


What groups are on

Profile: You say "What groups are on" and this profile tells you. File Link

Toggle a device

Task: Set step 1 to the name of the device you want to control. If it's on, it will turn off. If it's off, it will turn on. File Link

Lights on at Sunset

Profile: This turns a light on 10 minutes before sunset and off 10 minutes after civil dusk.

File Link

Open Sesame

Profile: Say "Open Sesame" and the command in step 1 is performed. I use it to unlock a door (obviously). File Link

Wifi Robots Enable/Disable

Profile: Turn robots on or off when you are close to your home WiFi. I use it to get notifications only when I am away from home. File Link

CHANGELOG

Wink Tasker Project Download


11/15/2017

Fix for API credential changes.

1/11/2016

  • FASTER!! The project now stores your Access Token until expired. This stops a new token be granted every time you give a command, thus greatly increasing speed.
  • BETTER!! Setup if vastly easier. Instead of setting a whole bunch of stuff manually, you will now be prompted for the required information. Just enter your Username and Password when requested. (after you get Tasker installed of course)
  • STRONGER!! OK, maybe not. But I DID fix an issue where if your device contained a "Device Word" (turn, set, dim, etc...) it would be stripped from the device name and cause a failure. Thanks Ken Vermillion, for bringing it to my attention.

11/16/2015

Added a method to override the "%WinkFlashConfirm", "%WinkVibrateConfirm", & "%WinkVoiceConfirm" variables at a local level. These were introduced in the 10/19/2015 update. This change allows you to temporarily override them in individual tasks by setting a new variable "%WinkResponseOverride" to 0 or 1. 0 is the default state. Set this variable to 1 when you want to change the output variables in a task, set it back to 0 when you are done.

10/19/2015

Inspiration from Allen Barreno

  • Created a new task called Wink Set Variables. I moved configurable variables from several other tasks into this one for a central point of control.
  • Added the option to configure your responses when a command is given, you can turn on or off the following output methods
    • A Flash/Toast message. This is a small, short-lived message that appears at the bottom of your screen. This was included previously, but can now be toggled.
    • Vibration. Two short buzzes for success, 1 long buzz for failure. This was included previously, but can now be toggled.
    • NEW!!! Voice output. Variables can be configured to contain a series of phrases to be spoken upon successful completion of a request. Multiple phrases can be added to each variable type (Device, Shortcut, or Robot) and one will be chosen randomly when a request is made.
  • Added several new variables to facilitate response toggles and voice output. These new variables are all contained in the "Wink Set Variables" task.
    •  %WinkFlashConfirm controls whether a flash/toast is show upon success or failure. 1 = show it, 0 = don't.
    •  %WinkVibrateConfirm controls whether the phone vibrates on success or failure. 1 = buzz, 0 = don't.
    •  %WinkVoiceConfirm controls whether voice output is enabled for success or failure. 1 = talk, 0 = don't.
    •  %WinkDeviceResponses contains the phrases to be spoken when a device state is successfully changed.
    •  %WinkShorcutResponses contains the phrases to be spoken when a shortcut is successfully activated.
    •  %WinkRobotResponses contains the phrases to be spoken when a robot is successfully enabled or disabled.
    • TO EDIT RESPONSES To add new responses to any of the 3 relevant variables...
      1. Make sure the current last character in the variable is a bar "|". This is how Tasker separates each phrase in the variable.
      2. Add your new phrase after the "|", make sure you add another "|" at the end of the newly added phrase.
      3. There are two "magic words" that can be inserted to reference the object and action of your command in the voice output.
        • "<object>" (no quotes) can be inserted into the response. At run-time, this will be replaced with the name of the Device, Shortcut, or Robot used in the command. "<object> was successfully activated" would be changed to "Sleepy Time was successfully activated" where you said "Activate Sleepy Time". This example was for a shortcut, but the same principal applied to a device or robot command.
        • "<action>" (no quotes) can be inserted into the response. At run-time, this will be replaced with the requested action used in the command. "The Robot was <action>" would be changed to "The Robot was enabled" where you said "Enable Robot Front Door Motion". This example was for a robot, but the same principal applied to a device command. Shortcut commands don;t really have an action.
        • When combined together "I have set the <object> to <action>" would be changed to "I have set the Dining Room Light to On" where you gave the command "Turn the dining room light on"

7/16/2015

  • Changed "Get Wink Devices" task to handle a change in the Wink API that caused it to return unusable data.

5/13/2015

  • Forced actions into light bulbs and switches while we wait for Wink to fix the API. Locks never stopped working, but anything other than locks/lights/switches/outlets is probably no going to work ATM.

3/20/2015

  • Changed "Group" variables to include contained device ids instead of applicable states. The states aren't used for anything, but having the devices ids will save time in several tasks.
  • Rewrote "Wink Get Device Status" to be MUCH faster at handling a request for all objects. Typical results will be returned in 2-3 seconds total instead of 2-3 seconds PER OBJECT.
  • Added the ability for "Wink Get Device Status" to handle groups. This will return a variable with the group name and ID, followed by the status of every device in the group. Group data will only be returned if a group is specifically named when calling the task.

3/18/2014

  • I borked the normal lock/unlock controls. Fixed now.

3/17/2015

  • Changed task priority on all tasks which need to call "Wink Get OAuth" to ensure that an auth token is provided before trying to continue. This is what was causing the issue with Tasker 4.7b2/3/4. I'm guessing that it will be a permanent change to Tasker, so adjusted the app accordingly. If anyone using the Play store version of Tasker has any issues, please let me know ASAP.
  • Added the enhanced Schlage values to "Wink Get Device Status". This will now return battery level as well as many other bits of info. If you use this task in any of your own stuff, please verify that it will still work for you as the output format may have changed slightly.
  • Added enhanced Schlage Lock functionality control
  • Use the following commands to enable or disabled enhanced features. You can still use the normal "Lock the <door name>" like you always could.
    • "Set <lock name> beeper enabled to <true or false>"
    • "Set <lock name> vacation mode enabled to <true or false>"
    • "Set <lock name> auto lock enabled to <true or false>"
    • "Set <lock name> alarm enabled to <true or false>"

3/12/2015

  • Bug Fix: Corrected issue where a scene with a single-word name would not fire from Voice Control
  • Bug Fix: Corrected Issue where a Voice Control would only accept the first word in the %WinkSceneWords var as usable (usually "Activate")
  • New Feature: Added the ability to turn Robots on and off. See below for Voice Commands.
  • New Feature: Added the ability to get the current status of a robot and the last time it was fired. See "Wink Get Device Status" task description for usage.
  • Random: Broke Device and Shortcut control into 2 separate tasks. The single "Wink Send Command" task was getting to large an unmanageable to hold both.
  • New Task: "Wink Send Shortcut". This should never be called directly and should not affect any existing tasks you might have created.
  • New Task: "Wink Send Robot". New task to send Robot enable/disable commands.

3/2/2015

  • Added enhanced controls for thermostats. See above for voice commands.
  • Bug fixes.

2/25/2015

  • I moved the changelog to the bottom so you don't have to scroll through 150 lines of boring.
  • Silly little update to add an "Open Sesame" profile. No need to download this update just for that.

If you want to add it without downloading, just make a new profile... Profile: Event Context -> Plugins -> AutoVoice -> Recognized Command "Open Sesame" (no quotes)

Task: unnamed New Action -> Task -> Perform Task Name: Wink Process Command Paramter1: "unlock the front door" (no quotes, replace front door with whatever your lock is named on the Hub)

2/24/2015

  • I reworked a few tasks to make them less confusing.
  • I added a new task called "Wink Test Task." This task shows you how to send a manual command from another task without using voice control
  • Deprecate the word "scene" from the project. I'm used to that term with home automation, but Wink calls them "shortcuts", so I changed the project to reflect that. If you had any tasks calling "Wink Process Command" and were calling a Wink Shortcut, please change %par2 to "shortcut" instead of "scene"*
  • Reworded the "Wink Process Command" task description below.
  • Added "Wink Test Task" description below.
  • Added section about expanding my project with your own stuff below.

2/3/2015

  • With the help of ​ I fixed the issue with controlling garage door openers.
  • Added support for Pivot Power Genius powerstrips. Use the name of the individual outlets to trigger them. i.e. if an outlet on a strip is named "Space Heater", you would say "Turn Space Heater On"

1/29/2015

  • I flushed out 2 tasks that have been sitting dormant. "Wink Get Device Status" and "Wink Get Device By Name"
  • "Wink Get Device By Name" should be called from other tasks to get a device variable based on a name. Call it and pass in something like "Living Room Light" and it will return the full variable "wink|Living Room Light|address1234|etc...".
  • "Wink Get Device Status" will query the hub to get the device state. then return it to the calling task.
    • If you don't pass in a specific device, this will look up the status of all devices registered with you hub.
    • If you pass in a full device variable, it will look up and return the status of just that device.
    • If you pass in just a device name, "Dining Room Light", it will use the "Wink Get Device By Name" task to get the full variable for that device, then send the request and return the result.

1/28/2015

  • At the request of several users, I altered the project to allow for easier customization of trigger words for Wink Shortcuts (and regular devices/groups by proxy)
  • Changed the flow of the project to add an extra step between receiving voice commands and actually sending them to Wink. This extra step breaks apart the task that parses voice commands into one that breaks multiple commands into usable data and one that converts that data for sending to Wink.
  • See notes below for details on how to customize trigger words.

1/11/2015

  • Integrated the group functionality that ​ was able to get working.

12/31/2014

  • Added full support to control Wink Shortcuts.
  • Added support to get groups from the API, but I can't seem to control them yet. You will see groups in the device list, but you can't make then turn on or off.
  • Changed the "Wink Get Devices" task to ignore devices that are not controllable such as the Nest Protect.
  • I added support for the MyQ garage door opener, but I have no way to test. Another user tested for me without success. If you have a MyQ garage door opener, please test and let me know if it works.

See notes below for new usage instructions.

12/29/2014

  • Changed API variables to the defaults used by Wink's Android App.
  • Altered "Get Devices" script to exclude devices that don't offer a controllable state, such as the Nest Protect.

9/19/2014

  • Initial upload