From 6d1c5eda38a78f611ca9cf682aceb1f1030e44ad Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 8 Oct 2018 20:16:29 +0200 Subject: [PATCH] Add webhook trigger docs (#6610) --- source/_docs/automation/templating.markdown | 9 +++++++++ source/_docs/automation/trigger.markdown | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/_docs/automation/templating.markdown b/source/_docs/automation/templating.markdown index 74f0427f48c..a34d46cc3c6 100644 --- a/source/_docs/automation/templating.markdown +++ b/source/_docs/automation/templating.markdown @@ -126,6 +126,15 @@ The following tables show the available trigger data per platform. | `trigger.platform` | Hardcoded: `time` | `trigger.now` | DateTime object that triggered the time trigger. +### {% linkable_title webhook %} + +| Template variable | Data | +| ---- | ---- | +| `trigger.platform` | Hardcoded: `webhook` +| `trigger.webhook_id` | The webhook ID that was triggered. +| `trigger.json` | The JSON data of the request (if it had a JSON content type). +| `trigger.data` | The form data of the request (if it had a form data content type). + ### {% linkable_title zone %} | Template variable | Data | diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown index e682a20c389..734799268b6 100644 --- a/source/_docs/automation/trigger.markdown +++ b/source/_docs/automation/trigger.markdown @@ -125,7 +125,7 @@ automation: offset: '-00:45:00' ``` -Sometimes you may want more granular control over an automation based on the elevation of the sun. This can be used to layer automations to occur as the sun lowers on the horizon or even after it is below the horizon. This is also useful when the "sunset" event is not dark enough outside and you would like the automation to run later at a precise solar angle instead of the time offset such as turning on exterior lighting. +Sometimes you may want more granular control over an automation based on the elevation of the sun. This can be used to layer automations to occur as the sun lowers on the horizon or even after it is below the horizon. This is also useful when the "sunset" event is not dark enough outside and you would like the automation to run later at a precise solar angle instead of the time offset such as turning on exterior lighting. {% raw %} ```yaml @@ -190,9 +190,20 @@ automation 3: seconds: 00 ```

- Remember that if you are using matching to include both `minutes` and `seconds`. Without `seconds`, your automation will trigger 60 times during the matching minute. + Remember that if you are using matching to include both `minutes` and `seconds`. Without `seconds`, your automation will trigger 60 times during the matching minute.

+### {% linkable_title Webhook trigger %} + +Webhook triggers are triggered by web requests made to the webhook endpoint: `/api/webhook/`. This endpoint does not require authentication besides knowing the webhook id. You can either send encoded form or JSON data, available in the template as either `trigger.json` or `trigger.data`. + +```yaml +automation: + trigger: + platform: webhook + webhook_id: +``` + ### {% linkable_title Zone trigger %} Zone triggers can trigger when an entity is entering or leaving the zone. For zone automation to work, you need to have setup a device tracker platform that supports reporting GPS coordinates. This includes [GPS Logger](/components/device_tracker.gpslogger/), the [OwnTracks platform](/components/device_tracker.owntracks/) and the [iCloud platform](/components/device_tracker.icloud/).