btw - the command_line is great alternative and can be very useful ,
But i wonder if it can support more than ON/OFF/STATE ?
like a “multi-positions” switch where each position can relate to different command_line scenario .
I believe it require command_line also support this ,
hopefully some1 from HA dev read this and like the idea:)
Sorry, I’m not an expert. I just like to share my finding…
To run shell command you should write the script
Then you can fire the script via a call on your configuration.yaml or included files.
So you might write:
shell_command:
restart_pow: touch ~/.pow/restart.txt ## or your own shell script
then on configuration just set a trigger that will call the service restart_pow. But if you try to set through the UI, you’ll find you script listed (script.restart_pow). If not you probably need to restart HA.
If i understand it correctly,
I already tried that -
adding shell_command command which fire script (locate known HA folder config/tmp,
set_mask_true: /config/mask.sh
where mask.sh contain simple touch command .
restart -> execute from UI .
It didn’t work for me (error code -11).
shell commands should work just fine without any SSH business, unless you need access to a binary that is not available in the container, or if you need access to the host.
The HA installed on QNAP docker ,
I’m connecting to QNAP using SSH and run command ,
I guess u mean to connect with HA user ?
case yes, how can i get what HA user is using for ssh session (as same using for shell_command)?
And for the Q - Can some please explain why command_line allow executing “external” commands and not shall_command?
Sorry I’m misleading. I dismiss the use of docker.
I was supposing you could handle to modify permissions to the files, which is not simple for dockers.
But the /config/ is in an open file system. So once you login via SSH, you should switch to root command line, by login command. Then you might change permission in /config. Any how better list how are the other file permission.
/config is mapped to the host. You can modify permissions on the host to match the UID/GID inside the docker container, but the entire docker instance runs as root, so you don’t have to worry about that.
It seems like there is a LOT of confusion in this thread alone. There have been some assumptions that you are using hassio, and I think there needs to be some clarification.
In the OP, you are attempting to run those commands directly inside the docker container running HA.