Trying to get my first tasker automation to work

Are you running MQTT? If so this is an easy task with Tasker+MQTT Client

Have a task for a received SMS to start with. Use MQTT Client to send a message and have Home Assistant act on it.

yes i have a multi sensor working through MQTT however again i dont understand how to get it working… it just works… pot luck to be honest… so i think my biggest problem is i dont understand what im doing/trying to do and i’m struggling to find documentation that i understand to learn from, whether it’s written or my preferred method video.

my whole setup has to be able to run without access to the internet, thats a must. after that, when my mobile phone rings (ideally limited to a selection of contacts and all unknown/unrecognized numbers), then a light will flash and continue to flash untill i answer my phone or clear the missed call alert. what the best, easiest way to accomplish this is, I have no idea.

I knew about tasker for android and was reminded of it in another post where i was also told that webhooks would work in my situation, i thought i understood webhooks but it turns out i know nothing of them and in all honestly i’m struggling to work out parts of it, from what I think i understand my webhook is made up by me and consists of “https://my.hass.io.ip:8123/api/webhook/this_bit_i_make_up_to_be_unique?some_json_code_here

Yes, you make up the webhook ID. For example:

- initial_state: 'on'
  alias: 'Tasker hook'
  trigger:
    - platform: webhook
      webhook_id: this_bit_i_make_up_to_be_unique
  action:
    - event: tasker_webhook
      event_data_template:
        who: "{{ trigger.json.who }}"
        what: "{{ trigger.json.what }}"

Would result in the URL you posted (though you have to use the hostname, not the IP).

In Tasker:

  • Action: HTTP Request
  • Method: POST
  • URL: https://your-ha.example.net:8123/api/webhook/this_bit_i_make_up_to_be_unique
  • Headers: Content-type: application/json
  • Body: {"who":"rdoull","what":"ringing"}

Then you can consume the events fired with something like:

- initial_state: 'on'
  alias: 'my phone ringing'
  trigger:
    - platform: event
      event_type: tasker_webhook
      event_data:
        who: rdoull
        what: ringing
  action:
    - service: light.turn_on
      data:
        entity_id: light.main_bulb_1
        brightness_pct: 11

The great thing of this approach is that if you want to change what happens, that’s controlled by Home Assistant, not your phone.

1 Like

thank you again Tinkerer,

if i understand what you have put above, both sections that begin with

- initial_state: 'on'

are in my automations.yaml ?

and my webhook would begin with “http://hassio.local:8123/…”

Yes, both of those are automations

And no, your webhook wouldn’t.

If you enter

      webhook_id: test

Then the webhook URL becomes https://hassio.example.org:8123/api/webhook/test

1 Like

ahh, ok… i’m on my laptop just now but will edit this with pictures from my phone in a sec.

i’m still having problems (and greatly appreciate everyones time in helping me, thank you)

here is what i have

- id: '1566779457539'
  initial_state: 'on'
  alias: Testing webhooks
  trigger:
  - platform: webhook
    webhook_id: imjusttestingthis
  action:
  - event: tasker_webhook
    event_data_template:
      who: "{{ trigger.jason.who }}"
      what: "{{ trigger.json.what }}"
 
- id: '156677945758'  
  initial_state: on
  alias: tasker webhooks tester one
  trigger:
    - platform: event
      event-type: tasker_webhook
      event_data:
        who: rdoull
        what: ringing
  action:
    - service: light.turn_on
      data:
        entity_id: light.main_bulb_1
        brightness_pct: 11

and in tasker i have the following :






jason?

You also truncated the Headers, or it’s just the way you screen grabbed it.

OK… Missed that in the automation… Also caught a few other typos… Whoops…

I’ve changed my header to the following…

But still no joy…

Dunno if it means anything but on my phone it says “tasker no active profiles”

also tried changing the header to "content-type:… "

and “content_type:…”

Is there any way I can break it down to see if tasker is sending the webhook and if ha is receiving it? Then I can maybe assertain where the problem is.

The Home Assistant log file by default will have details of when the automation runs, but it doesn’t show webhooks as such. For example:

2019-08-27 17:58:07 INFO (MainThread) [homeassistant.components.automation] Executing Tasker hook

Tasker itself will pop up an error if the connection fails.

The first is technically valid, the second isn’t.

However, I see you’re using http:// - did you not yet set up SSL? You’re forwarding port 8123 on the router to 8123 on your HA host?

i tried once, but it lost me… starting to see a trend here huh…

i think so, i know i did have remote access set up via duckdns but i removed all of that a while ago, think it stopped working and there was another method i switched to that used the cloud, though i may be wrong here.

though if this is to be internal do i still need to forward the port? (sorry if its a daft question)

i’ve looked through my logs and cant find anything like what you posted for webhooks not even similar.

If it’s internal then use the internal IP and port, not the external hostname

thank you for your patience with me, i know it cant be easy.

I’ve changed the tasker address to include my HA ip and port 8123 (if i type that into my browser i get to the password page for HA ) still no joy and no reports in HA

Ok, so the URL should look like

http://192.168.0.42:8123/api/webhook/imjusttestingthis

?

And your automation trigger is like:

  trigger:
    - platform: webhook
      webhook_id: imjusttestingthis
1 Like

Url is :

And my complete automation looks like this :

- id: '156677999539'
  initial_state: 'on'
  alias: Testing webhooks
  trigger:
  - platform: webhook
    webhook_id: imjusttestingthis
  action:
  - event: tasker_webhook
    event_data_template:
      who: "{{ trigger.json.who }}"
      what: "{{ trigger.json.what }}"
 
- id: '156677999999' 
  initial_state: 'on'
  alias: tasker webhooks tester one
  trigger:
  - platform: event
    event_type: tasker_webhook
    event_data:
      who: rdoull
      what: ringing
  action:
    - service: light.turn_on
      data:
        entity_id: light.main_bulb_1
        brightness_pct: 11
1 Like

Go to the Tasker Task, and run the task. Check for any errors popping up on the screen.

If you’re not running Hass.io you can also run tcpdump -n port 8123 on the HA host and see what’s going on.

the webhook is getting to HA, i had a space in the url that shouldn’t have been there, i went through everything with the cursor to check if i had extra spaces or something.

the automations show up in HA logbook as having been triggered too but there is no change in the light…

thank you

edit:

human error… the automation works as well ! i wasn’t allowing enough time between calling my phone to hanging up for HA to receive the info and act on it. takes about 2 rings

so thank you again for all your help and patience you’re a legend !

if I may though, through all of this i think i have learned a lot about how to set it up though I don’t understand what the “who” and “what” are used for or why i need them. also why do i need the two automatons? couldn’t i just use the second automation on its own with the same end result?

I’ve been playing and trying to understand the automation and I’ve found that this also works (what appears to be) exactly the same… so I must be missing something with the reasoning for the rest of it…


- id: '156677999539'
  initial_state: 'on'
  alias: Testing webhooks
  trigger:
  - platform: webhook
    webhook_id: imjusttestingthis
  action:
  - service: light.turn_on
    data:
      entity_id: light.main_bulb_1
      brightness_pct: 100

I use those so that you can use the same webhook for multiple things. Want to hook up a second device, or another person’s phone, update who. Want to handle more than ringing, update what, and so on. I use the webhook for:

  • Reporting whether the phone/tablet was connected to power, or disconnected from power (multiple people and devices)
  • Reporting what time the next alarm on the phone is set to (multiple people and devices)
  • Tracking whether I’m in the car (so far only me)
  • more

All this with a single webhook.

What you’ve got will work for any use of the webhook, no matter what data is sent. That’s fine if you want a single purpose webhook.

2 Likes

thanks for this. I might use webhook in the future for tasker. my current method was http sensor, but this looks better.