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:
parent
f72701dba6
commit
53c3ff3fdc
1 changed files with 7 additions and 0 deletions
|
@ -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].
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue