How to Add Webhooks to Home Assistant

This weekend, I finally got around to fixing my IFTTT to Home Assistant WebHooks. Documented in issue #426. Webhooks and IFTTT can be used to bridge devices that do not yet have full support in Home Assistant but ARE supported by the IFTTT service. During this process, I actually learned about two useful methods for interacting with IFTTT. For this set of automations, I am focusing on triggers FROM IFTTT being sent to Home Assistant. This changed over time in Home Assistant as they introduced a new event handler specifically for IFTTT. In the past, you could hit the Home Assistant API with a single URL. You could add legacy API passwords into the URL and cause HA to fire an appropriate event that could then be used to trigger different automation.

Shell
Old YAML
Shell
New YAML

This new event_type is now standardized for IFTTT as ifttt_webhook_recieved. You then pass variables from IFTTT as actions. The post data in the IFTTT recipe would now look like this:

You can see the new code in action here:
https://github.com/CCOSTAN/Home-AssistantConfig/blob/master/config/automation/flash_all.yaml#L26-L30

For this new type of IFTTT trigger to work, I used a webhook leveraging my Nabu Casa subscription.
Created in the Home Assistant integration section, you get a very complex randomly generated URL to Nabu Casa that acts as a bridge to your local Home Assistant instance.

Once the IFTTT webhook is created, you can then add this to your IFTTT recipes as the URL.

This is all you need to set up the IFTTT integration. There is another way to do it as well if you don’t need authentication or security. These are called Webhook triggers.
The webhook triggers are just simple URL triggers in the format of https://your-home-assistant:8123/api/webhook/some_hook_id.

You then use the following YAML code to capture the trigger in an automation.

Shell
Webhook Trigger

Since there is no authentication, be sure to use these carefully with things that have little consequence if discovered.

Happy Automating!
Carlo

TAGS