⚙️ Using Tasker with Home Assistant (V2)

Hi, How can I use this to kill a process on android in case of an automation is triggered in HA? Thank you

So this tutorial is really all about getting Tasker to be able to talk to HA. It doesn’t include anything for having HA talk back to tasker though.

I do have this capability on mine though, I use it for a few things. The easiest way to do it is to get the plugin called AutoRemote. Essentially what that plugin provides is a URL that you can then use to start a tasker task. And since Tasker has a “Kill App” action available for tasks that should give you what you want.

To get this set up, after downloading AutoRemote follow the directions in app to get your personal AutoRemote URL. Then you can make a RESTful command service like this:

rest_command:
  autoremote: 
    method: GET
    url: 'https://autoremotejoaomgcd.appspot.com/sendmessage?message={{ message }}&key=<Insert Your Key>'

With this you can put in a service call in your automation that then sends a message to your phone, whatever message you provide as the ‘message’ parameter.

On the Tasker side you can create a profile that then listens for an autoremote call with a specific message and triggers a task. If you follow the link I provided for AutoRemote, João has a couple of videos that explain it really well you can follow. Since at this point its all just tasker stuff.

Now I do think that AutoRemote costs a couple bucks so hopefully that’s ok. If you were hoping for a solution native within Tasker (no other plugins required) I don’t really have a solution for you there. I did some googling and tasker doesn’t have websockets support so there’s not really any good way to listen for an event in HA. The only thing I can think of here would be to have your automation set a helper (input_boolean, input_text, etc.) and then have tasker poll HA repeatedly calling the HA Template task provided by the author above to watch for changes in this helper. Then you could react to those changes by calling Kill App.

This would work I suppose but its polling so its pretty ugly and there will be a delay. Autoremote I know of to get this to be event-driven.

4 Likes

This is very useful information @CentralCommand ! I am now investigating a way to automatically toggle motion alerts from a video doorbell app via another Tasker plugin - AutoInput. If I can get that to work to virtually tap the app’s icons, then I need a way for HA automation to instruct Tasker to run that task.

AutoRemote looks like the best way to do that, especially since I already have Tasker running to act on doorbell press and motion alerts from the app. (See this post if interested) I agree, polling would be ugly, and websockets much preferred. It is also not great that the Rest command can’t communicate directly with the phone, rather than go through the cloud.

I’ve not used this rest_command in HA before, but I would have thought a POST method to send the message, and not a GET would be needed?

EDIT: Thinking about this some more, I’m also using Telegram integration in HA to push messages for alerts. I could install Telegram alongside Tasker and use that to send message triggers tthrough Tasker’s built-in UI notification.

Could you share your version, cause I would also really like the HA set-state?

hi! forgive me digging up such an old thread, but I just [day ago] found that, while looking for Tasker<>Home Assistant connectivity, and I’d like to say: great job! that’s exactly what I planned to do, but I AM SO GLAD that somebody did that before me - I think I just saved a lot of time :wink:

but I have a “small” [I hope] problem, so maybe you @bokub could help me out :slight_smile:

I use an old android phone [android 6.x, device hard to root/flash custom so it is what it is] as the car gps system, and also as mobile router for my also android based head unit, but it’s irrelevant. I made a two tasks that depend on the chargin status. when ignition is on and phone is charging, task “hotspot on” is started. it turns on mobile data, turns on wifi tethering and with a big help of your tasks - it sends information to my Home Assistant instance [it sends phone battery level and turns on “car active” input_boolean, the rest is done by my HA, but it’s not important now]. when ignition is turned off and phone charging stops, task “hotspot off” is started and it sends info to HA [battery level & turns off “car active” input_boolean], then it turns off tethering and turns off mobile data - so the battery is saved and phone is in “standby” mode [I can change it any time by sending a text message to turn the data on, I can ask for location and get it via text etc. all done with Tasker too].
the problem is, HA not always gets the info from tasker. I thought it is some kind of ping/lag issue, so I’ve added a “wait 20s” commands before and after running your tasks, to be sure they won’t be interrupted by mobile data off command etc. I’ve even cloned the “perform task” command, so now I’m running your tasks twice, to be sure that the info goes out of the phone.
still - it doesn’t work every time. on the other hand, when I run the task by hand - it reports correctly, and status of my car is changed in HA.
I thought that maybe it’s because when task is [or should be] started automatically - screen is off and therefore battery optimization kills tasker or sth, and while I do it by hand - screen is on; but that’s not the case - I made sure tasker is not optimized for battery usage, and also the rest of the task [mobile data/tethering] turns on and off correctly.
I didn’t saw any errors displayed so I’m kinda stuck with no ideas.

can I somehow debug what’s happening with the information sent from your task - and if it is sent correctly?

1 Like

Dears,

When I execute the task, I recieve the following message in the notification bar:

With HA_ADDR set to “https://xxx.duckdns.org:8123

Error: 400
400: Bad request

With HA_ADDR set to “https://xxx.duckdns.org:8123/

Error: 404
404: Not Found

Any idea about how to solve?,

Thanks in advance.

Jose

As said in the tutorial, no trailing slash in HA_ADDR.

Have you checked that your JSON payload is valid ?

Thanks a lot for your tutorial. I don’t want to be spammer but I cannot find solution anywhere. I need a new task in TASKER to trigger my ‘Google Home Mini’ (of course integrated in HA) and let it say (maybe I shoul write ‘play’) audio file placed in HA ‘media’ folder. I’ve only found JSON script example: {“entity_id”: “media_player.studio_speaker”, “message”: “Hello World!”} but It’s for TTS (in addition doesn’t work).
Thanks a lot for any ideas.
Jard

Thanks to bokub I was able to create this widget.

This is a widget I built in KWGT that allows me to toggle devices and get the states of those devices. Using Tasker, AutoRemote and KWGT.

What you need for this widget:

Android OS phone Tasker (paid app) KWGT (paid app) AutoRemote Lite (paid or free) Home Assistant

1 Like

I’m trying to setup tasker to communicate with home assistant and have tried to follow the tutorial… Seems I have done something wrong as I am getting a error from tasker and have already managed to block my IP once lol… I am using duckdns. Any help would be much appreciated ! :slightly_smiling_face::+1:t2:

Hello,
I found this thread very interesting and decided to give a try to this solution to let tasker communicate with HA.
I made a task, and it works ok if I execute it directly, but I get an error 400 bad request when I use it in a profile that runs every 5 minutes.
I’m getting the battery status from my smartwatch (via autowear) and I would like to send it to HA.
The JSON for my task is the following:

{“entity_id”:“input_number.watchbattery”,“value”:“%awmessage”}

Again, if I execute the task it works perfectly, and the values in HA are set accordingly, the bad request only happens when I use a profile “every 5 minutes”.

Can you help with this?
Thanks in advance!

OK, it seams it was a problem with my phone that hibernated autowear, and so the plug-in didn’t work when the screen was off.
So it didn’t pass any parameter to the following step.

Thanks anyway.

Is anyone having a problem with this? I am getting an Error 60 when I try and run this shell command. It was previously working fine

I am getting this exact same issue. Did you manage to get it fixed?

I’m no longer using Tasker>HASS. Tasker was crashing on the old Galaxy S3 I had it installed on with the original Android. To get it working, I updated the OS to a newer Android 7 build found on xdadevelopers.com I suggest that you do the same - research what newer XDA Android builds will work on your old phone.

If you must stick with the same Android 4.4x OS, then try contacting the Tasker developer for advice on possible older version of Tasker or some other configuration to get past the error.

Maybe someone here can help me. I’m searching for a solution to interact with the reolink app via Tasker and home Assistant. What I want is that when alarmo is triggered Tasker opens the reolink app and starts recording. It’s a battery powered camera and don’t have a rtsp stream. Neolink doesn’t work because with neolink the battery is empty after a few hours.

Is this possible with Tasker or someone has got a better idea?

So I want to realize this project:
https://notenoughtech.com/tasker/how-to-sync-android-alarm-with-nodered/

For starters I wanted to send a message from Tasker to Node Red.
Pretty simple one would think, especialy as he explained that pretty well here:
https://notenoughtech.com/tasker/integrating-nodered-and-tasker/

As I want to have this function working only within my own house anyway
I decided to do this without any dyndns. Only within my own network.
Therefore my first attempt was to send a http message from Tasker to NodeRed.
But whatever I tried I didn’t succed.
Anybody an idea?
Do I need to enter my credentials for the mqtt server anywhere?
That’s the only thing I could think of.

Grateful for any hint.

Cheers
Enrico

Hi, I receive the same error. Did you manage to fix that?

Thanks it works …but cant we control phone from home assistant ?
Say from home assistant call service to turn phone volume like that ?

Trying to use a input_select.select_option but not sure how to format the second JSON, which as per the converter should be:

{
“data”: {
“option”: “Noche”
},
“target”: {
“entity_id”: “input_select.fase_del_dia”
}
}

Any clues?