Extend examples on Shell Command documentation (#17493)

This commit is contained in:
Franck Nijhof 2021-04-17 12:02:11 +02:00 committed by GitHub
parent 96778b8931
commit 0de9f04589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,8 @@ Shell commands aren't allowed for a camel-case naming, please use lowercase nami
[script]: /integrations/script/
[automation]: /getting-started/automation/
## Configuration
```yaml
# Example configuration.yaml entry
# 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.
## 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
# Apply value of a GUI slider to the shell_command
automation:
@ -55,8 +79,8 @@ input_number:
max: 32
step: 1
{% raw %}
shell_command:
set_ac_to_slider: 'irsend SEND_ONCE DELONGHI AC_{{ states("input_number.ac_temperature") }}_AUTO'
{% endraw %}
```
{% endraw %}