Tasker & Long Lived Access Tokens

Yes “Bearer” prefix was a solution. Thanks.

well done! but howto update a sensor with that command?

In the past i tracked my battery level with a json payload like

{"state":"%BATT", "attributes": {"friendly_name": "cellular batt", "icon":"mdi:cellphone","unit_of_measurement":"%"}}

My example calls a script that sets a boolean, triggering an automation.
The developer docs https://developers.home-assistant.io/docs/en/external_api_rest.html cover passing JSON data as a parameter.

You should be able to modify my example accordingly. I’m still in the process of building out the infrastructure and will not get to additional RestAPI use until the subscription Cloud connection comes online

Someone can give simple example of the usage including all parameters…

i could not get this to work…

@poratnir This can be also done with webhooks and without tasker plugin “RESTask”. Pictures are from RESTask. For testing and running from RESTask own play button, replace the “%HA_token” with your actual token.

I have found that webooks are, by far, the easiest to use in most scenarios.

This post by @masterkenobi is what helped me get it working.

I have also attached some Tasker examples. You will need to create two variables and for my examples to work,%HASSIO_SERVER and %WEBHOOK_ID
where:
%HASSIO_SERVER = https://yourdomain.duckdns.org
and
%WEBHOOK_ID = same_string_as_“webhook_id:”_in_the_automation

Pro tip 1: webhooks don’t require authentication so use a very hard to guess string for webhook_id (mine are 100 character randomly generated strings)
Pro tip 2: don’t use # or % in the webhook_id (Home Assistant doesn’t like # and Tasker doesn’t like %)

Obviously, you will also need to change the entries in the examples to reference items that exist in your Home Assistant environment. Hope these help. :grin:

Webhook_Automation.tsk.xml (1.7 KB)
Webhook_Command.tsk.xml (2.2 KB)
Webhook_Scene.tsk.xml (1.6 KB)
Webhook_Script.tsk.xml (1.6 KB)

Hey
thanks for assisting …tasker is just plug in …
how to activate it?

Not sure i fully understand how to use it … editing is easy…
how to run it?

I need the token for HADASHBOARD

Sorry, I don’t use HADashboard so I don’t know how to help with that. If you just need to generate token, you can do so from your account profile page.

So i log into the profile and create token with token name…
how to link the token to the service?

Solid. :+1:

3 Likes

Hey man! Nice to see you around! Welcome back!

1 Like

I see the Beauty in there! Done Well!
Unfortunately I was a Idiot and put in https://url.com/ instead of https://url.com - Took me an hour :sweat_smile:
Thanks a lot! And It should defenetly go in the cookbook!
When you give me the permision Ill do it for you (even after I cant code at all)

Please feel free to add it to the cookbook.

haha, thanks! Sorry to ghost! Pumped to be back at it.

son any inputs regard HADashboard?

Question: Is it possible to use webhooks to update an http sensor? I’m trying to use Tasker to fire when my phone disconnects from my car and i’d like to do a sensor instead of an input_boolean or something like that. I also don’t want to keep using the api and want to go token…is my only option the RESTask plugin?

I’ve been struggling a bit with this problem, and had some issues with the RESTask Plug-in.

I have finally found a method that suits me, so I wrote a quick tutorial which works without any Tasker Plug-in, if anyone is interested

2 Likes

Thanks @bokub! That seems to work great! Had to put a 1 second wait between calls (i have multiple sensors updating from a single task), but otherwise awesome (and yay 1 less app/thing that can break).