Home Assistant Community

Tutorial: Using the new Auth system with tasker


I’ve managed to stop the errors, and get the task to run.
But nothing happens in HA.



Same here. And funny thing is that the old taks I had, with the API password in the url is still working fine.

Can anyone help out get this new authentication way working?

UPDATE: Ok so I got it working using the duckdns url. I first tried with my local url and actually that is what I want to do. So that tasks only run when I’m actually in the same network. If anyone knows how I can achieve that…?



My old tasks with the API password don’t work.
I can’t use tasker in conjunction with HA at all no.
Sad times



You don’t say if you tried to set it up like mentioned in the topic start.



Sorry thought it was clear,
Yeah I’ve set it up exactly as explained in the first post.

Maybe someone who has it working could export the xml from tasker and share?



I was struggling to get this to work. No error messages in Hassio or Tasker. Finally realized that url need to have also port if you are running Home Assistant in some other port than default SSL.

So correction for me was to set global variable %HA_ADDR to https://my_site_name.duckdns.org:8123



thank you so much for posting this, i was able to get this setup in 10 minutes and it has opened up the door to automations for me.



im getting this error:

Log Details (WARNING)

Login attempt or request with invalid authentication from



Make sure you have his script formatted correctly in tasker. If you copy->paste to your phone it may be incorrectly formatted. That is what is causing alot of the error posted above. I was using Join to send the text to my phone through chrome and if f’ed it all up on the transfer.

ie. turn your phone sideways and make the line of text EXACTLY the way his is.



This is incredible! I’m sure this saved me hours of troubleshooting and research. Very easy to follow and I updated my existing HTTP Post state “Perform task” with very little effort. I spent more time trying to figure out why I was getting an error popup after Home Assistant rebooted. Even though the entities were updating properly. For my purposes I actually took out the last three lines so I wouldn’t get the error message when my entities updated for the first time after a reboot.

if( xhttp.status != 200 ) { 
    console.error(xhttp.status + ' - ' + xhttp.responseText); 


@bokub Finally got al my Tasker shortcuts back, thanks a lot!



Thanks for the info. I can’t for the life of me get this to work. I have followed the OP’s tutorial exactly, and absolutely nothing happens when I run this task. No error messages on my phone, and nothing happens within Home Assistant.

I am able to use HTTP Post with my API password to accomplish the same thing, but I’d much rather use this token method. Is there something additional that I need to do within Home Assistant besides creating the token? I’m kind of a newbie with this. Please help!

Phone: Google Pixel XL
HA: Docker container - QNAP NAS



Thanks for your tutorial.
Im new at Tasker and first i tried with the api_password methode form Bruh Automation (https://www.youtube.com/watch?v=CvSYZnKS0es) and i didn’t worked now i tryed it with the Turial but I have the problem that i get the error Massage 400 Bad Request.
In Ha there’s no Log whats going wrong.
Does anyone have any idea what else I can do that it works?



API method isn’t preferable these days so I wouldn’t try that.

Did you create a token for Tasker?

Other option these days is to use Webhooks. Works pretty well with Tasker.



@phantomdarkness Yes I create a long life token for Tasker like shown in this tutorial. But I get the error Massage 400. Is there more todo, which is not described in the tutorial?



Maybe you’re sending a bad JSON payload? Only thing I can think of with a 400 request. It’s not a 201 connection refused error, so you have most things set up correctly. Can you post what your payload/trying to send to HASS is?



I tried to do as explained in the first post and everything works perfectly but I’d rather delete all the variables and have a single task.

I modified the javascriptlet but it always gives me the same error. What am I doing wrong?

const url = https://myurl.duckdns.org:8123/api/services/switch/toggle;
const token= ‘Bearer ABCDEFG’;
const xhttp = new XMLHttpRequest();
xhttp.open(‘POST’, url, false);
xhttp.setRequestHeader(‘Authorization’, token);
xhttp.send({“entity_id”: “switch.sonoff”});
if( xhttp.status != 200 ) {
console.error(xhttp.status + ’ - ’ + xhttp.responseText);



Got it, merci @bokub!

had issues because either I didn’t reboot after creating token or typo while creating tasks. Initially I thought issue was due because I had trusted network activated in my config but it works with and without it.

If it could help and save time a bit here is the “Call HASS” xml task :

Call_HASS.tsk.xml (700 Bytes)



That’s my config on Tasker I hope you find a mistake that. Thank you a lot!



You wrote “ligth” instead of “light” in par1…