Trying to get my first tasker automation to work

hi all,

wonder if someone out there can lend me a hand.

i’m trying to get a light to flash when my mobile phone rings (this is the ultimate goal).

here is what i’m currently trying… I’ve dumbed it down for testing purposes, i’m just changing the brightness of a light for now as i don’t know how to get the light to flash either, but that’s another problem…

installed tasker (tester) on my mobile phone

set an event for when my phone rings (caller = C:ANY , Priority = Highest)

set a task:
HTTP Request
Method POST
URL: Http://Hass.io.ip.address:8123/api/services/light_on?api_password=HASSIOPASSWORD (i entered my actual ip and password not this)

File to send
{“entity_id”:“light.main_bulb_1”,“brightness_pct”:“100”}

timeout = 11 sec

clicked to get back to the main tasker screen to check everything is there… it is… closed tasker and phoned myself from the landline…

nothing from the light…

what am i doing wrong? to be fair all this i have got from a BRUH youtube video from 3 years ago so i guess something has quite possibly changed…

any help is greatly received

thank you

Robin

Hi, try following this instead, I’m not sure api_password method is still working.

Unfortunately Home Assistant moves rapidly, and videos from 3 months ago can mislead you, never mind ones from years ago.

I use the webhook trigger with Tasker. This also means you’re separating out the logic of how your home works from Tasker, which makes things far easier to work with.

This is my automation - I fire an event so that I can use the one webhook with many activities, such as here.

On the Tasker side I use the HTTP Request action, POST for the Method, the webhook URI for the URL (https://my-homeassistant.example.com/api/webhook/SomeLongSecretStringGoesHere), Content-type: application/json for the Headers, and then a JSON formatted body.

Thanks, I guess my understanding of webhooks just doesn’t exist lol I thought I was trying to get webhooks to work via tasker lol.

I’m going to have to spend some time understanding all this and getting it all to work properly as I have a feeling I may end up using it alot in the future… Back to the drawing board I guess for a lot of trial and error and learning…

Thanks all I’ll post back when I start to move forward with this :grinning:

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.