From 3eb6e62e048e1d2ad037942a2669001b84b11a4e Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Mon, 30 May 2022 04:01:45 -0700 Subject: [PATCH] Update calendar automation recipes (#22846) --- source/_integrations/calendar.markdown | 55 ++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/source/_integrations/calendar.markdown b/source/_integrations/calendar.markdown index 07313232c45..8cc7fe0c9e5 100644 --- a/source/_integrations/calendar.markdown +++ b/source/_integrations/calendar.markdown @@ -34,11 +34,22 @@ automation: entity_id: calendar.personal ``` -### Example Automation +Calendar triggers should should generally not use automation mode `single` to ensure the trigger +can fire when multiple events start at the same time (e.g. use `queued` or `parallel` instead) -This is an example of an automation that sends a notification with details about the event that -triggered the automation. See [Automation Trigger Variables: Calendar](/docs/automation/templating/#calendar) for additional trigger data available for conditions or actions. +See [Automation Trigger Variables: Calendar](/docs/automation/templating/#calendar) for additional trigger data available for conditions or actions. +### Automation Recipes + +Below are a few example ways you can use Calendar triggers. + +{% details "Example: Calendar Event Notification " %} + +This example automation consists of: +- For the calendar entity `calendar.personal` +- At the start of any calendar event +- Send a notification with the title and start time of the event +- Allowing multiple events starting at the same time {% raw %} ```yaml @@ -54,6 +65,42 @@ automation: message: >- Event {{ trigger.calendar_event.summary }} @ {{ trigger.calendar_event.start }} - mode: single + mode: queued ``` {% endraw %} + +{% enddetails %} + +{% details "Example: Calendar Event Light Schedule " %} + +This example consists of: +- For the calendar entity ` calendar.device_automation` +- When event summary contains `Front Lights` +- Turn on and off light named `light.front` when the event starts and ends + +{% raw %} +```yaml +automation: + alias: Front Light Schedule + trigger: + - platform: calendar + event: start + entity_id: calendar.device_automation + - platform: calendar + event: end + entity_id: calendar.device_automation + condition: + - condition: template + value_template: "{{ 'Front Lights' in trigger.calendar_event.summary }}" + action: + - if: + - "{{ trigger.event == 'start' }}" + then: + - service: light.turn_on + else: + - service: light.turn_off + mode: queued +``` +{% endraw %} + +{% enddetails %}