mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-05-31 23:36:50 +00:00
Add template entity script action documentation (#28768)
* Add template entity script action documentation * Update source/_integrations/template.markdown Co-authored-by: Erik Montnemery <erik@montnemery.com> * Focus action explanation on variables avaiable in templates * Remove whitespace * tiny tweak --------- Co-authored-by: Erik Montnemery <erik@montnemery.com> Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
parent
724878a111
commit
72062aa3de
@ -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)._
|
||||
|
Loading…
x
Reference in New Issue
Block a user