docs: fix jinja2 example
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
adfe8a67b6
commit
1d1ce0671d
|
@ -1315,12 +1315,12 @@ command_topic: my/mqtt/command
|
|||
# Lets assume this device requres a json payload with each command.
|
||||
# We will use a dict to generate the payload
|
||||
command_payload:
|
||||
{% set my_payload = {} %}
|
||||
{% do my_payload["SOME_FIELD"] = "some_string" %}
|
||||
{% do my_payload["ANOTHER_FIELD"] = True %}
|
||||
{% set my_payload = {"SOME_FIELD": ""} %}
|
||||
# example of calling the dict.update method
|
||||
{% do my_payload.update({"SOME_FIELD": "a string value"}) %}
|
||||
# Here we set the actual command, the "command" variable
|
||||
# is passed to the context of this template
|
||||
{% do my_payload["POWER_COMMAND"] = command %}
|
||||
{% do my_payload.__setitem__("POWER_COMMAND", command) %}
|
||||
# generate the json output
|
||||
{ my_payload|tojson }
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue