nitinuae
(Nitinuae)
February 12, 2024, 5:43am
1
Hello
Need help in shell commnds.
Here is the config -
in configuration.yaml, I have included
shell_command: !include shell_commands.yaml
The shell_commands.yaml consist of
inc_gardenroom_vol: echo -e “inc fader /“GardenRoom/” 1/n” | nc 192.168.39.197 52774
Now, when I call service shell_command.inc_gardenroom_vol, nothing happens. I cannot see anything in logs also.
The above command(echo -e “inc fader /“GardenRoom/” 1/n” | nc 192.168.39.197 52774 ) works if invoked from terminal(using addon ssh terminal)
What am I doing wrong?
nitinuae
(Nitinuae)
February 12, 2024, 8:21am
3
Yes - thats how I tested (I wrote above- tested in terminal - using addon ssh terminal)
The command works in ssh terminal.
When called using run script- the trace says ok, but command is not sent. Its like a blackhole- with no way to debug (i did enamle debug for shell commnd - still there is nothing in the log)
Summarizing -
configuration.yaml contains-
shell_command: !include shell_commands.yaml
shell_commands.yaml contains -
inc_gardenroom_vol: echo -e “inc fader /“GardenRoom/” 1/n” | nc 192.168.39.197 52774
scripts.yaml contains-
gardenroom_increase_volume:
alias: GardenRoom Increase Volume
sequence:
- service: shell_command.inc_gardenroom_vol
data: {}
mode: single
If I call this service using developer tools, returncode is 0, that means its being executed without error. But the command is going to blackhole
_dev_null
(/dev /null)
February 12, 2024, 1:06pm
4
Are you escaping correctly ?
Shouldn’t it be something like this ?
echo -e "inc fader \"GardenRoom\" 1\n" | nc 192.168.39.197 52774
Trying it directly in HA seems to output correctly
root@svr1:~# podman exec -it homeassistant bash
svr1:/config# echo -e "inc fader \"GardenRoom\" 1\n" | nc 192.168.39.197 52774
^Cpunt!
svr1:/config# echo -e "inc fader \"GardenRoom\" 1\n" | nc 10.0.0.6 52774
svr1:/config# echo -e "inc fader \"GardenRoom\" 1\n"
inc fader "GardenRoom" 1
Edit: yup just checked my configuration.yaml for the way I escape chars and can confirm black slashes being used
eg
turn_off_ryzen: "ssh -i /config/.ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] \"net rpc shutdown -f -t 0 -C shuttingdown -U ............\" "
nitinuae
(Nitinuae)
February 12, 2024, 1:51pm
5
Sorry - my bad - As file editor doesnot allow cut paste - I wrote on this forum (and miswrote)
This works -
This doesnot work
nitinuae
(Nitinuae)
February 12, 2024, 1:56pm
6
Oh wait - Restarting the ha worked !!!
Reloading yaml didnot.
Solved!!!