Help with IFTTT webhook

I am trying to take data from an ifttt webhook and display/update a sensor.

I am using the Mojio ifttt to report on our vehicle location when a trip completes, and I want to display the car location and trip info in HA. If I can create a device_tracker from the webhook’s body data that would be great, but I’d be fine with just a sensor to display address/time/etc.

My IFTTT is running without issue. I’m properly integrated to IFTTT, since I am successfully sending events to IFTTT in other automations. But I cannot get things to work with HA consuming the webhook.

This is my json body being posted with my nabucasa url:

{ "date": {{CreatedAt}}, "friendly_name" : {{VehicleName}}, "start_address" : {{StartAddress}}, "end_address" : {{EndAddress}}, "total_miles" : {{DistanceMiles}} }

It appears that my webhook is being received based on this log:

Received message for unregistered webhook ##############################

1:45 PM components/webhook/init.py (WARNING) - message first occurred at 9:17 AM and shows up 30 times

Is the only way to register this webhook is to make an automation in my yaml? I’ve seen lots of examples like this:

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 }}'

But all those examples seem to be sending event data in the body. I have data fields I want turned into a sensor or device_tracker. Is there a way to just create a new entity with the body of the webhook? or send it in mqtt and have that create a sensor? Any help or advice would be appreciated, I feel like I’m close, but I can’t figure out how to access that data, all the examples I’m finding are just firing off events in HA.

Thanks!

I feel like I drove around the block to go across the street, but this should work.

Created input_text to feed the IFTTT data into:

input_text:
  sensor_wyze_co_ifttt:
    name: "Wyze CO IFTTT State"
  sensor_wyze_co_ifttt_time:
    name: "Wyze CO IFTTT Time"
  sensor_wyze_co_ifttt_service:
    name: "Wyze CO IFTTT Service"

Setup template sensor to grab the data:

  - platform: template
    sensors:
      wyze_co_ifttt:
        value_template: "{{ states.input_text.sensor_wyze_co_ifttt.state }}"
        attribute_templates:
          time: "{{ states.input_text.sensor_wyze_co_ifttt_time.state }}"
          service: "{{ states.input_text.sensor_wyze_co_ifttt_service.state }}"

Then Setup automation which will fill the data.

- alias: Wyze CO IFTTT Trigger
  initial_state: on
  trigger:
    platform: event
    event_type: ifttt_webhook_received
    event_data:
      action: call_service
  condition:
    - condition: template
      value_template: "{{ trigger.event.data.service == 'shell_command.wyze_co_ifttt_shell' }}"
  action:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.sensor_wyze_co_ifttt
        value: '{{ trigger.event.data.state }}'
    - service: input_text.set_value
      data_template:
        entity_id: input_text.sensor_wyze_co_ifttt_time
        value: '{{ trigger.event.data.time }}'
    - service: input_text.set_value
      data_template:
        entity_id: input_text.sensor_wyze_co_ifttt_service
        value: '{{ trigger.event.data.service }}'

The IFTTT Body looks like this:

{"state":"{{CoDetected}}","time":"{{TriggerTime}}","service":"shell_command.wyze_co_ifttt_shell"}

I’ve been trying your first approach for a while (mostly because IFTTT seems to be having issues, can’t update a recipie) but this approach does look simpler and more direct. I’m going to try this out, thanks so much for the help!

You can run a curl command for testing instead of waiting for IFTTT.

curl -H 'Content-Type: application/json' -X POST -d '{"state":"on", "time":"10:00", "service":"shell_command.wyze_co_ifttt_shell"}' webhook_url_you_put_in_ifttt_recipe

Is there another step to register the ifttt webhook? My logs still show me getting the same unregistered webhook. Is there more to do to register then just creating an automation to handle the incoming data?

2020-01-06 18:40:33 WARNING (MainThread) [homeassistant.components.webhook] Received message for unregistered webhook 7e0312k2h43b89e2b348eb641e2a0c1e2jkh21l34u118c97c47e6fejl1231hjg2j8

The log has a big long randomized string in that warning message (the one above is redacted). Do I need to register that value somewhere?

It’s been a long time, but iirc the webhook you would use comes after you setup the integration.

https://www.home-assistant.io/integrations/ifttt/

Because I have a similar problem I thought is better to ask here instead of opening another thread. I have a script called “netflix” which works when i run it. I’m trying to setup IFTTT to run the script when i say “Ok google, XXXX”. I have managed the communication between IFTTT and HA but i’m getting the following errors. (I know I have to learn to read the errors but as new with scripts I don’t see where the problem is). Any help?

Netflix Script

  netflix:
    alias: Netflix Script
    sequence:
    - service: media_player.turn_on
      data_template:
        entity_id: >
          {% if (states('media_player.bedroom_tv') == 'off') and (states('media_player.living_room_tv') == 'off') %}
            media_player.living_room_tv
          {% endif %}
    - service: media_player.select_source
      data_template:
        entity_id: >
          {% if (states('media_player.bedroom_tv') == 'on') %}
            media_player.bedroom_tv
          {%-elif (states('media_player.living_room_tv') == 'on')  %}
            media_player.living_room_tv
          {% endif %}
        source: 'Netflix'```

IFTTT Trigger Automation

alias: IFTTT
trigger:
  platform: event
  event_type: ifttt_webhook_received
  event_data:
    action: call_service
action:
  service_template: '{{ trigger.event.data.service }}'
  data_template:
    name: '{{ trigger.event.data.name }}'

Errors

Log Details (ERROR)

Logger: homeassistant.components.script
Source: helpers/script.py:831
Integration: Script (documentation, issues)
First occurred: July 10, 2020, 11:33:05 PM (1 occurrences)
Last logged: July 10, 2020, 11:33:05 PM

Netflix Script: Error executing script. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]


Log Details (ERROR)

Logger: homeassistant.components.automation
Source: helpers/script.py:831
Integration: Automation (documentation, issues)
First occurred: July 10, 2020, 11:33:05 PM (1 occurrences)
Last logged: July 10, 2020, 11:33:05 PM

IFTTT: Error executing script. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]