[HOW TO] Tasker + RESTask + Autovoice for Google Now voice commands of Iris
5 5

58 posts in this topic

** This post will be a work in progress, as I continue to work on it i'll try to make the steps more succinct and easier to follow **

All credit goes to lwalker!

As far as i know there is no tasker app available for iOS, so this is a Android focused solution. Correct me if i'm wrong...

buy and install tasker
install autovoice plugin (pay for and install the PRO unlock)
Install RESTask

In autovoice settings select Google Now Integration and enable integration via accessibility settings

In Tasker go to overflow menu (three dots stacked vertically in the upper right corner) --> Misc tab and check Allow External Access

Copy text of script posted in lwalker's Sample Tasker Script - Set Home Mode thread: http://forum.livingwithiris.com/index.php?/topic/146-sample-tasker-script-set-home-mode/
Paste into a text editor (notepad etc) and save as .xml

Once you have the xml file you will need to get it on your phone/tablet/device, I usually just drop it in google drive so i can access it on any of my devices. On your device you will need to have a file system browser installed (I personally use ES File Explorer, but any of the thousands available should do). Download the xml file to your device (by default it will probably be placed on the sdcard in a download folder). In the file browser, find your download and then move it to sdcard/tasker/tasks.

Open tasker, go to the tasks tab. Tap and hold the tab label for a couple seconds, release and a menu will pop up with "Import" as one of the options (There should be some sort of haptic feedback signaling that when you remove your finger from the screen the menu will be there, but there's no indication, personal annoyance...). Hit Import, select the file you just copied into the tasks folder and it will show up in your tasks list. Now you can tap on the task and edit each step (enter you username, password, etc).

You will want to scoll down to the second RESTask step (should be somewhere around step 9) and tap on it then tap on the "pencil" icon next to Configuration. There are two fields you will spend most of your time on here, Host and Custom body. Host tells the script where the API call goes (it will actually define the specific device you are interacting with) and Custom body is where you define what you want the device or setting to do (in lwalker's example, this is profile=HOME - it tells Iris to set the profile to the HOME mode, you could set this to NIGHT, AWAY, or VACATION if you wanted in that specific example).

Also, just notice that if you swipe right to left you will get a "Headers" section and here the ApiSession cookie is defined. It is taken from a variable that is defined earlier in the tasker script, this is what I personally had a lot of problems with early on as I was using a non-primary login for my Iris account, so the scrip was actually encountering a EULA when it tried to log in so it wasn't parsing the session id properly. Without that session id the script can execute the actual command. No changes needed here, you'll just want to be aware that its there and what it does...



Now, there's two primary areas that i've adapter lwalker's original script to control devices:

* %irisurl/users/%irisusername/widgets/smartplugs
* %irisurl/users/%irisusername/widgets/groups

You can use the two strings above to generate output of all the devices or groups attached to your system by placing one or the other in the Host field in the Iris_Get_Device_Types.tsk.xml (attached).

This script will connect to your Iris system and generate a text file on your sdcard in the tasker folder that lists out all of your devices. This file isn't formatted, so I usually generate the file, upload to google drive, download to my pc, open in notepad or similar, and seperate each device onto its own line. There's a lot of information in there, but i'm generally just after the device ID and the description which are basically the first two items, so you can just turn off word wrap and then wherever there's a device ID just move it to the next line so it's easier to look at.

Also attached are two more example scripts, one that interacts with the Garage door controller and one that controls a group. In the garage controller one you will have to go find your controller's device ID and put that in place of **deviceid** in the host field under the RESTask settings for the task. Same for the group, you will need a list of your programmed groups so you can replace **groupid** with the appropriate group id.

Once you have defined your task(s) you can switch over to the profiles tab in tasker. Hit the plus button at the bottom to start configuring a new profile (this will be where you define the google now voice command).

Plus button-->Event-->Plugin-->AutoVoice Recognized-->"pencil" icon-->command filter or speak filter (type the command or say it). Once finished hit the "check" button up top and then hit back until you're back to the main tasker interface and you have a popup where you select the task you want the voice command to execute, pick a task and you're done. You can long press the profile name and then hit the large "A" button on the top to rename it if you want.

One thing to watch out for, sometimes google now recognizes things differently then you'd expect. For example, i configured an autovoice command that included the string "back yard". Google now decided i was saying "backyard" so tasker wasn't triggering...so just watch for things like that.

Iris_Open_Garage.tsk.xml

Iris_Turn_On_Downstairs_Lights_Group.tsk.xml

Iris_Get_Device_Types.tsk.xml

Iris_Close_Garage.tsk.xml

Iris_Turn_Off_Back_Yard_Sprinklers.tsk.xml

Iris_Turn_On_Back_Yard_Sprinklers.tsk.xml

Iris_Buzz_In_Front_Door_Deadbolt.tsk.xml

Share this post


Link to post
Share on other sites

Can you post an example of what you mean by device id or the information you kept out of the text file you complied? DONT post the actual device ids as those are mac addresses, I just want to see an example of the text file you made from all that info and what you kept

 

so my example is:

{"smartplugs":[{"id":"MAC ADDRESS A/N CODE","name":"Freezer","type":"SmartPlug","controlType":"POWER","plugType":"us","presence":true,"onOffState":"on","lastKnownState":"off","supportsIntensity":false,"intensity":null,"supportsSpeed":false,"speed":null,"applianceType":"FRIDGE","currency":"USD","costUnits":"$","powerUnits":"W","remoteMode":false,"supportsPower":true,"scheduleEnabled":false,"supportsLock":false,"isLocked":null,"state":null,"bulb":false,"lighting":false,"howAmIDoing":4,"costSoFarToday":"0.05","costYesterday":"0.150","costPredictedToday":"0.149","powerNow":114,"changeSummary":"ABOUT_SAME_AS_YESTERDAY","presenceYesterday":true,"nextEvent":null

Share this post


Link to post
Share on other sites

Yes, as of now. I can confirm this works. Just take your time. Make sure you dont disable tasker. I have 2 smart plugs and this works great even with the basic free account!

 

Now I just pick my phone up and say ok google, turn lights on or off and boom let there be light!

 

Now, to work on getting settings for the ac thermostat and to arm the alram like ivee can.

 

I also wanted to note that this opens more doors (pun intended) than you think!

 

I have a gear 2 and now I can use the tasker widgets on my watch to do the same things! Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :lol:

Share this post


Link to post
Share on other sites

Excellent feedback, thank you!

 

I know you can arm the alarm by triggering the home mode, but haven't taken the time to look into directly interacting with the alarm or thermostat portions of the system, but would be good to explore!

Share this post


Link to post
Share on other sites

Thanks Joel for your effort. This could be a huge advancement in the true automation of Iris.  I'm covered up right now but plan on jumping in on this in a few days.

 

Do you think it's safe to assume that geo fencing actions in tasker could trigger an event like a garage door opening?

Share this post


Link to post
Share on other sites

I could us some help new at tasked. I get error eveytime I run the script. Error no such session and in tasked it says no active profiles. Thanks 

I'm new also so not much help at this time.  I did follow joel's instructions above and it worked fine. I downloaded the .xml files and made the username, password and device id changes and followed the tasker setup. I actually made the device id changes in the .xml file before I imported it as a task and then edited the task to enter my username and password.

Share this post


Link to post
Share on other sites

I setup a task and profile to open my garage doors. I also created profiles to execute the tasks based on GEO location. The Google voice command works fine for both but the GEO location was only executing the first profile when the GPS parameters were met. I'm not sure just yet but it appears multiple tasks executed on the same profile will only run the first task in line.

 

I found that I could add another action to that first task and run the 2nd task which was not executing.

 

The garage door script supplied here has 10 actions in the task with the last being flash "the door is opening"

 

To add this action perform the following:

 

click the task which will show the 10 actions

click the + at the bottom

click the task icon

click the perform task icon

click the search icon and select the task you want to execute 

 

In summary this allowed me to cause both doors to be opened based on the GEO location action on one of them and it also confirms you can trigger one task based on another.

Share this post


Link to post
Share on other sites

I'm new also so not much help at this time.  I did follow joel's instructions above and it worked fine. I downloaded the .xml files and made the username, password and device id changes and followed the tasker setup. I actually made the device id changes in the .xml file before I imported it as a task and then edited the task to enter my username and password.

The device ID is that the hub ID. If so how do I find that. I do not see the hub in the list. 

Share this post


Link to post
Share on other sites

The device ID is that the hub ID. If so how do I find that. I do not see the hub in the list. 

 

The hub id isn't needed as long as you only have one hub on your system (anything that requires a hub id can be done using /hubs/only instead of /hubs/hubid).

 

The device IDs he mentioned above are the IDs for each individual lightswitch/smartplug/etc.  You can find the device IDs using the task i provided or by logging into your iris portal, going to devices-->manage for a given device and the device ID will be displayed in the browser address bar.

Share this post


Link to post
Share on other sites

As Joel mentioned you can find the device id which is the MAC address by managing any device from the device tab.  When you click on manage a device the string at the end of the url following the /id will be the MAC address and it is characters in alpha numeric format such as X1-XX-X2-XX-X3-XX-X4-XX

Share this post


Link to post
Share on other sites

I just added 3 more tasks to the OP.  One is for closing the garage door (basically you change the custom body to "isLocked=true"), the other two are exports from my sprinkler tasks.  The way i currently have this set up is a sprinkler valve wired to a $15 irrigation transformer (24V) plugged into an Iris smartplug.  I'm not using the Oribit irrigation timer at this point since I haven't got it working connected to Iris yet.

Share this post


Link to post
Share on other sites

Thanks Joel, so I'm assuming you could use your irrigation script for any Smart Plug?

 

Correct.

 

On a related note, at one point I collected the information for the Orbit irrigation timer, but couldn't really test anything with it since it wasn't working...I think if i ever get it working correctly with Iris i'll be able to put a script together to control it as well.

Share this post


Link to post
Share on other sites

Actually could you use this script for any device for basic on/off functions using the proper MAC address?

 

Most likely...I know it works with the GE lightswitches, the Linear lightswitches i posted about a few days ago, a third lightswitch brand that i haven't mentioned before now (can't remember the exact brandname, but i'll be adding it to the non-iris branded devices list), the smartplugs, and I would assume the GE wallplug.

Share this post


Link to post
Share on other sites

The garage door controller task ends with a flash notification and the irrigation task ends with a notify notification. Is there a reason for this difference? The only difference I saw was one displayed in the status bar and one displayed as a screen popup. The status bar had to be cleared which would be a little annoying.

Share this post


Link to post
Share on other sites

The only reason is that partway through configuring my tasks I decided I liked a flash better than a notification because the notification looks like an error message and it has to be manually dismissed (which is OK for initial setup/troubleshooting, but kind of annoying for day to day use). That's all...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
5 5