diff --git a/source/_docs/scripts/service-calls.markdown b/source/_docs/scripts/service-calls.markdown index d153233b4ca..03424e8a7d6 100644 --- a/source/_docs/scripts/service-calls.markdown +++ b/source/_docs/scripts/service-calls.markdown @@ -133,13 +133,12 @@ Examples of service response data are upcoming calendar events for the next week Templates can also be used for handling response data. The service call can specify a `response_variable`. This is the [variable](/docs/scripts/#variables) -that contains the response data. You can define any name for your `response_variable`. This example calls a service and stores the response in -the variable called `agenda`. +that contains the response data. You can define any name for your `response_variable`. This example calls a service and stores the response in the variable called `agenda`. {% raw %} ```yaml -service: calendar.list_events +service: calendar.get_events target: entity_id: calendar.school data: @@ -168,7 +167,7 @@ data: message: >- Your agenda for today:

- {% for event in agenda.events %} + {% for event in agenda['calendar.school'].events %} {{ event.start}}: {{ event.summary }}
{% endfor %}

diff --git a/source/_integrations/calendar.markdown b/source/_integrations/calendar.markdown index de20cd1328d..dc539ba1af0 100644 --- a/source/_integrations/calendar.markdown +++ b/source/_integrations/calendar.markdown @@ -192,10 +192,10 @@ data: {% endraw %} -### Service `calendar.list_events` +### Service `calendar.get_events` This service populates [Response Data](/docs/scripts/service-calls#use-templates-to-handle-response-data) -with calendar events within a date range. +with calendar events within a date range. It can return events from multiple calendars. | Service data attribute | Optional | Description | Example | | ---------------------- | -------- | ----------- | --------| @@ -209,20 +209,20 @@ Use only one of `end_date_time` or `duration`. - -{% raw %} ```yaml -service: calendar.list_events +service: calendar.get_events target: - entity_id: calendar.school + entity_id: + - calendar.school + - calendar.work data: duration: hours: 24 response_variable: agenda ``` -{% endraw %} -The response data field `events` is a list of events with these fields: +The response data contains a field for every calendar entity (e.g. `calendar.school` and `calendar.work` in this case). +Every calendar entity has a field `events` containing a list of events with these fields: | Response data | Description | Example | | ---------------------- | ----------- | -------- | @@ -236,16 +236,17 @@ This example uses a template with response data in another service call: {% raw %} ```yaml -service: notify.gmail_com +service: notify.nina data: - target: gduser1@workspacesamples.dev title: Daily agenda for {{ now().date() }} message: >- - Your agenda for today: -

- {% for event in agenda.events %} + Your school calendar for today: + {% for event in agenda["calendar.school_calendar"]["events"] %} + {{ event.start}}: {{ event.summary }}
+ {% endfor %} + Your work calendar for today: + {% for event in agenda["calendar.work_calendar"]["events"] %} {{ event.start}}: {{ event.summary }}
{% endfor %} -

``` {% endraw %}