kdschlosser / samsungctl

Remote control Samsung televisions via a TCP/IP connection
MIT License
148 stars 34 forks source link

Pair request over and over and permission denied in terminal #128

Open zaileion opened 4 years ago

zaileion commented 4 years ago

So I'm new to samsungctl, just started using it last night... Its been an effort but now the TV is responding and asking me to allow, deny the device meaning my laptop. the problem is I get a permission denied and when I run the command again it simply re-asks me to allow/deny it again followed by command Traceback to permission denied again. Samsung Model QN65Q9FNA

I guess I should point out if I just use the code from this site it doesn't work, it simply hangs and I have to ctrl+z to get it to quit. No request for pairing on the TV.

I used this link https://github.com/eclair4151/samsungctl/tree/websocketssl and ran the setup.py and it gives me a pair request, but like i said i get a permission denied on the traceback and when i resend the code it asks to pair again followed by the traceback permission denied. does this over and over.

Here is the output any help would be appreciated $ samsungctl --host 192.168.1.27 --port 8002 --method websocket KEY_POWEROFF { "data": { "token": "81994378", "clients": [ { "isHost": false, "attributes": { "name": "c2Ftc3VuZ2N0bA==" }, "id": "40876f0-826a-4c27-acb4-649ef4d8d6d", "connectTime": 1572803997333, "deviceName": "c2Ftc3VuZ2N0bA==" } ], "id": "40876f0-826a-4c27-acb4-649ef4d8d6d" }, "event": "ms.channel.connect" } Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.7.1+1', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/main.py", line 110, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/remote.py", line 11, in init self.remote = RemoteWebsocket(config) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/remote_websocket.py", line 55, in init self._read_response() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/remote_websocket.py", line 100, in _read_response with open(self.token_file, "w") as token_file: IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/token.txt'

OK. So i had to sudo the command and it worked once. It looks like i need to install samsungctl in my home folder but don't know how to do that since i just ram the command sudo python setup.py install as the instructions say.

But the command fired and the volume went down but it didnt drop me back to the terminal prompt i had to ctrl+z to get it to exit back to the terminal prompt but now i have this issue. When i try to run the command again I get the following output and the command does not fire.

Output: sudo samsungctl --host 192.168.1.27 --port 8002 --method websocket KEY_VOLDOWN Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in <module> load_entry_point('samsungctl==0.7.1+1', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/__main__.py", line 110, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/remote.py", line 11, in __init__ self.remote = RemoteWebsocket(config) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.7.1+1-py2.7.egg/samsungctl/remote_websocket.py", line 46, in __init__ sslopt={"cert_reqs": ssl.CERT_NONE}) File "/home/zaileion/.local/lib/python2.7/site-packages/websocket/_core.py", line 514, in create_connection websock.connect(url, **options) File "/home/zaileion/.local/lib/python2.7/site-packages/websocket/_core.py", line 223, in connect options.pop('socket', None)) File "/home/zaileion/.local/lib/python2.7/site-packages/websocket/_http.py", line 120, in connect sock = _open_socket(addrinfo_list, options.sockopt, options.timeout) File "/home/zaileion/.local/lib/python2.7/site-packages/websocket/_http.py", line 189, in _open_socket raise error socket.error: [Errno 115] Operation now in progress

How do i run the setup.py file with Python3 and install it in a directory where I don't need to sudo the samsungctl command? i assume i have to redirect the install to somewhere in my home directory but I am unaware of the command.

Further EDITS: So I installed this https://github.com/kdschlosser/samsungctl by downloading the zip, extracting it and running the command python setup.py install --user

Then

I i installed this https://github.com/eclair4151/samsungctl/tree/websocketssl by running the command pythin setup.py install --user BUT FIRST you have to set permissions for all the root owned files within the timeout fix. I did that by using chown <your username> -R *.* you will get some permission erorrs in the dist and build directories you just chown them to your username also and it will fix the issues.

Here is a copy/paste of my commands history for setting permissions for the timeout fix. They arent perfect but they worked.. Don't forget to switch "zaileion" with your user name. 781 chown -R zaileion . 782 sudo chown -R zaileion . 783 python setup.py install --user 784 sudo chown -R 777 . 785 python setup.py install --user 786 sudo chown zaileion -R 777 . 787 sudo chown zaileion -R . 788 python setup.py install --user 789 sudo chown zaileion -r . 790 cd fix 791 cd build 792 ls 793 chown -R zaileion . 794 sudo chown -R zaileion . 795 cd lib 796 sudo chown -R zaileion . 797 ls 798 cd .. 799 sudo chown -R zaileion lib 800 python setup.py install --user 801 cd .. 802 python setup.py install --user 803 cd dist 804 sudo chown -R zaileion *.egg 805 cd .. 806 python setup.py install --user

once you have a successful install of both using the python setup.py install --user then run amsungctl --host 192.168.1.27 --port 8002 --method websocket --timeout 10 KEY_VOLUP using whatever key you want then it will work. you will still need to ctrl+c to drop back to the command prompt but then you will be able to run additional commands...

This will prob work for all newer TV's like Q8 and Q7 also

Ill keep working on it but i have no idea how to write code... Hopefully OP will be back soon and fix'er up for us laymen.

I will quote reply some of the other posts on here and reply to them so users get notifications (if its like other message boards). This is a dirty work around but it gets it working at least...