Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run any scripts #16

Open
abtzero opened this issue May 16, 2017 · 11 comments
Open

Can't run any scripts #16

abtzero opened this issue May 16, 2017 · 11 comments

Comments

@abtzero
Copy link

abtzero commented May 16, 2017

ha-bridge 4.5.0 runs on my synology via docker.
Everything works fine, but I can't get any exec-command to work.
Most of the times I get a "file not found" error.
Tried everything I can imagine.
I get a green response in the ha-bridge interface but nothing is executed by using for example:
/usr/bin/python3 /volume1/Data/haactions/py/aquosOFF.py
The same for shell scripts.
I guess, it is a question of user-rights.
Am I right, that everything is executed by root (how can I find out?), but on the synology the user root has limited rights?
How could I get around this?

@aptalca
Copy link
Owner

aptalca commented May 16, 2017

The container only has access to locations that are mounted in the docker run command. By default, the config folder is mounted under /config

You need to use the internal maooed location of the script (and first make sure that location is mounted)

@abtzero
Copy link
Author

abtzero commented May 16, 2017

Thanks for Your response!
I added a mounted path to the existing folder /docker using the docker gui and setting the folder to /docker and mount-path to /docker (correct?).
Added a simple python script into the subfolder "py" and added the command /usr/bin/python3 /docker/py/test.py into ha-bridge.
It works manually with my user in a console but not with ha-bridge.
What else do I need to do?

@aptalca
Copy link
Owner

aptalca commented May 16, 2017

I added a mounted path to the existing folder /docker using the docker gui and setting the folder to /docker and mount-path to /docker (correct?) I don't quite understand this statement but I'm assuming that on the host, the script is at /docker/py/test.py, in the docker run command you used -v /docker:/docker:rw and in the bridge you are using the location /docker/py/test.py
If so, that seems to be correct. As to why the script isn't firing, you should ask on bwssystems' github. I don't have any experience with firing python scripts from this bridge.

@abtzero
Copy link
Author

abtzero commented May 16, 2017

Well, I do not know how to manipulate the RUN command (I do not know where to put the -v /docker:/docker:rw
I am working on the synology's gui to do that:
image
And in ha-bridge:
image
I think, it should work having access to my added directory.
Firing up a shel script with it's name does not give me an 'file not found' - error anymore.
But does not work. (my test-script should write a file to my directory.)
Can I expect having access to all system programs (i.e. bash and python modules) root would have, without mounting any additional path?

EDIT:
I got a python script working now, which writes a text-output to my directory.
My script that should turn on/off my sharp-TV is still not working (could be something with the import socket command...)
But thanks man!
You pushed me into the right direction by telling me to add a mounted path.

@aptalca
Copy link
Owner

aptalca commented May 16, 2017

Good to hear that python works. Just so you know, the script will only have access to the libraries and modules inside the container, which is ubuntu.

If you want to test/troubleshoot your python script, it is best to do inside the container so you can see the console output. You can exec into the container with docker exec -it <containername> bash from synology console.

@abtzero
Copy link
Author

abtzero commented May 16, 2017

Thanks for this hint!
When I connect as admin via SSH the command
docker exec -it aptalca-home-automation-bridge1 /bin/usr/python3 /docker/aquosON.py
gives me the response
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Wrong user?

@aptalca
Copy link
Owner

aptalca commented May 16, 2017

maybe try with sudo ?

@abtzero
Copy link
Author

abtzero commented May 16, 2017

Yes, but then it doesn't find python3.
It is not the same environment, as executed by ha-bridge.

@aptalca
Copy link
Owner

aptalca commented May 16, 2017

/usr/bin/python3

or just python3

@abtzero
Copy link
Author

abtzero commented May 16, 2017

OMG, sure ist has to be /usr/bin/
Now I have a script error output.
Thanks again!

@abtzero
Copy link
Author

abtzero commented May 16, 2017

YESSS!
For all readers in the background:
Firing up python scripts worked now, but my script, that should turn ON/OFF my Sharp Aquos TV failed with the error message:
TypeError: 'str' does not support the buffer interface
This is caused by using a socket send command like s.send(user + "\r" + password + "\r").
With python 3 this should be
s.send((user + "\r" + password + "\r").encode())
That way it works.

Buuuut:
My Sharp TV looses IP-connection after being more than 10 minutes in standby... lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants