mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-20 07:46:52 +00:00
Add documentation for json_attributes in command (#5889)
* Add documentation for json_attributes in command * Fix formatting
This commit is contained in:
parent
ecaa94ff53
commit
eceee28362
@ -33,6 +33,7 @@ Configuration variables:
|
|||||||
- **value_template** (*Optional*): Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload.
|
- **value_template** (*Optional*): Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload.
|
||||||
- **scan_interval** (*Optional*): Defines number of seconds for polling interval (defaults to 60 seconds).
|
- **scan_interval** (*Optional*): Defines number of seconds for polling interval (defaults to 60 seconds).
|
||||||
- **command_timeout** (*Optional*): Defines number of seconds for command timeout (defaults to 15 seconds).
|
- **command_timeout** (*Optional*): Defines number of seconds for command timeout (defaults to 15 seconds).
|
||||||
|
- **json_attributes** (*Optional*): Defines a list of keys to extract values from a JSON dictionary result and then set as sensor attributes.
|
||||||
|
|
||||||
## {% linkable_title Examples %}
|
## {% linkable_title Examples %}
|
||||||
|
|
||||||
@ -162,3 +163,22 @@ sensor:
|
|||||||
unit_of_measurement: "Direction"
|
unit_of_measurement: "Direction"
|
||||||
```
|
```
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
|
|
||||||
|
### {% linkable_title Usage of JSON attributes in command output %}
|
||||||
|
|
||||||
|
The example shows how you can retrieve multiple values with one sensor (where the additional are attributes) by using `value_json` and `json_attributes`.
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
```yaml
|
||||||
|
# Example configuration.yaml entry
|
||||||
|
sensor:
|
||||||
|
- platform: command_line
|
||||||
|
name: JSON time
|
||||||
|
json_attributes:
|
||||||
|
- date
|
||||||
|
- milliseconds_since_epoch
|
||||||
|
command: 'python3 /home/pi/.homeassistant/scripts/datetime.py'
|
||||||
|
value_template: '{{ value_json.time }}'
|
||||||
|
```
|
||||||
|
{% endraw %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user