Clarify command_line runtime environment (#19150)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Lars 2021-12-14 02:14:01 +01:00 committed by GitHub
parent 599653d89f
commit 1230df26a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 0 deletions

View File

@ -74,6 +74,18 @@ command_timeout:
default: 15
{% endconfiguration %}
## Execution
The `command` is executed within the [configuration directory](/docs/configuration/).
<div class='note'>
If you are using [Home Assistant Operating System](https://github.com/home-assistant/operating-system), the commands are executed in the `homeassistant` container context. So if you test or debug your script, it might make sense to do this in the context of this container to get the same runtime environment.
</div>
With a `0` exit code, the output (stdout) of the command is used as `value`. In case a command results in a non `0` exit code or is terminated by the `command_timeout`, the result is only logged to Home Assistant log and the sensors value is not updated.
## Examples
In this section you find some real-life examples of how to use this sensor.

View File

@ -56,6 +56,18 @@ json_attributes:
type: [string, list]
{% endconfiguration %}
## Execution
The `command` is executed within the [configuration directory](/docs/configuration/).
<div class='note'>
If you are using [Home Assistant Operating System](https://github.com/home-assistant/operating-system), the commands are executed in the `homeassistant` container context. So if you test or debug your script, it might make sense to do this in the context of this container to get the same runtime environment.
</div>
With a `0` exit code, the output (stdout) of the command is used as `value`. In case a command results in a non `0` exit code or is terminated by the `command_timeout`, the result is only logged to Home Assistant log and the value of the sensor is not updated.
## Examples
In this section you find some real-life examples of how to use this sensor.
@ -189,3 +201,4 @@ sensor:
```
{% endraw %}

View File

@ -39,6 +39,16 @@ Any service data passed into the service call to activate the shell command will
`stdout` and `stderr` output from the command are both captured and will be logged by setting the [log level](/integrations/logger/) to debug.
## Execution
The `command` is executed within the [configuration directory](/docs/configuration/).
<div class='note'>
If you are using [Home Assistant operating system](https://github.com/home-assistant/operating-system), the commands are executed in the `homeassistant` container context. So if you test or debug your script, it might make sense to do this in the context of this container to get the same runtime environment.
</div>
With a `0` exit code, the output (stdout) of the command is used as `value`. In case a command results in a non `0` exit code or is terminated by the `command_timeout`, the result is only logged to Home Assistant log and the value of the sensor is not updated.
## Examples
### Defining multiple shell commands