IFTTT to HA

I have been using HA for about a month, utilizing youtube videos and other forum post to help me along the way. Im running 0.103.5 on a rpi b3+. I have hit a slight wall as to get a webhook to trigger either a single device or run a script.

I have created a webhook in IFTTT to trigger a script, I can see that the applet ran but nothing happens in HA.

Could somebody please help me as im stuck.

webhook setup

https://xxx.duckdns.org/api/webhook/really.long.key
application/json
{“entity_id”: “script.1645830544211”}

HA setup

automations.ymal

- id: ifttt_automation
  alias: IFTTT Automation
  trigger:
    platform: event
    event_type: ifttt_webhook_received
    event_data:
      action: call_service
  action:
    service_template: '{{ trigger.event.data.service }}'
    data_template:
      entity_id: '{{ trigger.event.data.entity_id }}'
      state: '{{ trigger.event.data.state }}'

let me know if more info is needed

Please format your code correctly. Mark the code, press the </> button on top, done.

Hi, welcome to HA and the forum! :slight_smile:

When posting code snippets, URLs, log messages, etc., please format them properly. E.g., enter a line before and after containing just three “back ticks”, like this:

```
code snippet
```

The default formatting will change indentation, quote characters, etc.

Formatting done

Thanks.

Well, your webhook request doesn’t match the automation. The automation requires four pieces of data – action, service, entity_id & state – but you only provided entity_id in the webhook.

If you just want to invoke a script (and use the webhook URL as is), then you could change your automation to:

- id: ifttt_automation
  alias: IFTTT Automation
  trigger:
    platform: event
    event_type: ifttt_webhook_received
  action:
    service_template: '{{ trigger.event.data.entity_id }}'
1 Like

Don’t know much about IFTTT, however I don’t see any “state” or “service” provided in the data from the IFTTT, I only see the “entity_id”.

Thanks Phil

I have changed the ymal to your code, however the script still does not trigger in HA.

Am I missing something from somewhere else in HA

Let’s check a few basics…

Go to the EVENTS tab of the Developers Tools page. Enter ifttt_webhook_received where it says “Event to subscribe to” and click START LISTENING. Then cause your IFTTT applet to send the webhook request. You should see an event printed on that page. If you do then click STOP LISTENING and post what get (and remember to format it properly.) If you don’t then you need to check the IFTTT applet.

This is what I get

{
    "event_type": "ifttt_webhook_received",
    "data": {
        "entity_id": "script.1645830544211",
        "webhook_id": "really.long.key"
    },
    "origin": "LOCAL",
    "time_fired": "2020-01-02T18:09:59.680250+00:00",
    "context": {
        "id": "eff46a60457e455a8efdcf80fe8305e5",
        "parent_id": null,
        "user_id": null
    }
}

I was wondering if there was some sort of “wireshark” trace in HA

Ok, looks like the webhook is being received ok and is generating the expected event.

Look on the STATES tab of the Developer Tools page. Do you see script.1645830544211 listed?

Also, are there any errors on the LOGS tab?

I can see script.164583054421 listed. If I click on ‘more info’ I can execute the script. There are no errors in the log

Check automation.ifttt_automation. Is it on?

Also, did you restart HA after changing the automation?

automation.ifttt_automation was not listed in the current entities so I created it and set the state to on. I have not restarted HA but will do that now and will let you know

What do you mean you created it and set the state to on?

If it wasn’t listed, then the automation didn’t exist, which is why it wasn’t doing anything. :wink: When you change automations.yaml you need to restart, or at least click on RELOAD AUTOMATIONS on the Configuration → Server Controls page.

Within Developer Tools - States I added automation.ifttt_automation and state to on at the top of the page.

I have just restarted HA and now the webhooks are triggering in HA.

I think i’ve configured this the long way round. I have restarted HA many times trying different things but your wisdom has pointed me in the correct direction and I can now start putting my hair back in.

That doesn’t actually add an automation. That just creates the representation of its state in the State Machine.

In any case, glad you got it working!