explain value extraction via template (#1891)

* explain value extraction via template

Getting values from a JSON variable via `state_format` did not work for me, but using `value_template` worked. I added some explanation on how to use it.

* wrap template with {% raw %}...{% endraw %}
This commit is contained in:
Felix Fischer 2017-02-02 09:25:08 +01:00 committed by Fabian Affolter
parent f72701dba6
commit 53c3ff3fdc

View File

@ -279,6 +279,13 @@ switch:
platform: mqtt platform: mqtt
state_format: 'json:somekey[0].value' state_format: 'json:somekey[0].value'
``` ```
It is also possible to extract JSON values by using a value template:
```yaml
switch:
platform: mqtt
value_template: '{% raw %}{{ value_json.somekey[0].value }}{% endraw %}'
```
More information about the full JSONPath syntax can be found [here][JSONPath syntax]. More information about the full JSONPath syntax can be found [here][JSONPath syntax].