Error when running shell command

I get this error in the log when trying to run a shell command.
Anyone knows what it indicates?

[homeassistant.components.shell_command] Error running command: bash /home/homeassistant/.homeassistant/bash_scripts/synology_poweroff.sh, return code: 6
NoneType: None

It means the shell script returned status code 6, which, of course, depends on what the script was doing.

You might want to enable debug for shell_command, which should capture the stdout & stderr in home-assistant.log:

logger:
  default: info
  logs:
    homeassistant.components.shell_command: debug
1 Like

I tried the debug and now gets this error but I don´t what to make of it.

[homeassistant.components.shell_command] Stderr of command: bash /home/homeassistant/.homeassistant/bash_scripts/synology_poweroff.sh, return code: 6:
b’Pseudo-terminal will not be allocated because stdin is not a terminal.\r\n’

Can you post the contents of /home/homeassistant/.homeassistant/bash_scripts/synology_poweroff.sh?

Yes of course.
I had it working before but after a new install of HA it stopped. Maybe I miss something after installing HA. I have installed sshpass again.
This is the content of my bash script “synology_poweroff.sh”

#! /bin/bash
sshpass -p "password" ssh -t  [email protected] "echo password | sudo -S poweroff"

I’m no expert at this, but after a quick bit of Googling I’d suggest changing -t to -T.

EDIT: Or maybe change -t to -tt.

Just tried, but unfortuneately no change.

Which did you try? -T or -tt, or both?

both… now :slight_smile:

Ok, well I don’t have any other suggestions. It appears that the command, and hence the script, is returning status code 6. And the command/script is writing that error message.

I also found this

At this point I don’t think I can help any further. Either someone else will have an idea, or maybe you can do a bit more googling and see if you can find a suggestion that applies to your situation. BTW, have you tried running that script from whatever context HA is running in (docker, whatever)?

I think I got it.
I had to ssh into the Synology from HA shell as the user “homeassistant” to make the secure fingerprint and accept the NAS as a valid host. I did that with the user “pi” before and that didn´t work
Now it runs.
Thanks for helping :slight_smile:

1 Like