From 1230df26a326b606c1bca37546237205168ebd85 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 14 Dec 2021 02:14:01 +0100 Subject: [PATCH] Clarify command_line runtime environment (#19150) Co-authored-by: Franck Nijhof --- source/_integrations/command_line.markdown | 12 ++++++++++++ source/_integrations/sensor.command_line.markdown | 13 +++++++++++++ source/_integrations/shell_command.markdown | 10 ++++++++++ 3 files changed, 35 insertions(+) diff --git a/source/_integrations/command_line.markdown b/source/_integrations/command_line.markdown index 97e73861dc5..fb2485ba441 100644 --- a/source/_integrations/command_line.markdown +++ b/source/_integrations/command_line.markdown @@ -74,6 +74,18 @@ command_timeout: default: 15 {% endconfiguration %} +## Execution + +The `command` is executed within the [configuration directory](/docs/configuration/). + +
+ +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. + +
+ +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. diff --git a/source/_integrations/sensor.command_line.markdown b/source/_integrations/sensor.command_line.markdown index 38843c89f09..c15e824401b 100644 --- a/source/_integrations/sensor.command_line.markdown +++ b/source/_integrations/sensor.command_line.markdown @@ -56,6 +56,18 @@ json_attributes: type: [string, list] {% endconfiguration %} +## Execution + +The `command` is executed within the [configuration directory](/docs/configuration/). + +
+ +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. + +
+ +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 %} + diff --git a/source/_integrations/shell_command.markdown b/source/_integrations/shell_command.markdown index 9ff98e724a5..0f2e5e02833 100644 --- a/source/_integrations/shell_command.markdown +++ b/source/_integrations/shell_command.markdown @@ -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/). + +
+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. +
+ +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