Tutorial: Using the new Auth system with tasker

Oh, I missed your reply 'cause you didn’t reply to my post :smiley:
However in the meantime found a solution, a bit different:

In the “Call HA get” Task (the one with http request and autotools json read) I added task -> return action.
In there I entered the %state variable. This is specifically made for “perform task”.
Now in the “perform task” task there is a field “Return Value Variable” where you put in a variable that gets the content of the %state variable from “Call HA get” Task :slight_smile:

Thanks for this write-up !

I can git it to work, but i have to execute the task 2 times in a row for it to work. If i only run it once, nothing happens. Anyone else experiences this behavior ?

I am using Home Assistant cloud BTW.

I’m trying to get a toggle switch working but i’m stuck on the current state part.
I tried this solution without luck: "Quick Settings" Toggle Tiles by Tasker on Android

A few things were suggested in that thread but since this one is more active i thought dropping my question here.

Like i said i’m stuck in getting the current state when submitting my POST request, lights switch on and off but i can not get the current state.

I did some reading here: https://developers.home-assistant.io/docs/en/external_api_rest.html
And if i’m correct the only status you will get returned are:

Successful calls will return status code 200 or 201. Other status codes that can return are:

  • 400 (Bad Request)
  • 401 (Unauthorized)
  • 404 (Not Found)
  • 405 (Method not allowed)

Is that correct or am i missing something?
The only solution i can think of is to do a GET directly after the POST to get the current status or can it be done more simple?

I use the Join notifier to send me every state update for the entity_ids I define. While HTTP Get works I find the notifier approach is more streamlined.

Is Join notifier sending silent notifications then?
I don’t need an extra notification just to toggle a icon to show it’s status if you understand what i mean.

Yes, they’re silent. Meaning they utilize the AutoApps command system to update the global variables I’ve assigned in my setup. I use KWGT to display my current sensor states in a custom widget. For more pressing events, like door lock events or if a door stays open for more than 2 minutes, I use AutoNotification to generate custom notifications.

Here’s my motion and door sensor update automation:

- id: '1293844881759'
  alias: Sensor Update
  trigger:
  - platform: state
    entity_id: binary_sensor.wyzesense_7782663d, binary_sensor.wyzesense_778376d9, binary_sensor.wyzesense_77850f6d, binary_sensor.wyzesense_778b9919, binary_sensor.wyzesense_778bc206, binary_sensor.wyzesense_778265c5, binary_sensor.wyzesense_7781a5a0, binary_sensor.wyzesense_77837920, binary_sensor.ring_front_door_motion
  action:
    service: joaoapps_join.send_tasker
    data_template:
      command: >
         {% set Data1 = 'Sensor_' + trigger.to_state.attributes.friendly_name %}
         {% set Data2 = trigger.to_state.state %}
         {% set Data3 = Data1 + '_update' %}
         {% set Data4 = now().strftime('%D %H:%M') %}
         {% set output = 'sensor=:='+Data1+'=:='+Data2+'=:='+Data3+'=:='+Data4 %}
         {{output}}

I am trying to update my “input_datetime.flemming_phone_next_alarm_date_and_time”, but I can’t get it working. I have tried for days without any solution, the sensor will not update.

This is the closest I think is right, but it don’t work:
par1
/api/services/input_datetime.set_datetime
par2
{"entity_id":"input_datetime.flemming_phone_next_alarm_date_and_time","state":"%year-%month-%day %hour:%minute:00"}

normal “toggle”, “on”, “off” tasks works fine, but they only have entity_id in par2.

What stands out is the dot in par1. Try replacing it with a /: /api/services/input_datetime/set_datetime

At least I got another error message :wink: so I think it is closer.
But it don’t work.
Now I got Javascriptlet: line 8 :400 - 400: Bad Request

To me it looks like you need to replace “state” with “datetime” in par2? Could that be the issue?

hmm, not, same error

Update. If I hard-code it like this it works:
{"entity_id":"input_datetime.flemming_phone_next_alarm_date_and_time","date":"2019-10-31","time":"10:15:00"}
“Just” have to make the AutoAlarm variables work then

image
After some more work I can confirm this working:
{entity_id":"input_datetime.flemming_phone_next_alarm_date_and_time","date":"%year-%month-%day","time":"%hour:%minute:00}
It turns out I disabled alarm during diagnosis and AutoAlarm variables don’t have a value if alarm is not set.

Did you get any solution. I am also stuck at same

So, I’ve created a version 2 of this tutorial, which should be a lot easier to follow

It uses generic tasks with a nice error handling, simpler parameters, and no javascript :wink: