Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions source/_docs/configuration/templating.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ To improve the experience of writing Jinja templates, we have enabled the follow
extensions:

* [Loop Controls](https://jinja.palletsprojects.com/en/3.0.x/extensions/#loop-controls) (`break` and `continue`)
* [Expression Statements](https://jinja.palletsprojects.com/en/3.0.x/templates/#expression-statement) (`do`)

## Home Assistant template extensions

Expand Down Expand Up @@ -991,6 +992,21 @@ To evaluate a response, go to **{% my developer_template title="Developer Tools

{% endraw %}

### Mutable dictionaries and lists

- Filter `as_mutable` takes a list or dictionary and returns a mutable copy that you can modify using the standard Python methods and the [`do` syntax](https://jinja.palletsprojects.com/en/3.0.x/templates/#expression-statement).

For example:

{% raw %}

```text
{% set dict = {} | as_mutable %}
{% do dict.update({"key": "value"}) %} {# dict now contains key->value #}
```

{% endraw %}

### Using templates with the MQTT integration

The [MQTT integration](/integrations/mqtt/) relies heavily on templates. Templates are used to transform incoming payloads (value templates) to status updates or incoming service calls (command templates) to payloads that configure the MQTT device.
Expand Down