diff --git a/source/_integrations/template.markdown b/source/_integrations/template.markdown index caab7a606b2..153eee1a261 100644 --- a/source/_integrations/template.markdown +++ b/source/_integrations/template.markdown @@ -112,6 +112,10 @@ unique_id: description: The unique ID for this config block. This will be prefixed to all unique IDs of all entities in this block. required: false type: string +action: + description: Define actions to be executed when the trigger fires. Optional. Variables set by the action script are available when evaluating entity templates. This can be used to interact with anything via services, in particular services with [response data](/docs/scripts/service-calls#use-templates-to-handle-response-data). [See action documentation](/docs/automation/action). + required: false + type: list sensor: description: List of sensors required: true @@ -660,6 +664,36 @@ template: {% endraw %} +### Trigger based handling of service response data + +This example demonstrates how to use an `action` to call a [service with response data](/docs/scripts/service-calls/#use-templates-to-handle-response-data) +and use the response in a template. + +{% raw %} + +```yaml +template: + - trigger: + - platform: time_pattern + hours: /1 + action: + - service: weather.get_forecast + data: + type: hourly + target: + entity_id: weather.home + response_variable: hourly + sensor: + - name: Weather Forecast Hourly + unique_id: weather_forecast_hourly + state: "{{ now().isoformat() }}" + attributes: + forecast: "{{ hourly.forecast }}" +``` + +{% endraw %} + + ## Legacy binary sensor configuration format _This format still works but is no longer recommended. [Use modern configuration](#configuration-variables)._