#shell_command is not executing when using conjunction

1 messages · Page 1 of 1 (latest)

bold heath
#

In the documentation examples declared how to use conjunction in commands, to pass data from HA to command.
https://www.home-assistant.io/integrations/shell_command/

Examples:

  • with states
> shell_command:
>   set_ac_to_slider: 'irsend SEND_ONCE DELONGHI AC_{{ states("input_number.ac_temperature") }}_AUTO'
  • with variable
> shell_command:
>   get_file_contents: "cat {{ filename }}"
> 
> - action: shell_command.get_file_contents
>         data:
>           filename: "todo.txt"

but when I try to use such sintax, it is not work. Maybe the commands is not executed at all((

I tried this options:

> shell_command:
>   test1: 'echo "test_variable=lalala" > test1.txt'
>   test2: 'echo "test_variable={{ test_variable }}" > test2.txt'
>   test3: 'echo "test_variable=${test_variable}" > test3.txt'
>   test4: 'bash -c "echo \"test_variable=${test_variable}\"" > test4.txt'
>   test5: 'echo "test_variable={{ state_attr("sensor.limassol_air_quality", "data") }}" > test5.txt'

and executing it with such script

> alias: test_script
> sequence:
>   - action: shell_command.test1
>     data:
>       test_variable: lololo
>   - action: shell_command.test2
>     data:
>       test_variable: lololo
>   - action: shell_command.test3
>     data:
>       test_variable: lololo
>   - action: shell_command.test4
>     data:
>       test_variable: lololo
>   - action: shell_command.test5
>     data:
>       test_variable: lololo

as a result I have 3 files instead of 5 with such text inside:

> test1.txt: test_variable=lalala
> test2.txt is not created
> test3.txt: test_variable=
> test4.txt: test_variable=
> test5.txt is not created

In HA.core logs of debug level there are only messages about start and end of script execution, no errors or warnings.

I do not understant what I am doing wrong, and why the 2nd and 5th commands is not executing at all, without errors or warnings.

Home Assistant

Instructions on how to integrate Shell commands into Home Assistant.

earnest grailBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.