This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
[TUTORIAL] Using Tasker together with Homey
Phuturist
Member
I have seen some requests on the forum for more details about using Tasker in combination with the Homey API. Since I had some time this evening I have tried this out myself with a little help of superice and decided to share my experiences here.
With these Tasker Tasks you can create a profile in Tasker that will trigger these actions, for instance based on your smartphone being connected to your Home Wifi network. But better yet, this is just an example on how to use Tasker in combination with the Homey API. You can use the BetterLogic app with it's API to create any kind of variable that you like which you can set with Tasker based on events on your smartphone and you can then create flows within Homey based on the change of this variable. The possibilities are endless! Please share your use cases in this thread as it might help other people as well.
What is this tutorial for?
If you need to read this, then this tutorial is probably not for you. I'm going to assume you know your way around Tasker (Android Automation App) and you know how to create Profiles and Tasks within Tasker. If so, with this tutorial you should get an idea on how to use Tasker in combination with the Homey API.Index of Tasker Use Cases
- Replace the Homey presence detection with the more reliable Tasker presence detection (this post)
- Create homescreen buttons to trigger flows or switch devices
- Send triggers from Homey to Tasker to do stuff on your smartphone based on Homey triggers
- Using wallmounted tablet as security camera with Tasker and IP Webcam
Replace the Homey presence detection with the more reliable Tasker presence detection
In this tutorial I'm going to set the presence of a user based on a Profile event within Tasker (for instance, being connected to you Home Wifi network). In the next post a tutorial on how to add Homescreen shortcuts to trigger flows will follow.Prerequisites
- A working Homey
- An Android smartphone with Tasker installed
- A Tasker plugin called RESTask installed which enables an extra plugin in Tasker
- The external URL to your Homey (it looks something like this: https://ID.homey.athom.com/ and can be found by going to my.athom.com and login to your Homey from outside your own network)
- Your bearer token (can be found by going to my.athom.com and inspect the URL linked to the Homey icon. The url contains a parameter called bearer_token which is the token you need to have)
Creating "At Home" Task
Add a new task in Tasker called something like "At Home". Create a new action within the task and select the RESTask plugin (it's under the plugins category). Click on the configuration button and use the following settings for configuring the RESTask action where you replace the tags with your own external URL and bearer token.Settings Tab of new RESTask action
- Request Type: PUT
- Host: https://ID.homey.athom.com/api/manager/presence
- Enable Custom Body: Yes
- Custom Body: {"present": true}
Header Tab of new RESTask action
- Add new header with name "Content-Type" and value "application/json" (without the quotes)
- Add new header with name "Authorization" and value "Bearer <<token>>" (without the quotes and replace <<token>> with your token and leave a space between the word Bearer and your actual token)
Creating "Away" Task
Add a new task in Tasker called something like "Away". Create a new action within the task and select the RESTask plugin (it's under the plugins category). Click on the configuration button and use the following settings for configuring the RESTask action where you replace the tags with your own external URL and bearer token.Settings Tab of new RESTask action
- Request Type: PUT
- Host: https://ID.homey.athom.com/api/manager/presence
- Enable Custom Body: Yes
- Custom Body: {"present": false}
Header Tab of new RESTask action
- Add new header with name "Content-Type" and value "application/json" (without the quotes)
- Add new header with name "Authorization" and value "Bearer <<token>>" (without the quotes and replace <<token>> with your token)
With these Tasker Tasks you can create a profile in Tasker that will trigger these actions, for instance based on your smartphone being connected to your Home Wifi network. But better yet, this is just an example on how to use Tasker in combination with the Homey API. You can use the BetterLogic app with it's API to create any kind of variable that you like which you can set with Tasker based on events on your smartphone and you can then create flows within Homey based on the change of this variable. The possibilities are endless! Please share your use cases in this thread as it might help other people as well.
Comments
Creating shortcut buttons for Homey through Tasker by Android
This tutorial will explain how to create shortcut buttons in Android using Tasker for Android. These buttons can be placed on your Homescreen and trigger any flow you want. In the future this functionality will probably be part of the Homey Android app but for now you can use this tutorial.Prerequisites
Create "Set variable x" task
Add a new task in Tasker called something like "Set variable x". Create a new action within the task and select the RESTask plugin (it's under the plugins category). Click on the configuration button and use the following settings for configuring the RESTask action where you replace the tags with your own external URL and bearer token.Settings Tab of new RESTask action
Header Tab of new RESTask action (needed from BetterLogic v0.9.0 and higher)
Create a shortcut on a Homescreen which sets the variable
Go to one of your Homescreens and start the "Add a shortcut" wizard (most likely by long pressing on your Homescreen and selecting the right option). In the list for adding a shortcut select Task Shortcut with the Tasker logo. In the next list select the task you have just created. Note: you might have to add a task icon to the task before being able to set it as a shortcut by selecting the icon at the bottom right and setting an icon.Once done you now have a button on your Homescreen which will set the BetterLogic variable to it's desired value. Based on the change of this variable to a specific value you can trigger any flow within Homey!
Thanks for setting up the tutorial. I was just trying to create an at home task. However, when I test the action I get the following error in tasker.
[Edit]
Nevermind already got the At home and Away action working in Tasker
You actually do need a space between Bearer and your token. For me the value for the header authorization looks like this: "Bearer 12324234bfgbgb4234242vdvf335vd43".
Return code:
404
Return data:
{"status":404,"message":"not_found"}
The Request Type is correct, the Host is correct and I added a Header with: Bearer XXXXXXXXXXXXX (including the space).
I tried different types of variables but none is working.
http://tasker.wikidot.com/profile-index
could be interesting for Athom to make a Homey plugin so one could directly select device (id) or flows within Homey.
EDIT: I just realized that Homey presence by default only gets updated in the mobile app. This used to be parametrised in the app, so I guess once the Setup view is back, this problem would resolve itself
Body is exactly as specified above:
{"present": false}
or
{"present": true}
I found the ID for my external URL homey id by going to the system informatins tab / page, its called "Athom Cloud ID"
http://[local homey ip]/manager/settings/#homey:manager:system
Thank you very much for the excellent tutorials!
So far it is only obvious to me how I can use my phone to send commands to Homey. But how can I use Homey to send commands to my phone?
I think that should work for you
May I ask what you are trying to achieve, maybe there are different solutions.
I also changed phones, so it could be that, but thought I would ask here before starting a possibly painstaking (Typing bearer tokens and long urls into Tasker :P) process of debugging.
EDIT: Disregard! It is werking afterall
My phone is usually connected to my LAN via VPN (OpenVPN Connect), so I replaced the external Homey URL https://ID.homey.athom.com/ with the internal Homey URL http://<Homey-IP-address>/ in the RESTask settings, which works perfectly as well.
The excellent location based profiles in Tasker (using cell tower ID's + wifi networks + GPS, if needed) greatly improve the presence detection en geofencing options for young Homey
Like Phuturist said, as a first "Hello World" example, this is only the beginning. Integrating these two provide nearly limitless possibilities together, and I'm curious what other users have crafted. One of my examples:
My Tasker calculates how late I'll be arriving home in the evening, triggered by a location I pass on the route from work to home on workday evenings. It automagically informs the home front in advance, with a text message containing the expected arrival time. Till now... because Homey + RESTask open up some very creative options for bringing the news
I recently created the other was around communication. Something on Homey triggers a flow which sends a request to your phone. This request is picked up in Tasker allowing you to trigger actions on your phone (for instance, I used it to be able to control my robot vacuum cleaner which does not have an open api).
It requires a paid app called Autoremote. If anyone is interested I could create a tutorial for it.
It's not the simplest solution since you need IFTTT aswell but it relys on Autoremote aswell. Step 1,2 and 4 are showing how to get homey to trigger a tasker task. You don't need Autoinput beside you would like to create a similar action with screen input on your phone/tablet.