I am new to The Home Remote, and have been searching for methods to control the device I am running THR on. Have you ever wanted to have a simple way to turn on or off the screen from within THR? A simple way to say something on the device’s speakers? To run another app from within THR? To be able to initiate a Tasker Task from THR, and unleash the awesome capabilities of Tasker? Me too. The THR’s JavaScript scripting language is running within a sand box, making it difficult to do this kind of stuff. But JavaScript can do “HTTP Get” commands. This plugin will send messages to Tasker via HTTP, using the Loopback IP Address. The message is then received by the AutoRemote Tasker plugin, which in turn will pass the command onto Tasker. This method does not require any cloud services, any servers, or any additional hardware. Unfortunately this method only allows for one way communication from THR to Tasker, and of course only works on Android devices that have Tasker and the AutoRemote Tasker plugin installed. This also means that the plugin will not work in the Designer (you most likely will see a “Failure to connect” error message).
plugin.Name = "TaskerPlugIn";
plugin.OnChangeRequest = onChangeRequest;
plugin.OnConnect = onConnect;
plugin.OnDisconnect = onDisconnect;
plugin.OnPoll = onPoll;
plugin.OnSynchronizeDevices = onSynchronizeDevices;
plugin.PollingInterval = -1;
var VERSION = "220714A";
var http = new HTTPClient();
var preurl = "http://127.0.0.1:1817/?message=";
var posturl = "=:=HomeRemote";
function onChangeRequest(device, attribute, value) {
var buff = "";
var response;
console.log("onChangeRequest: " + attribute + "=" + value);
if (device.Id == "1") {
if (attribute == "Switch") {
if (value == "Off") {
buff = "ScreenOff";
}
if (value == "On") {
buff = "ScreenOn";
}
}
if (attribute == "Scene") {
buff = value;
}
if (attribute == "Task") {
buff = "Task " + value;
}
if (attribute == "App") {
buff = "App " + value;
}
if (attribute == "Say") {
buff = "Say " + value;
}
}
if (buff != "") {
buff = preurl + encodeURI(buff) + posturl;
console.log(buff);
// Due to a bug in AutoRemote, the get sometimes aborts with erc 500
// Just resend the request when this happens.
try {
response = http.get(buff);
}
catch (err) {
response = http.get(buff);
}
}
}
function onConnect() {
}
function onDisconnect() {
}
function onPoll() {
}
function onSynchronizeDevices() {
console.log("onSynchronizeDevices called");
var virtualSwitch = new Device();
virtualSwitch.Id = "1";
virtualSwitch.DisplayName = "Tasker";
virtualSwitch.Capabilities = ["Switch", "Scene"];
virtualSwitch.Attributes = ["Task", "App", "Say"];
plugin.Devices[virtualSwitch.Id] = virtualSwitch;
}
I have also attached two Tasker Profiles to enable Tasker to understand what is being requested from THR. The “HomeRemote” profile runs when the Home Remote app is started, and enables AutoRemote to receive messages from THR (it is normally disabled). The second profile “HRemote” is the profile that actually receives messages, and does the processing to perform the desired Tasker command. Just import these two profiles into your Tasker environment.
This Tasker plugin will create a device named “Tasker”. To pass requests/commands to Tasker, use a DataAction.
To turn the screen off or on:
Tasker.Switch = Off
Tasker.Switch = On
To run another app on the device (“My App” being your apps name, case sensitive):
Tasker.App = My App
Example:
Tasker.App = Night Clock
To say something on the device’s speaker:
Tasker.Say = Use the force, Luke
To run a specific Tasker set of instuctions, use the Scene command. Currently only “Exit” is implemented, which will disable the AutoRemote Wifi reception. It is a good idea to disable AutoRemote Wifi Reception when not in use, but be careful as AutoRemote will no longer be able to receive commands until it is re-enabled.
Tasker.Scene = Exit
All of the above can also be done by creating a Tasker Task, and then running that Task.
Tasker.Task = My Task
You can also pass one or two parameters to that task, by using the vertical bar delimiter:
Tasker.Task = My Task|Parameter 1
Tasker.Task = My Task|Parameter 1|Parameter 2
Some of the things one can do within a Tasker Task is to set or lock the Screen Rotation, send SMS messages, make custom Notifications, and much, much more. Also, if running another app that Tasker can communicate with (such as “Homeseer”), then you can now use Tasker as the intermediator between THR and that app.
Notes: AutoRemote by default will display a Toast as it receives messages. You can disable those Toasts by explicitly running AutoRemote, and going to Settings, Alerts. You might want to leave Toasts on at first so that you can see that everything is working. Also, Tasker may require special Android permissions to run certain functions (like turning the screen off). Refer to the Tasker Documentation to find out how to grant those permissions to Tasker.
Tasker.plugin (1.7 KB)
HomeRemote.prf.txt (3.8 KB)
HRemote.prf.txt (17.1 KB)
Rename the two profile text uploads to have a suffix of “.xml” instead of “.txt” before you import them into Tasker (this site does not allow .xml type files).