python-samsung-smarttv-2016 icon indicating copy to clipboard operation
python-samsung-smarttv-2016 copied to clipboard

Not working with 2017er TV - connection closed

Open Cinema-HD opened this issue 7 years ago • 3 comments

Dear all,

I'm not familiar with python. I download the script and try to control my TV over command line. System is Ubuntu 16.04 LTS

If I'm running the script I get following feedback:

root@srv0007:/var/www/html# python3 sstv2016.py xx.xx.xx.xx KEY_MUTE Traceback (most recent call last): File "sstv2016.py", line 38, in remote(sys.argv[1], sys.argv[2:]) File "sstv2016.py", line 10, in remote asyncio.get_event_loop().run_until_complete(_remote(keys_list, ip_addr)) File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete return future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result raise self._exception File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step result = coro.send(None) File "sstv2016.py", line 22, in _remote message = yield from websocket.recv() File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 299, in recv raise ConnectionClosed(self.close_code, self.close_reason) websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1000, no reason. root@srv0007:/var/www/html#

Output on port 8001 from TV is following:

{ "id": "uuid:xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx", "name": "[TV] Samsung 7 Series (43)", "version": "2.1.0", "device": { "type": "Samsung SmartTV", "duid": "uuid:xxxxxx-xxxx-xxx-xxxxxx", "model": "16_JAZZM_UHD", "modelName": "UE43KS7590", "description": "Samsung DTV RCR", "networkType": "wired", "ssid": "", "ip": "xx.xxx.xxx.xxx", "firmwareVersion": "Unknown", "name": "[TV] Samsung 7 Series (43)", "id": "uuid:xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", "udn": "uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx", "resolution": "3840x2160", "countryCode": "DE", "msfVersion": "2.1.0", "smartHubAgreement": "true", "VoiceSupport": "true", "GamePadSupport": "true", "wifiMac": "40:16:3b:0e:69:06", "developerMode": "0", "developerIP": "", "OS": "Tizen" }, "type": "Samsung SmartTV", "uri": "http://xxx.xxx.xxx.xxx:8001/api/v2/", "remote": "1.0", "isSupport": "{"remote_available":"true","remote_fourDirections":"true","remote_touchPad":"true","remote_voiceControl":"true","DMP_available":"true","DMP_DRM_PLAYREADY":"false","DMP_DRM_WIDEVINE":"false","EDEN_available":"true"}" }

Please can you give me an advice, how to get the script running

Thanks a lot

Regards Cinema-HD

Cinema-HD avatar Jul 29 '17 15:07 Cinema-HD

Exact same issue here

{
	"device": {
		"FrameTVSupport": "false",
		"GamePadSupport": "true",
		"ImeSyncedSupport": "true",
		"OS": "Tizen",
		"TokenAuthSupport": "true",
		"VoiceSupport": "true",
		"countryCode": "NL",
		"description": "Samsung DTV RCR",
		"developerIP": "0.0.0.0",
		"developerMode": "0",
		"duid": "uuid:xx-xx-xx-xx-xxx",
		"firmwareVersion": "Unknown",
		"id": "uuid:8f913fc3-x-x-xx-xx",
		"ip": "x",
		"model": "17_KANTM_UHD_BASIC",
		"modelName": "UE55MU6440",
		"name": "[TV]Samsung 6",
		"networkType": "wireless",
		"resolution": "3840x2160",
		"smartHubAgreement": "true",
		"ssid": "xx",
		"type": "Samsung SmartTV",
		"udn": "uuid:x",
		"wifiMac": "7C:xx"
	},
	"id": "uuid:8f913fc3xx",
	"isSupport": "{\"DMP_DRM_PLAYREADY\":\"false\",\"DMP_DRM_WIDEVINE\":\"false\",\"DMP_available\":\"true\",\"EDEN_available\":\"true\",\"FrameTVSupport\":\"false\",\"ImeSyncedSupport\":\"true\",\"TokenAuthSupport\":\"true\",\"remote_available\":\"true\",\"remote_fourDirections\":\"true\",\"remote_touchPad\":\"true\",\"remote_voiceControl\":\"true\"}\n",
	"name": "[TV]Samsung 6",
	"remote": "1.0",
	"type": "Samsung SmartTV",
	"uri": "http://10.0.0.xx:8001/api/v2/",
	"version": "2.0.25"
}

I found this documentation: https://developer.samsung.com/tv/develop/extension-libraries/smart-view-sdk/receiver-apps/debugging

jmvermeulen avatar Nov 25 '18 13:11 jmvermeulen

Hi , i also get a connection closed with a different websocket error code 1006 `python sstv2016.py 192.168.2.100 KEY_1 KEY_0 KEY_7 KEY_ENTER Traceback (most recent call last): File "/home/omria/.local/lib64/python3.6/site-packages/websockets/protocol.py", line 674, in transfer_data message = yield from self.read_message() File "/home/omria/.local/lib64/python3.6/site-packages/websockets/protocol.py", line 742, in read_message frame = yield from self.read_data_frame(max_size=self.max_size) File "/home/omria/.local/lib64/python3.6/site-packages/websockets/protocol.py", line 821, in read_data_frame self.close_code, self.close_reason = parse_close(frame.data) File "/home/omria/.local/lib64/python3.6/site-packages/websockets/framing.py", line 268, in parse_close check_close(code) File "/home/omria/.local/lib64/python3.6/site-packages/websockets/framing.py", line 295, in check_close raise WebSocketProtocolError("Invalid status code") websockets.exceptions.WebSocketProtocolError: Invalid status code

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "sstv2016.py", line 38, in remote(sys.argv[1], sys.argv[2:]) File "sstv2016.py", line 10, in remote asyncio.get_event_loop().run_until_complete(_remote(keys_list, ip_addr)) File "/usr/lib64/python3.6/asyncio/base_events.py", line 468, in run_until_complete return future.result() File "sstv2016.py", line 22, in _remote message = yield from websocket.recv() File "/home/omria/.local/lib64/python3.6/site-packages/websockets/protocol.py", line 434, in recv yield from self.ensure_open() File "/home/omria/.local/lib64/python3.6/site-packages/websockets/protocol.py", line 658, in ensure_open ) from self.transfer_data_exc websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason `

`

device  
FrameTVSupport "false"
GamePadSupport "true"
ImeSyncedSupport "true"
OS "Tizen"
TokenAuthSupport "true"
VoiceSupport "true"
countryCode "IL"
description "Samsung DTV RCR"
developerIP "192.168.2.8"
developerMode "1"
duid "uuid:b3d516ea-a5a6-48a9-9794-2df8172809a3"
firmwareVersion "Unknown"
id "uuid:b3d516ea-a5a6-48a9-9794-2df8172809a3"
ip "192.168.2.100"
model "18_KANTM2_QTV"
modelName "QE49Q6FNA"
name "[TV] Samsung Q6 Series (49)"
networkType "wired"
resolution "3840x2160"
smartHubAgreement "true"
type "Samsung SmartTV"
udn "uuid:b3d516ea-a5a6-48a9-9794-2df8172809a3"
wifiMac "d0:03:df:71:a1:ae"
id "uuid:b3d516ea-a5a6-48a9-9794-2df8172809a3"
isSupport "{"DMP_DRM_PLAYREADY":"false","DMP_DRM_WIDEVINE":"false","DMP_available":"true","EDEN_available":"true","FrameTVSupport":"false","ImeSyncedSupport":"true","TokenAuthSupport":"true","remote_available":"true","remote_fourDirections":"true","remote_touchPad":"true","remote_voiceControl":"true"}\n"
name "[TV] Samsung Q6 Series (49)"
remote "1.0"
type "Samsung SmartTV"
uri "http://192.168.2.100:8001/api/v2/"
version "2.0.25"

` this is a qled tv if that helps Thanks

omriarieli avatar Apr 13 '19 09:04 omriarieli

I get 1002 (protocol error) on a RPi running bullseye (python3.9)

`# python3 sstv2016.py 10.0.1.155 KEY_1 KEY_0 KEY_7 KEY_ENTER sstv2016.py:13: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead def _remote(keys, tv_addr,delay=1): Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 944, in transfer_data message = await self.read_message() File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 1013, in read_message frame = await self.read_data_frame(max_size=self.max_size) File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 1095, in read_data_frame self.close_rcvd = Close.parse(frame.data) File "/usr/local/lib/python3.9/dist-packages/websockets/frames.py", line 417, in parse close.check() File "/usr/local/lib/python3.9/dist-packages/websockets/frames.py", line 441, in check raise exceptions.ProtocolError("invalid status code") websockets.exceptions.ProtocolError: invalid status code

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/lightspeed/smarthome/sstv2016.py", line 38, in remote(sys.argv[1], sys.argv[2:]) File "/lightspeed/smarthome/sstv2016.py", line 10, in remote asyncio.get_event_loop().run_until_complete(_remote(keys_list, ip_addr)) File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/lightspeed/smarthome/sstv2016.py", line 22, in _remote message = yield from websocket.recv() File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 552, in recv await self.ensure_open() File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 929, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedError: sent 1002 (protocol error); no close frame received `

jeffgoh avatar Jan 09 '22 08:01 jeffgoh