Integration IFTTT, Google Home and HASSIO - not trigerring switch

Hi all,

I have Hassio installed from the image on a Raspberry PI3.
I have configured my duckdns in https and it works
I have a google home and a IFTTT account (it works for other triggers).
The connection IFTT and Google Assistant works fine (my command is understood and I have the vocal reply).

I’m a newbie, but I have read (all) the tutorials and followed the instructions.
https://community.home-assistant.io/t/ifttt-webhook-and-webhook-id/84670
https://community.home-assistant.io/t/how-to-integrate-google-assistant-and-home-assistant-api-using-only-ifttt/19269
and so on.

In my configuration.yaml, I added

automation: !include automations.yaml
script: !include scripts.yaml

# Example configuration.yaml entry
ifttt:
  key: xxx - found on the (https://ifttt.com/maker_webhooks/settings) 

In the automation.yaml, I put

- alias: automate_ifttt
  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 }}'

In my script.yaml (number was generated in the HASSIO script editor)

'1575417635560': 
  alias: allume_TV
  sequence:
  - device_id: 0622cf9141e44e14ae631fae2ec0f6c8
    domain: switch
    entity_id: switch.nodon_id_rf_asp_3_1_00_smart_plug_switch
    type: toggle

I test my script in the HASSIO Developpement tool/Service and it trigger my switch.

In the IFTT applet, I put in the Make a web request triggered by Google Assitanst (Say a simple phrase)

URL : https://MYDNS.duckdns.org:8123/api/webhook/xxxx (found once during the IFTT integration)
Method : POST
Content : application/JSON
Body : { “action”: “call_service”, “service”: “script.toggle”, “entity_id”:“script.1575417635560” } 

I think I have done everything, BUT it doesn’t work :unamused:

When I talk to my Google Home Assistant or App, it replies to my command and the applet is run with no error (I can see in the activity). BUT nothing is triggered… no error but nothing is done.

Where to find the activity of the HASSIO and for instance the request coming form IFTTT ? I could see if I received something or not and dig further…

Anyone has an idea ?

IFTTT integration is a bit confusing.

First, the ifttt key setting in your configuration is only used when sending to IFTTT. It has nothing to do with receiving from IFTTT.

Next, I’m assuming this is a copy/paste/formatting issue, but make sure the double-quote characters in the IFTTT applet web request Body are the plain " and not the fancy or .

Next, to see if HA is receiving the request from IFTTT, go to the EVENTS tab of the Developer Tools page. Enter ifttt_webhook_received where it says “Event to subscribe to”, then click START LISTENING. Now cause IFTTT to send the request. If/when it is received by HA the details of the request will be shown on that page, something like this:

Event 0 fired 9:34 AM:

{
    "event_type": "ifttt_webhook_received",
    "data": {
        "type": "presence",
        "who": "ian",
        "activity": "exited",
        "webhook_id": "xxx"
    },
    "origin": "LOCAL",
    "time_fired": "2019-12-04T15:34:50.923256+00:00",
    "context": {
        "id": "0c328097f76f44b9b8c0ece008084c26",
        "parent_id": null,
        "user_id": null
    }
}

When you’re done using this tool click STOP LISTENING.

Next, note that the IFTTT HA example is only an example. Specifying parameters in the web request Body that request HA call a service is a nice, generic mechanism and the same automation can, therefore, handle several different requests (as long as they all call a service that accepts an entity_id parameter.) However, you’re free to put anything in the web request Body and write a corresponding automation event trigger. Which leads me to my next point…

Automation event triggers work by trying to match every event in HA against the parameters of the trigger. Obviously the event_type has to match. But the way the event_data parameter works is a little less obvious. First, the event_data parameter of the trigger corresponds to the data key of the event itself. So in the example event I showed above, the trigger might look like this:

trigger:
  platform: event
  event_type: ifttt_webhook_received
  event_data:
    type: presence

Next, anything you put under event_data must match the corresponding value in the event, but only if it’s actually in the event data. So in this example I put type: presence in the trigger. So if type is in the event data, then it must be presence. But if the event data does not contain a key named type, then that will “match”, too. This, I think, is the part that trips up most people.

So, to summarize, what you entered in both HA and IFTTT look ok to me (except for maybe the quote characters in the web request Body.) Using the technique described above, see if HA is receiving the IFTTT request. If it does, check the details of the event data to see if it’s what you were expecting.

EDIT: Oh, one other thing. To cause a script to run it’s probably better to use the script.turn_on service instead of script.toggle (although script.toggle will probably work.)

1 Like

Oh damned !! It was exactly what you suspected : the quotes were not the good ones in the IFTTT applet !!!
To avoid typo, I copied the block from the HA forum and pasted into the applet, but may be conversion between PC and MAC gave this kind of fancy quotes…

Now it works, I will come back to script.turn_on (even if toggle is working). It will be more explicit for me in the long term.

I will also look in detail your explanations on the event.

Thanks a lot !!!

2 Likes