Because it would fail any time I called it as /usr/bin/nc but creating a symlink in config (/usr/share/hassio/homeassistant) and calling that works.
I clearly have some kind of permission issue with the docker container or HA, and that’s what I’m trying to solve… but root is the only user that seems to be there… I’m new to docker so that may be why I’m struggling. The docs are all over the place too… I have found 5 walkthroughs from the last year on the home assistant site of how to install supervised and all are slightly different…
I did see that raspbian is not actually approved a s a “supported” OS… maybe I will start over (again…) with true Debian10 and see if that helps… nothing that worked in the HASSOS install works here and nothing that works here works in the HASSOS install.
Sorry. I have a tendency to read diagonally when there is too much text
You can enter your container with docker exec -it homeassistant /bin/bash from the OS.
You’ll get a shell under root. HA also runs under root in the container so you’d have a smilar environment.
Now, you might be able to debug more easily your issue.
Note that you don’t have a full bash. Just busybox. So that could limit the capabilities of your scripts
Nevermind. Seems a full bash. I’m not sure wthether shell commands run under bash or plain sh though, which is busybox, not bash. That might explain…
EDIT2: Setting the HA log level to debug would show the commands stdout/stderr, according to the doc
EDIT3: Again from the doc, the proper way to execute a script would be bash /config/shell/script.sh
All good, I have a tendency to use too many words to get my point across… lol
I will try that… but I did see that the add-on web ssh terminal is busybox which is why I tested there assuming if it works in that limited environment it should within HA. Also paths and env are different there so I used that to make sure all was good. I wonder if that provides yet another env…?
Had logs at debug but didn’t get more info from the error. I love errors, they tell you exactly how to fix the issue! I would kill to get some detailed errors! Lol
As for /config/shell/script.sh Is that needed? That folder doesn’t exist, though I have a folder I put those scripts in but the name was different. Is there something that allows for permissions for a folder with that name? I saw multiple people say on threads that they must be in the main config folder so I moved them there instead of the sub folder I had within config
Oh, ok. I had them in /config/dd/ (with proper path) and they did not work so I moved them to /config/ and they didnt work. I was not sure if you were saying that /config/shell/ had special permissions within the HA environment… All my scripts have been in /config/ or a folder within.
Just connected with this technique and all scripts function properly with nc (actual /usr/bin/nc, not my symlink) OR curl OR echo to /dev/tcp/10.0.0.2/6722
They also all work from the busybox terminal in the add-on and the OS env… There are definately different permissions in the HA running environment than in any of these other three options. I also can write to files and /dev/null from any of those places but not from within HA…
Ah, not sure how you installed HA, but there is apparmor involved, which might limit what you can do under HA.
I had it disabled everywhere so cannot really help, there.
Now we are getting somewhere… lol!
I remember seeing an error or message about apparmor. I believe I was going through the info screen trying to make everything “approved” and it was not there so I added it… but now I cannot find that. I did not know what it was so I added it thinking it was required (again, never used docker before so a LOT of new things thrown at me)
Creating a basic button and setting ‘tap_action’ to toggle, I get errors of script failed for the scripts in command_on, command_off, and command_status… which are calling my commands as shown (ie: command_on: shell_command.lantern_on) but if I do ‘tap_action’ of ‘call-service’ and call service shell_command.lantern_on it works with no errors… So this issue seems to now be in the toggle functionality… How can it work when triggered by a call-service but not when triggered by a toggle?!? The toggle function updates so fast on my other install but using call-service I need two buttons and have to process the status myself which is only when that tcp sensor updates which takes forever.
Got the time down to 5-10s…
By making the call-service button entity the tcp sensor rather than the switch.
Now if I can get it to use shell commands from a script file instead of “inline” commands in the yaml I should be good! The app-armor was definitely blocking the inline scripts but I can’t make it run .sh files still.
I ran into permission problems similar to this and IIRC I had to install the community version of web terminal in order to get elevated permissions. Which version of ssh did you install, there are 2.