From 2e14a909fcd96828cbbb0a8b8c6c9d6cd8f551b4 Mon Sep 17 00:00:00 2001 From: Carlo Costanzo Date: Fri, 2 Dec 2016 08:32:36 -0500 Subject: [PATCH] Example of Data_template with IFTTT (#1522) This drove me nuts for a few hours trying to get the exact syntax down so I thought I would share. --- source/_components/ifttt.markdown | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source/_components/ifttt.markdown b/source/_components/ifttt.markdown index 7971c89ebb3..a5f38ad2d5c 100644 --- a/source/_components/ifttt.markdown +++ b/source/_components/ifttt.markdown @@ -74,6 +74,31 @@ automation: data: {"event":"TestHA_Trigger", "value1":"Hello World!"} ``` +IFTTT can also be used in scripts and with `data_template`. Here is the above automation broken into an automation and script using variables and data_templates. + +```yaml +# Example configuration.yaml Automation entry +automation: + alias: Startup Notification + trigger: + platform: event + event_type: homeassistant_start + action: + service: script.ifttt_notify + data_template: + value1: 'HA Status:' + value2: "{{ trigger.event.data.entity_id.split('_')[1] }} is " + value3: "{{ trigger.event.data.to_state.state }}" +``` + +```yaml +#Example Script to send TestHA_Trigger to IFTTT but with some other data (homeassistant UP). +ifttt_notify: + sequence: + - service: ifttt.trigger + data_template: {"event":"TestHA_Trigger", "value1":"{{ value1 }}", "value2":"{{ value2 }}", "value3":"{{ value3 }}"} +``` + ### {% linkable_title Sending events from IFTTT to Home Assistant %} To be able to receive events from IFTTT, your Home Assistant instance needs to be accessible from the web. This can be achieved by forwarding port 8123 from your router to the device running Home Assistant. If your ISP is giving you a new IP address from time to time, consider using [DuckDNS](https://duckdns.org).