Howto: Full control Android device with OH using Tasker

Dear community,

Recently joaomgcd of Tasker has released a beta version of Tasker that comes with an extra (and long waited) feature; The Tasker HTTP Request Event and HTTP Response Action functions.
According to joaomgcd on his reddit channel, this releases a range of new features. I agree!

With these new functions we are not only able to not only receive something from tasker but also send something to tasker. Let`s get busy :grinning:

In this example I will use this new feature to adjust the screen brightness of my tablet running HABpanel without the need of an external service (e.g. myopenhab) or another app (e.g. Fully Kiosk Browser). This is all local from client (OH) to server (tasker)

1) Download and install Tasker Beta
First we need to install the latest beta of Tasker that contains these functions.
The latest beta releases can be found here.
Please note that Tasker is a paid application for Android.

2) Setup Tasker

  • Variable:
    First we will create a Global Variable
    Go to VARS and add (+) a variable called %VarBrightness

  • Tasks:
    Go to Tasks and add (+)
    First task we name: “Request from OH”
    Add action → Variables > Variable Set
    Enter name %VarBrightness
    Enter To %request
    Second task we name “SetBrightnessDisplay”
    Add action → Display → Display Brightness
    Level → click on the two-arrow-icon on the right
    Add %VarBrightness

  • Profiles:
    Now we add two Profiles
    First profile we add (+) event → net → HTTP Request
    Configure this profile by
    adding to Method: GET
    adding to Path /command*
    Tasker wants to link this profile to a task, link it to “Request from OH”
    Add a second profile name “Event VarBrightness change”
    Variables → Variable Set
    Enter %VarBrightness as Variable
    Link this profile to “SetBrightnessDisplay”
    Make sure both profiles are enabled

3) Configure openHAB

Install the exec Binding

Create a script
p.s. I couldn`t get the script started in the script folder so I ended up putting it elsewhere. Depending on the platform you use for openHAB, make sure the script is whitelist and is accessible by OH

# change the IP address to your tasker device
PAYLOAD="$1 $"

# Send the cURL request
curl -X GET "$TASKER_URL" --data "test=$PAYLOAD"

Then we make the script executable by OH

sudo chmod 755 /usr/local/bin/

Put the script in the whitelist by OH (full path)

/usr/local/bin/ %2$s

Create a thing manually and place it in the things folder, e.g. execute.things

Thing exec:command:ToTasker "Tasker Command Brightness" [ 
    command="/usr/local/bin/ %2$s", 
    autorun=true ]

please note that wherever you will put your script, it need to be full path as stated in the how-to by Rich

Create two items:

Dimmer TaskerBrightness "Display tablet Brightness "
String TaskerBrightnessOutput {channel="exec:command:ToTasker:input"}

Create a rule:

rule "Send Command Brightness to Tasker"
   Item TaskerBrightness changed
      val Number IntBrightness = (TaskerBrightness.state as DecimalType)
      //adapt 100% dimming to 8-bit representation
      val Number IntBrightnessNew = ((IntBrightness / 100) * 255).intValue()

Now whenever TaskerBrightness is changed, the request will be send over to Tasker and it will act accordingly. As Tasker is a very powerfull tool you could almost control the whole android device from openHAB, which makes it really awesome!

As I am not an software engineer I spent a few evenings on this matter. The exec binding is quite old and this forum has alot of old topics regadering the binding. The full example on the exec binding creates a loginfo like such

 logInfo("Your command exec", "Raw result:" + yourcommand_Out.state )

This gives a lot of insight of what you are actually sending. Please read the docs for this.
I guess it could be done using the HTTP binding awell.

Now tasker is a bit of a strange duck when it comes to logic. If you run into any problems with Tasker, Joaomgcd created a http request example which you can import into tasker as a project. This could provide some insight in how Joaomgcd thinks and thus how Tasker works.


Thanks for the tutorial. It’s good to see jaomgcd is continuing development of Tasker.

Some screen shots on step 2 I think would be very helpful, particularly to those who are not as familiar with Tasker.

Why not use the HTTP binding? That should be more straight forward.

One gotcha here is that most modern phones use mac address randomization. To ensure that your phone always gets the same IP address, you need to disable that on the phone under wifi settings (it’s configured on an SSID by SSID basis so it’s not turning it off for all networks, just your home network) and configure a reservation in your router so the phone always gets the same address.

Another alternative would be to have Tasker update an Item with the IP address when ever your phone joins the home network which can then be used to conbstruct the URL. If you used that approach, instead of the HTTP binding or Exec binding using sendHttpGetRequest from a rule would probable be the most straightforward approach.

To control your phone even when it’s not at home, you can use a VPN but then you need to keep track of whether the phone is connected locally or via the VPN and use the corresponding IP address.

Yes, I mention this in the last paragraph :slight_smile: I took this path and it worked but both are possible for sure.

Yes, thanks for this clarification. I assume the reader knows some basics of network topology.
They are not Home Assistant users :sweat_smile: , that counts for something right?

I will look into the screenshots. You are right that it would make it easier to set this up correctly!