Skip to content

Commit 5752c94

Browse files
authored
Add documentation for calendar trigger initial version (#22328)
1 parent 4efc8cd commit 5752c94

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

source/_docs/automation/templating.markdown

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ The following describes trigger data associated with all platforms.
2424
| `trigger.id` | Optional trigger `id`, or index of the trigger.
2525
| `trigger.idx` | Index of the trigger.
2626

27+
### Calendar
28+
29+
| Template variable | Data |
30+
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
31+
| `trigger.platform` | Hardcoded: `calendar` |
32+
| `trigger.event_type` | The trigger event type, either `start` or `end` |
33+
| `trigger.calendar_event` | The calendar event object matched. |
34+
| `trigger.calendar_event.summary` | The title or summary of the calendar event. |
35+
| `trigger.calendar_event.start` | String representation of the start date or date time of the calendar event e.g. `2022-04-10`, or `2022-04-10 11:30:00-07:00` |
36+
| `trigger.calendar_event.end` | String representation of the end time of date time the calendar event in UTC e.g. `2022-04-11`, or `2022-04-10 11:45:00-07:00` |
37+
| `trigger.calendar_event.all_day` | Indicates the event spans the entire day. |
38+
| `trigger.calendar_event.description` | A detailed description of the calendar event, if available. |
39+
| `trigger.calendar_event.location` | Location information for the calendar event, if available. |
2740
### Device
2841

2942
| Template variable | Data |

source/_docs/automation/trigger.markdown

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ An automation can be triggered by an event, with a certain entity state, at a gi
2323
- [Zone trigger](#zone-trigger)
2424
- [Geolocation trigger](#geolocation-trigger)
2525
- [Device triggers](#device-triggers)
26+
- [Calendar trigger](#calendar-trigger)
2627
- [Multiple triggers](#multiple-triggers)
2728
- [Multiple Entity IDs for the same Trigger](#multiple-entity-ids-for-the-same-trigger)
2829

@@ -851,6 +852,25 @@ In contrast to state triggers, device triggers are tied to a device and not nece
851852
To use a device trigger, set up an automation through the browser frontend.
852853
If you would like to use a device trigger for an automation that is not managed through the browser frontend, you can copy the YAML from the trigger widget in the frontend and paste it into your automation's trigger list.
853854

855+
## Calendar trigger
856+
857+
Calendar trigger fires when a [Calendar](/integrations/calendar/) event starts or ends, allowing
858+
much more flexible automations that using the Calendar entity state which only supports a single
859+
event start at a time.
860+
861+
```yaml
862+
automation:
863+
trigger:
864+
- platform: calendar
865+
# Possible values: start, end
866+
event: start
867+
# The calendar entity_id
868+
entity_id: calendar.light_schedule
869+
```
870+
871+
See the [Calendar](/integrations/calendar/) integration for more details on event triggers and the
872+
additional event data available for use by an automation.
873+
854874
## Multiple triggers
855875

856876
It is possible to specify multiple triggers for the same rule. To do so just prefix the first line of each trigger with a dash (-) and indent the next lines accordingly. Whenever one of the triggers fires, [processing](#what-are-triggers) of your automation rule begins.

source/_integrations/calendar.markdown

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,50 @@ ha_codeowners:
1010
ha_integration_type: integration
1111
---
1212

13-
The calendar integration allows you to integrate your calendars into Home Assistant.
13+
The calendar integration allows you to integrate your calendars into Home Assistant. Calendars are shown on the calendar dashboard, and can be used with automations.
14+
15+
A calendar entity has state and attributes represent the next upcoming event (only). A calendar trigger is much more flexible, has fewer limitations, and is recommended for automations, instead of using the entity state.
16+
17+
## Automation
18+
19+
Calendar [Triggers](/docs/automation/trigger) enable automation based on an event start or end. Review the [Automating Home Assistant](/getting-started/automation/) getting started guide on automations or the [Automation](/docs/automation/) documentation for full details.
20+
21+
{% my automations badge %}
22+
23+
![Screenshot Trigger](/images/integrations/calendar/trigger.png)
24+
25+
An example of a calendar trigger in yaml:
26+
27+
```yaml
28+
automation:
29+
trigger:
30+
- platform: calendar
31+
# Possible values: start, end
32+
event: start
33+
# The calendar entity_id
34+
entity_id: calendar.personal
35+
```
36+
37+
### Example Automation
38+
39+
This is an example of an automation that sends a notification with details about the event that
40+
triggered the automation. See [Automation Trigger Variables: Calendar](/docs/automation/templating/#calendar) for additional trigger data available for conditions or actions.
41+
42+
43+
{% raw %}
44+
```yaml
45+
automation:
46+
alias: Calendar notification
47+
trigger:
48+
- platform: calendar
49+
event: start
50+
entity_id: calendar.personal
51+
action:
52+
- service: persistent_notification.create
53+
data:
54+
message: >-
55+
Event {{ trigger.calendar_event.summary }} @
56+
{{ trigger.calendar_event.start }}
57+
mode: single
58+
```
59+
{% endraw %}
93.5 KB
Loading

0 commit comments

Comments
 (0)