mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-04-29 07:47:48 +00:00

* Split MQTT documentation * Add more details * Move content to /docs * Enable sidebar * Move content to /docs * Enable sidebar * Move content * Update links * Remove wizard stuff * Enable sidebar * Minor changes * Move MQTT parts to /docs * update links * Update links and sync content * Fix link * Enable sidebar * Remove navigation * Remove navigation and other minor updates * Update links * Add overview page * Make title linkable * Update * Plit content * Update links * Rearrange content * New getting-started section * Add icons for docs * Update for new structure * Update for new structure * Add docs navigation * Add docs overview page * Remove ecosystem navigation * Add docs and remove other collections * Move ecosystem to docs * Remove duplicate files * Re-add ecosystem overview * Move to ecosystem * Fix permission * Update navigation * Remove collection * Move overview to right folder * Move mqtt to upper level * Move notebook to ecosystem * Remove un-used files * Add one more rectangle for iOS * Move two parts back from docs and rename Run step * Remove colon * update getting-started section * Add redirect * Update * Update navigation
1.2 KiB
1.2 KiB
layout | title | description | date | sidebar | comments | sharing | footer | logo | redirect_from |
---|---|---|---|---|---|---|---|---|---|
page | Processing JSON | Instructions how to process the MQTT payload. | 2015-08-07 18:00 | true | false | true | true | mqtt.png | /components/mqtt/#processing-json |
The MQTT switch and sensor platforms support processing JSON over MQTT messages and parsing them using JSONPath. JSONPath allows you to specify where in the JSON the value resides that you want to use. The following examples will always return the value 100
.
JSONPath query | JSON |
---|---|
somekey |
{ 'somekey': 100 } |
somekey[0] |
{ 'somekey': [100] } |
somekey[0].value |
{ 'somekey': [ { value: 100 } ] } |
To use this, add the following key to your configuration.yaml
:
switch:
platform: mqtt
state_format: 'json:somekey[0].value'
It is also possible to extract JSON values by using a value template:
switch:
platform: mqtt
value_template: '{% raw %}{{ value_json.somekey[0].value }}{% endraw %}'
More information about the full JSONPath syntax can be found in their documentation.