mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 09:17:06 +00:00
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
@ -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…
x
Reference in New Issue
Block a user