mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-08 18:06:54 +00:00
Extend examples on Shell Command documentation (#17493)
This commit is contained in:
parent
96778b8931
commit
0de9f04589
@ -17,6 +17,8 @@ Shell commands aren't allowed for a camel-case naming, please use lowercase nami
|
|||||||
[script]: /integrations/script/
|
[script]: /integrations/script/
|
||||||
[automation]: /getting-started/automation/
|
[automation]: /getting-started/automation/
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
# Exposes service shell_command.restart_pow
|
# Exposes service shell_command.restart_pow
|
||||||
@ -37,6 +39,28 @@ 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.
|
`stdout` and `stderr` output from the command are both captured and will be logged by setting the [log level](/integrations/logger/) to debug.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Defining multiple shell commands
|
||||||
|
|
||||||
|
You can also define multiple shell commands at once. This is an example
|
||||||
|
that defines three different (unrelated) shell commands.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Example configuration.yaml entry
|
||||||
|
shell_command:
|
||||||
|
restart_pow: touch ~/.pow/restart.txt
|
||||||
|
call_remote: curl http://example.com/ping
|
||||||
|
my_script: bash /config/shell/script.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automation example
|
||||||
|
|
||||||
|
This is a an example of an shell command used in conjunction with an input
|
||||||
|
helper and an automation.
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Apply value of a GUI slider to the shell_command
|
# Apply value of a GUI slider to the shell_command
|
||||||
automation:
|
automation:
|
||||||
@ -55,8 +79,8 @@ input_number:
|
|||||||
max: 32
|
max: 32
|
||||||
step: 1
|
step: 1
|
||||||
|
|
||||||
{% raw %}
|
|
||||||
shell_command:
|
shell_command:
|
||||||
set_ac_to_slider: 'irsend SEND_ONCE DELONGHI AC_{{ states("input_number.ac_temperature") }}_AUTO'
|
set_ac_to_slider: 'irsend SEND_ONCE DELONGHI AC_{{ states("input_number.ac_temperature") }}_AUTO'
|
||||||
{% endraw %}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user