Hi !
I want execute a shell command wth 2 paramaters, I don’t know how
command I want to send
echo -e -n "So,num,cmd\n" > verif.txt
where num and cmd are parameters
I tried diffrent syntax like this
send_so: "echo -e -n 'So\,"{{num}}"\,"{{cmd}}"\n' > verif.txt"
and the script who call this
service: shell_command.send_somfy
data_template:
num: 1
cmd: D
Is it possible ?
Thank’s
1 Like
rccoleman
(Rob Coleman)
May 20, 2023, 11:46pm
2
I find that writing and calling a shell script is best to avoid issues.
myscript
:
#!/bin/bash
echo -e -n "So,$1,$2\n" > /config/verif.txt
configuration.yaml
:
shell_command:
test_params: /config/myscript {{num}} {{cmd}}
scripts.yaml
:
test_param:
sequence:
- service: shell_command.test_params
data:
num: 1
cmd: 2
Call the service:
service: script.test_param
Output:
rcoleman@rcoleman-linux ...docker/ha/config % cat verif.txt
So,1,2
BTW, data_template:
was deprecated many years ago.
Thank @rccoleman for your fast answer
I create a file inside the config dir with name myscript and copied the bash
I copied your shell-command in configuration.yaml
I copied test param at the end of script.yaml
I restarted HA
When I call the service script.test_param in developer tools
I receive the message : failled to call service script.test_param. Unknow error Failled to call service
rccoleman
(Rob Coleman)
May 21, 2023, 12:50am
5
You’ll need to review the HA logs. One possibility is that you didn’t make the script executable.
that was it! thank you so much
1 Like