sermayoral / ha-samsungtv-encrypted

Samsung TV Encrypted Models (H & J Series) custom component for Home Assistant
Apache License 2.0
39 stars 24 forks source link

Get token UE40J5200AKXZT #21

Open dariob84 opened 4 years ago

dariob84 commented 4 years ago

Good morning, i tried to take token for my tv (UE40J5200AKXZT) but i recived this:

C:\temp\samsungtv_encrypted>python get_token.py --ip 192.168.1.31 --port 8080 Traceback (most recent call last): File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 156, in _new_conn conn = connection.create_connection( File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection raise err File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request conn.request(method, url, **httplib_request_kw) File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1230, in request self._send_request(method, url, body, headers, encode_chunked) File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1276, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1225, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1004, in _send_output self.send(msg) File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 944, in send self.connect() File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 184, in connect conn = self._new_conn() File "C:\Users\dbarb\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 168, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000257CA59CD00>: Failed to establish a new connection: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione

can anyone tell me what am i doing wrong?

Thanks

AKuHAK commented 2 years ago

@epenet I don't quite remember, but probably I just did 2 pairings in a row.

I recommend for proper debugging install root on your testing device: H-J series Some useful commands:

curl -X GET -i http://192.168.1.184:8001/ms/1.0/
will show some ports and info
curl -X GET -i http://192.168.1.184:8001/ws/apps/
will show device capabilities
curl -X GET -i http://192.168.1.184:8001/api/v2/
will show firmware version capabilities
curl -X GET -i http://192.168.1.184:8000
will return "Server is running..."
curl -X GET -i http://192.168.1.184:8000/socket.io/1
if return token, that means that pin is supported
curl -X GET -i http://192.168.1.184:8080/ws/pairing\?step\=$\{step\}\&app_id\=$\{this._config.appId\}\&device_id\=$\{this._config.deviceId\}
PIN code test
curl -X GET -i http://192.168.1.184:8080/ws/apps/YouTube
curl -X GET -i http://192.168.1.184:8001/ws/apps/YouTube
will show info about youtube application, commands the same but from different port
curl -X POST -i http://192.168.1.184:8001/ws/apps/YouTube
will open YouTube application
only works with 8001 port, with 8080 port need Content-Length
curl -X DELETE -i http://192.168.1.184:8001/ws/apps/YouTube/run
curl -X DELETE -i http://192.168.1.184:8080/ws/apps/YouTube/run
will close YouTube application, works with both ports
curl -X GET -i http://192.168.1.184:8080/ws/apps/YouTube/install
the command for opening smarthub page with installation, only 8080 port, and only whitelisted apps will work

curl -X POST -i http://192.168.1.184:8001/api/v2/applications/111299001912
will open YouTube application through more modern api and port 8001
curl -X PUT -i http://192.168.1.184:8001/api/v2/applications/111299001912
will show some wrong information about YouTube application

curl -X POST -i http://192.168.1.184:8001/ws/apps/CloudPINPage
another pin code, purpose unknown
curl -X DELETE -i http://192.168.1.184:8001/ws/apps/CloudPINPage/run 
close pin code

curl -X POST -i http://192.168.1.184:8001/ws/apps/WebBrowser
open web browser
curl -X POST -i http://192.168.1.184:8001/api/v2/applications/101400000099
curl -X POST -i http://192.168.1.184:8001/ws/apps/SSO
works (select user) SSO
curl -X POST -i http://192.168.1.184:8001/api/v2/applications/111199001564
curl -X POST -i http://192.168.1.184:8001/ws/apps/AdHub
works (AdHub)
curl -X POST -i http://192.168.1.184:8001/api/v2/applications/11101200001
curl -X POST -i http://192.168.1.184:8001/ws/apps/Netflix
works (Netflix)
curl -X POST -i http://192.168.1.184:8001/api/v2/applications/20142100003
curl -X POST -i http://192.168.1.184:8001/ws/apps/emanual
works
curl -X POST -i http://192.168.1.184:8001/api/v2/pincode
curl -X DELETE -i http://192.168.1.184:8001/api/v2/pincode
works pin is shown

curl -X POST -i http://192.168.1.184:8001/ms/1.0/device/info/update
reet network settings

Next just should be open in web browser
http://192.168.1.184:8001/captcha.png
http://192.168.1.184:8001/resources/webapplauncher/
epenet commented 2 years ago

I don't actually have a H-J model to test with, so I am relying on other users to test it !

If what you say is correct, then maybe we need to adjust the config-flow in async_step_reauth_confirm_encrypted to ask the user "Session-id is 1, which is known to expire under certain circumstances. Would you like to run the pairing again?"

https://github.com/home-assistant/core/blob/248f01f41f58682abc75a26f8ae16bd1516fba97/homeassistant/components/samsungtv/config_flow.py#L580