"Quick Settings" Toggle Tiles by Tasker on Android

I tried to implement this but I think it’s causing issues because of the new AUTH system used by HA?
Any quick fix or should we rebuild function using this Tutorial: Using the new Auth system with tasker

I haven’t yet used the new auth system, but remove the ?api_key=xxxxxxxxxx from the end of the address from the previous instructions.

Replace:

var xhttp = new XMLHttpRequest();
xhttp.open = ( "POST", url+address, false );
xhttp.send(body);
var result = JSON.parse(xhttp.responseText)[0].state;

With:

var xhttp = new XMLHttpRequest();
token= 'Bearer ' + global('xxxxxxxxxxxxxxxx');
xhttp.open = ( "POST", url+address, false );
xhttp.setRequestHeader('Authorization', token);
xhttp.send(body);
var result = JSON.parse(xhttp.responseText)[0].state;

(note the API key is now inside the token parameter as per the linked tutorial)

1 Like

@fanuch
Thanks, it’s working partially now.
The light switches but the %results value is empty therefore I thought it didn’t worked at first.
Gonna do some reading how to have that fixed.

/Edit
I think I’ll do a GET straight after the POST to get the actual state.

Excellent @schumi2004!

As per the guide, see if you get a result on this place at the end of your request:
flash(xhttp.responseText);

It’s possible the response is under a different label/array.

Hi!

do I need to have a raspberry pi to use this?

I’m trying to get a quick setting tile to toggle my lights on/off but I only have my phone, tasker, some autoapps and the smart light switches and nothing else.

Is it possible?

Thanks

No, where did you get that idea?

You need an Android phone with Tasker, and be running Home Assistant with API access.

What you’ve described is the entire point of this guide :slight_smile:

I wasn’t sure if everything on this site was based off of a raspberry.

How do I run Home Assistant on my phone and get API access? Is it the HA app in the play store?

I’m a mega noob at this stuff and understand very little

Thanks

Based on your response I would highly encourage you to read through the documentation.

One of the best things about Home Assistant is the very well written manual and examples.

Here is the API guide

I am trying to make it work with the new auth system using a token. I used the replacement that @fanuch wrote above. But it still doesn’t work. Did you make any other changes? I can’t even get it to send a command to HA, much less get the state. Are you able to export your working setup?

No unfortunately I did not made any progress, still stuck on the current status part.
I did managed to flip the switch.
Reinstalled my phone today and will start over tomorrow. Will share my project once I got it working.

/Edit
I see that another guide is updated recently, maybe this will help you? I will use that tomorrow.

1 Like

@jockebq
Got it working.
Follow the first 3 steps from here: ⚙️ Using Tasker with Home Assistant (V2)
And then import this task and change icon for it: Test_Floorlight.tsk.xml https://pastebin.com/U79JT09s
Add tile and it should work.

1 Like

Thanks @schumi2004 I followed the guide the first 3 steps. And I downloaded your Test_Floorlight.tsk.xml and imported it to Tasker task section. But there seems to be something wrong with it, because when I click the task I cannot edit it, it asks me to select another task?

That is strange.
Maybe this works better using images?
Note: Floorlight has changed to Woonkamer or Kamer in my situation.

Task overview:
First 2 steps are from other topic, 3 - 8 from fanuch
Change task icon at bottom, mine has a lightbulb now.

Step 1

Step 2

Tasker Quick Settings Task

1 Like

Is there a way to set two quick settings task that act like toggles? When i try this the second toggles interacts strangely enough with the first one.

Thank you so much! It is almost working for me. I can toggle a device on and off but the state is not returned. It will flash off both when it is turned on or off. And the switch won’t change from active to not active either. This is how I get the state {{ states(“switch.livingroom_tv”) }}
And I followed your guide for everything!

If you did what I did then it should work.
I would suggest to make separate TEST tasks and follow the suggestion done in linked topic under section:

4. Create your own tasks

Part 1 - Calling a service

If you’re not familiar with Home Assistant services, I suggest you go to the Developper tools > Services page of your Home Assistant and try doing things first.

I used the developer tools services page to show me the current status reported back so i could test the actual code to use in Step 2

@nelbs
Only thing i can think of is that you’r linking tasks to each other?
Can you explain your tasks/setup you created and your goal?
I only have 1 toggle but i have a feeling you created more then 1?

Got it to work, it was actually the state of the switch I tested with that did not respond quick enough. So I set a 5 sec wait and now it works great.

I have the same question as @nelbs
Added a second quick setting and when I click it, it will change the first toggle to the same as the one I clicked. It seems you can only have one toggle switch in quick settings? Is there any way to add more than one?

I think you can do using AutoNotification.

I’m trying to turn on two lights using the ‘group.’ entity, it works but isn’t great as the lights don’t turn on and off in order, and it’s either 1 light on and the other off, different state with each toggle.

Also, I’m getting the error: Error 400: {'message": "Error rendering template: Template SyntaxEr- ror: unexpected char at 10") each time I press the toggle.

Any ideas? thanks

Can you post your task xml?