Notice the Bulb icon being “clicked” turns on all lights in my bedroom, and changes the colour of the tile!
If you want to get going as quickly as possible, download this GIST on your phone and import it!
Simply click and hold the “TASKS” tab at the top, click “Import” and navigate to the place where you downloaded the GIST.
Click through and change the parts that say CHANGE_ME based on your own settings!
I would like to continue on the good work by @broesie on his post Android: Control Home Automation with Tasker from Quick Toggles to explain how to make toggleable commands through Tasker!
The difference between this example and that of the previous example:
- Requires one task per toggle, instead of two
- Can read return data from Tasker for the true status
- Repeatable use of variables
Create the Task
+ icon to add a new task, and call it something meaningful. Note this name will be the word that appears under the tile!
Creating the VariablesFor the sake of code re-usability, I would recommend making the following variables: 1. `url` (should be called `domain`) 2. `address` 3. `body`
Create the variable by clicking the
+ button down the bottom right, and searching for
%body variable is what you would send to HA. You can work out what you need to send by going to the Services icon in the Developer tools, or looking through the forum for examples.
This is the example for the
%url variable, this should be your dynamic DNS address, or however you access HA. For example
https://xxxxxxxxx.duckdns.org:8123 (note, no trailing forward slash at the end!
%address you will need to work out what that is, but if you wish to toggle a light, it will be the same as mine:
note that if you have a password for web access, you place it at the end at the address, as the variable
api_password as is above, replacing the
Add the following in the
var xhttp = new XMLHttpRequest(); xhttp.open = ( "POST", url+address, false ); xhttp.send(body); var result = JSON.parse(xhttp.responseText).state;
.state at the end will look at the first array returned, and the value of
If you have any issues, add
flash(xhttp.responseText); after the 3rd or 4th line to see if you are actually getting a response from HA!
- Add an
a. and in the first field type
%resultand for the comparison, do
- Add the
Setup Quick Settingsaction after that
a. For the name, it should be the same as the current task you have made, and are in!
- add an
a. Tick the
c. important step toggle the
Inactive! This will turn the icon to a lighter shade
Choose the Icon
- Click the “grid icon” at the bottom of the screen
- Click on
- Choose any icon
Create the Quick Settings Tile
- Go to your quick tiles, and drag one of the Tasker tiles into your drawer as seen in the video.
- After exiting the edit, you should see your unset Tasker quick setting.
- Click and hold on the tile to edit it
- In the sceen that comes up, click the “magnifying glass” icon and click on your new task