Page 9 of 9

Re: Python Plugin: Samsung TV

Posted: Saturday 24 November 2018 20:54
by psychomaniac
alright, i managed to upgrade websocket, i also had to update setuptools... looks like i have to update everything, has something to do with Volumio image i guess. I also updatet websocket-client but unfortunately, that also doesn't work. It looks like this isn't the sollution, i still get the same error, see the spoiler for the output. Does anyone have an idea how to solve this one?
Spoiler: show
volumio@volumio:/$ samsungctl -i --host 192.168.0.123 --method websocket
Traceback (most recent call last):
File "/usr/local/bin/samsungctl", line 9, in <module>
load_entry_point('samsungctl==0.7.1', 'console_scripts', 'samsungctl')()
File "/usr/lib/python3.4/samsungctl/__main__.py", line 110, in main
with Remote(config) as remote:
File "/usr/lib/python3.4/samsungctl/remote.py", line 11, in __init__
self.remote = RemoteWebsocket(config)
File "/usr/lib/python3.4/samsungctl/remote_websocket.py", line 30, in __init__
self._read_response()
File "/usr/lib/python3.4/samsungctl/remote_websocket.py", line 67, in _read_response
response = self.connection.recv()
File "/usr/lib/python3.4/websocket/_core.py", line 310, in recv
opcode, data = self.recv_data()
File "/usr/lib/python3.4/websocket/_core.py", line 327, in recv_data
opcode, frame = self.recv_data_frame(control_frame)
File "/usr/lib/python3.4/websocket/_core.py", line 340, in recv_data_frame
frame = self.recv_frame()
File "/usr/lib/python3.4/websocket/_core.py", line 374, in recv_frame
return self.frame_buffer.recv_frame()
File "/usr/lib/python3.4/websocket/_abnf.py", line 383, in recv_frame
frame.validate(self.skip_utf8_validation)
File "/usr/lib/python3.4/websocket/_abnf.py", line 182, in validate
raise WebSocketProtocolException("Invalid close opcode.")
websocket._exceptions.WebSocketProtocolException: Invalid close opcode.

Re: Python Plugin: Samsung TV

Posted: Monday 26 November 2018 18:10
by psychomaniac
Meanwhile I used another Pi image, Raspbian and updated fully. But the samsungctl script still doesn't work. I still get the following:

pi@raspberrypi:/usr/local/bin $ samsungctl -i --host 192.168.0.127 --method websocket
Traceback (most recent call last):
File "/usr/local/bin/samsungctl", line 11, in <module>
sys.exit(main())
File "/usr/lib/python3.5/samsungctl/__main__.py", line 110, in main
with Remote(config) as remote:
File "/usr/lib/python3.5/samsungctl/remote.py", line 11, in __init__
self.remote = RemoteWebsocket(config)
File "/usr/lib/python3.5/samsungctl/remote_websocket.py", line 30, in __init__
self._read_response()
File "/usr/lib/python3.5/samsungctl/remote_websocket.py", line 67, in _read_response
response = self.connection.recv()
File "/home/pi/.local/lib/python3.5/site-packages/websocket/_core.py", line 310, in recv
opcode, data = self.recv_data()
File "/home/pi/.local/lib/python3.5/site-packages/websocket/_core.py", line 327, in recv_data
opcode, frame = self.recv_data_frame(control_frame)
File "/home/pi/.local/lib/python3.5/site-packages/websocket/_core.py", line 340, in recv_data_frame
frame = self.recv_frame()
File "/home/pi/.local/lib/python3.5/site-packages/websocket/_core.py", line 374, in recv_frame
return self.frame_buffer.recv_frame()
File "/home/pi/.local/lib/python3.5/site-packages/websocket/_abnf.py", line 383, in recv_frame
frame.validate(self.skip_utf8_validation)
File "/home/pi/.local/lib/python3.5/site-packages/websocket/_abnf.py", line 182, in validate
raise WebSocketProtocolException("Invalid close opcode.")
websocket._exceptions.WebSocketProtocolException: Invalid close opcode.

Does anyone know what this means? I'm don't even know what Invalid close opcode means.

Hope someone would help me with this :).

Re: Python Plugin: Samsung TV

Posted: Monday 26 November 2018 20:07
by psychomaniac
On Github there is a thread about this:

https://github.com/kdschlosser/samsungctl/issues/2

Looks like samsung did some adjustments in it's latest firmware. It uses tokens now to communicate. Couple of devs are trying to fix this in the last month.

Re: Python Plugin: Samsung TV

Posted: Friday 30 November 2018 22:45
by dextm80

Code: Select all

2018-11-30 22:36:27.244 Error: Samsung 65ks7000 hardware (4) thread seems to have ended unexpectedly
....for more and more time

anyone that get this issue?

Re: Python Plugin: Samsung TV

Posted: Saturday 15 December 2018 20:31
by kdschlosser
I am the developer working on the issue... the link that @psychomaniac posted... it is actually solved just ironing out the last bit of it. The whole samsungctl library has been worked over.

it now supports an easy to use Config class.
it also supports automatic discovery of any TV.
it supports more then one TV.
list installed applications (2016+)
start applications (2016+)(< 2014 you have to know the app id)
get the status of an application (2016+)
change the TV source (direct)(< 2014) (possibly <=2015).
change the source label(< 2014)(possibly <=2015)
get the source(< 2014)(possibly <=2015)
get the plugged state of the source(< 2014)(possibly <=2015)
change the channel (direct)(< 2014)(possibly <=2015)
get the channel(< 2014)(possibly <=2015)
get channel meta data(< 2014)(possibly <=2015)
change the channel label(< 2014)(possibly <=2015)
get the volume(all)
set the volume(all)
get mute(all)
set mute (not toggle)(all)
get the brightness(< 2014)(possibly <=2015)
set the brightness(< 2014)(possibly <=2015)
get the contrast(< 2014)(possibly <=2015)
set the contrast(< 2014)(possibly <=2015)
get the color temp(< 2014)(possibly <=2015)
set the color temp(< 2014)(possibly <=2015)
get the sharpness(< 2014)(possibly <=2015)
set the sharpness(< 2014)(possibly <=2015)
get aspect ratio(2016+)
set aspect ratio(2016+)
zoom control(2016+)
track number(all)
track duration(all)
track metadata(all)
track uri(all)
relative play time(all)
absolute play time(all)
relative play count(all)
absolute play count(all)
number of tracks(all)
media duration(all)
current uri(all)
current uri metadata(all)
next uri(all)
next uri metadata(all)
play medium(all)
record medium(all)
write status(all)
power on (2016+)
seek(all)
play speeds(all)
display onscreen messages (???)
open browser with url (< 2014) (2016+)
mouse functions moving, left click right click (2016+)

and all of the metrics you can think of.
frame TV support
TV voice recognition support
remote touch pad support
panel size
resolution
mfg year
series
panel technology (QLED, LED, Plasma, LCD, DLP, OLED)
network type
wifi mac address
operating system
mfg region
tuner count
dtv support
pvr support

and that is just to name a few.

and probably the biggest feature. it is now extremely easy to get notifications for volume changing, channel changing, source changing, power state.
almost anything listed above

the library is now python 2.7+ compatible

I am not sure what features are available for the 2014 (H) and 2015 (J) years yet. I have not had anyone test this. But the library now does support those funky AES/Rijndael encrypted websocket connections.

what I do need is some people willing to test. people that has a grasp of python and also how to provide the correct information so I can debug this thing. I only own a pre 2014 model so I am not able to test the websocket end of thing. The "legacy" works like a charm.

Re: Python Plugin: Samsung TV

Posted: Saturday 15 December 2018 20:36
by kdschlosser
opcode = Operation Code. these are codes that are used to identify the type of websocket communication that is taking place. whether it be closing the connection. or an ack packet. a ping. there is a different code for the various types of data that is being sent or received. the Samsung TV is closing the connection with an opcode that is not known to the websocket-client library. hence the error

Re: Python Plugin: Samsung TV

Posted: Saturday 15 December 2018 21:31
by dextm80
how can i update it?

Re: Python Plugin: Samsung TV

Posted: Saturday 15 December 2018 23:22
by kdschlosser
this plugin does not use the samsungctl library i do not believe. The author of the plugin would have to take a look and see what they can do with samsungctl of they wanted to have this plugin use it. if you are not familiar with python it is a little bit involved to explain it to ya.

Re: Python Plugin: Samsung TV

Posted: Monday 17 December 2018 13:24
by bimedana
Looks like websocket isn't upgraded. So i tried that but that also fails.

Re: Python Plugin: Samsung TV

Posted: Saturday 22 December 2018 16:19
by kdschlosser
ok I have a working fix for the websocket issue. If someone wants to update this plugin they can either use my code as a whole or they can take the bits a pieces to make this one work. I have not finished up with the rest of the additions just yet. I am still ironing the kinks out of it. But the websocket portion works fine


Here is is.
https://github.com/kdschlosser/samsungctl

Re: Python Plugin: Samsung TV

Posted: Saturday 22 December 2018 16:39
by zak45
kdschlosser wrote: Saturday 22 December 2018 16:19 ok I have a working fix for the websocket issue. If someone wants to update this plugin they can either use my code as a whole or they can take the bits a pieces to make this one work. I have not finished up with the rest of the additions just yet. I am still ironing the kinks out of it. But the websocket portion works fine


Here is is.
https://github.com/kdschlosser/samsungctl
Will give it a try, thanks

Re: Python Plugin: Samsung TV

Posted: Sunday 23 December 2018 9:27
by mark.sellwood
I tried this out yesterday and see the following:-
pi@SPARE-PI:~ $ samsungctl --host 192.168.1.66 --method websocket --name myremote KEY_VOLDOWN
error from callback <bound method RemoteWebsocket.on_open of <samsungctl.remote_websocket.RemoteWebsocket object at 0xb6212a10>>: on_open() missing 1 required positional argument: 'ws'
error from callback <bound method RemoteWebsocket.on_message of <samsungctl.remote_websocket.RemoteWebsocket object at 0xb6212a10>>: on_message() missing 1 required positional argument: 'message'
Traceback (most recent call last):
File "/usr/local/bin/samsungctl", line 11, in <module>
load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')()
File "/usr/local/lib/python3.4/dist-packages/samsungctl-0.8.0b0-py3.4.egg/samsungctl/__main__.py", line 181, in main
with Remote(config) as remote:
File "/usr/local/lib/python3.4/dist-packages/samsungctl-0.8.0b0-py3.4.egg/samsungctl/remote.py", line 13, in __init__
self.remote = RemoteWebsocket(config)
File "/usr/local/lib/python3.4/dist-packages/samsungctl-0.8.0b0-py3.4.egg/samsungctl/remote_websocket.py", line 50, in __init__
self.open()
File "/usr/local/lib/python3.4/dist-packages/samsungctl-0.8.0b0-py3.4.egg/samsungctl/remote_websocket.py", line 127, in open
raise RuntimeError('Connection Failure')
RuntimeError: Connection Failure

Am I missing something?

Re: Python Plugin: Samsung TV

Posted: Monday 09 December 2019 22:56
by Dim33
Hi,

Code: Select all

dd@ubuntu:~$ samsungctl -i --host 192.168.1.48
Traceback (most recent call last):
  File "/home/dd/.local/bin/samsungctl", line 10, in <module>
    sys.exit(main())
  File "/home/dd/.local/lib/python3.7/site-packages/samsungctl/__main__.py", line 102, in main
    config = _read_config()
  File "/home/dd/.local/lib/python3.7/site-packages/samsungctl/__main__.py", line 38, in _read_config
    config_file = open(path)
PermissionError: [Errno 13] Permission denied: '/home/dd/.config/samsungctl.conf'
What's the problem ?

Thanks for your help.

Re: Python Plugin: Samsung TV

Posted: Monday 06 January 2020 0:01
by Jazzle
Trying to get the kdschlosser version from Github working for months now, though am now really stuck with 2 issues at this moment.
I have installed all prerequisites correctly as it seems except for "curses".

- In the hardware tab, samsung tv still is not available, no clue how to get this there

- when trying to connect to the tv first time, by sending the command samsungctl --host 192.168.1.100 --config-file "/PATH/FILE.NAME" KEY_MENU
do i refer to the samsungctl.conf file? as i read it this is not necessary though.
I have tried both options but get the notification " unrecognized arguments"
What am i doing wrong?

Re: Python Plugin: Samsung TV

Posted: Friday 24 January 2020 9:36
by erasor2010
Hi,

i have a problem with the samsung plugin, it cant be loaded by domoticz

Code: Select all

2020-01-24 09:14:51.832 Error: (SamsungTV) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/SamsungTV/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2020-01-24 09:14:51.832 Error: (TV-Bad) Module Import failed, exception: 'ModuleNotFoundError'
2020-01-24 09:14:51.832 Error: (TV-Bad) Module Import failed: ' Name: samsungctl'
2020-01-24 09:14:51.832 Error: (TV-Bad) Error Line details not available
python 3.7 is my standard version

Code: Select all

python --version
Python 3.7.3
i can use the samsungctl on command line with

Code: Select all

samsungctl -i --host xx.xx.xx.xx
can someone help me

Samsung UE55MU6102 doesn't work :-(

Posted: Wednesday 19 February 2020 7:10
by radzik
Hello,

My configuration is Windows 10, 64-bit and tv Samsung model UE55MU6102 .

All logs are clear. All components including samsungctl (samsungctl 0.8.0b) and websocket-client correctly installed.

Unfortunately, after a few hours of struggle I gave up, none of the commands work and no message is displayed on TV :-(

Help please!

I'm trying to send different commands to the TV, but nothing happens :-( just a message:
For command:
samsungctl --method legacy --host 192.168.1.2 --port 8001 -v KEY_MUTE

Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\samsungctl-0.8.0b0-py3.8.egg\samsungctl\remote_legacy.py", line 76, in open
self.sock.connect((self.config.host, self.config.port))
ConnectionRefusedError: [WinError 10061] Nie można nawiązać połączenia, ponieważ komputer docelowy aktywnie go odmawia

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\Scripts\samsungctl-script.py", line 11, in <module>
load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\samsungctl-0.8.0b0-py3.8.egg\samsungctl\__main__.py", line 355, in main
with Remote(config) as remote:
File "C:\Program Files (x86)\Python38-32\lib\site-packages\samsungctl-0.8.0b0-py3.8.egg\samsungctl\remote.py", line 67, in __enter__
self.open()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\samsungctl-0.8.0b0-py3.8.egg\samsungctl\utils.py", line 24, in wrapper
return func(*args, **kwargs)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\samsungctl-0.8.0b0-py3.8.egg\samsungctl\remote_legacy.py", line 79, in open
raise RuntimeError('Unable to pair with TV.. Is the TV on?!?')
RuntimeError: Unable to pair with TV.. Is the TV on?!?


in this way:
samsungctl --method websocket --host 192.168.1.2 --port 8001 -v KEY_MUTE

command line doesn't respond and freezing :-(

Somebody can help me.

Thank you in advance.

Re: Python Plugin: Samsung TV

Posted: Saturday 25 April 2020 11:10
by kniazio
Pawcio wrote: Saturday 03 November 2018 23:10 Ok,
it means that samsung has slightly different protocol on different TV models which are communicating over ws.
Version from the Oct 31, waits for the ""ms.channel.connect" json response before keys processing (it wasn't present in the previous one).
Mark, could you turn on debugs and sends me logs? I'll check whats going on.

In the mean time please find the first plugin version with power off functionality added.
I hope it will work this time for you.
After installing your plugin, only two input and power on devices added to me
I can turn on the TV when it is turned off by the remote control but I can't turn it off. The Input button does not work at all