sermayoral / ha-samsungtv-encrypted Goto Github PK
View Code? Open in Web Editor NEWThis project forked from arturleao/samsungtv_custom
Samsung TV Encrypted Models (H & J Series) custom component for Home Assistant
License: Apache License 2.0
This project forked from arturleao/samsungtv_custom
Samsung TV Encrypted Models (H & J Series) custom component for Home Assistant
License: Apache License 2.0
running get-token.py gives following error:
root@hassio:/# ./usr/share/hassio/homeassistant/custom_components/samsungtv_encrypted/get_token.py
./usr/share/hassio/homeassistant/custom_components/samsungtv_encrypted/get_token.py: line 1: import: command not found
from: can't read /var/mail/PySmartCrypto.pysmartcrypto
./usr/share/hassio/homeassistant/custom_components/samsungtv_encrypted/get_token.py: line 5: syntax error near unexpected token (' ./usr/share/hassio/homeassistant/custom_components/samsungtv_encrypted/get_token.py: line 5:
def main(argv):'
Hassio is running on lxc container within portainer.
what doe i need to change or do i something wrong?
Hi! I try to use your integration, but when I run the get_token.py I get the following error:
Traceback (most recent call last): File "get_token.py", line 3, in <module> from PySmartCrypto.pysmartcrypto import PySmartCrypto File "C:\samsungtv_encrypted\PySmartCrypto\pysmartcrypto.py", line 2, in <module> from . import crypto File "C:\samsungtv_encrypted\PySmartCrypto\crypto.py", line 2, in <module> from Crypto.Cipher import AES ImportError: No module named Crypto.Cipher
What I am doing wrong?
I was previously able to turn off and turn on the TV using HDMI-CEC branch. Since the latest update, turn off is not working.
turn_on_action does not seem to work with the command turn on 0
as described in the readme.
I am able to turn on the TV using the command activate
, as below
entity_id: media_player.kodi
method: Addons.ExecuteAddon
addonid: script.json-cec
params:
command: activate
but this switches the source to the raspberry pi with kodi running.
How do i turn on the TV without changing the source and how do i get the turn off working again?
thanks
In version 2.1 the select source is no longer visible on the media player entity and using the select_source service call no longer works either.
Version 1.0 allowed me to see the select source drop down and select between TV and HDMI. Any reason this is no longer available? Happy to help out. Cheers
Use get_token.py to get your Samsung TV token (use --port 8080). Store TOKEN (CTX) and SESSION_ID output. Your TV must be turned on and connected to Internet with the specific IP. Terminal where you have executed get_token.py will ask for a PIN, that will be showed in your TV screen.
sorry,
im on hassio, how can use get_token.py?
thankyou
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
Looks like i cannot get token from mine TV UE58H5203 (btw usually the TV just show a pop-up to accept the new device, not a pin, and i never found an app that allow remote control, but i can do some actions like share youtube videos from the phone, or send content via DLNA streming)
python3 get_token.py -ip 192.168.144.21 -port 8080
Traceback (most recent call last):
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 61, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 752, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1252, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1298, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
conn = self._new_conn()
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10e89cb50>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='p', port=8000): Max retries exceeded with url: /socket.io/1/?t=1593430870908 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10e89cb50>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "get_token.py", line 27, in <module>
main(sys.argv[1:])
File "get_token.py", line 24, in main
PySmartCrypto(ip, port)
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 123, in __init__
self._connection = self.connect()
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 95, in connect
websocket_response = requests.get(step4_url)
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/Users/francyesco/Downloads/ha-samsungtv-encrypted-master/custom_components/samsungtv_encrypted/venv/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='p', port=8000): Max retries exceeded with url: /socket.io/1/?t=1593430870908 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10e89cb50>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
Hi,
My config:
- platform: samsungtv_encrypted
host: 192.168.xxx.yyy
token: "42711b38ae1045b45xxxxyyyyzzzz"
sessionid: 1
port: 8080
name: Samsung UE55H6200
mac: "c4:57:6e:xx:xx:xx"
I use "Check Home Assistant configuration" to check my config and I get this error:
INFO:homeassistant.util.package:Attempting install of PyNaCl==1.3.0
INFO:homeassistant.util.package:Attempting install of proxmoxer==1.0.4
INFO:homeassistant.util.package:Attempting install of mutagen==1.43.0
INFO:homeassistant.util.package:Attempting install of gTTS-token==1.1.3
INFO:homeassistant.util.package:Attempting install of homeassistant-pyozw==0.1.10
INFO:homeassistant.util.package:Attempting install of life360==4.1.1
INFO:homeassistant.util.package:Attempting install of pynuki==1.3.3
Failed config
General Errors:
- Platform error media_player.samsungtv_encrypted - No module named 'Crypto'
Successful config (partial)
s6-svscanctl: fatal: unable to control /var/run/s6/services: supervisor not listening
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
How do ask Hassio to install this package when we install this integration?
My problem looks like this issue: #11 .
Thanks.
The component does not work anymore and I am getting the following error in HA.
Source: util/async_.py:120
First occurred: 5:50:20 PM (1 occurrences)
Last logged: 5:50:20 PM
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for samsungtv_encrypted doing I/O at custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py, line 95: websocket_response = requests.get(step4_url)
@sermayoral: changing over to a separate issue thread.
thanks again for the cool implementation and work you've done.
I'm on version 2.5 of your plugin.
I've collected similiar files, as others and uploaded them here for you:
ip:9197/ConnectionManager_1.xml: https://pastebin.com/vwd7CjB0
ip::9197/RenderingControl_1.xml: https://pastebin.com/FE3LLmYF
home-assitant.log: https://pastebin.com/dM1jrh7Z
As you outlined, I've tried KEY_POWER, but it does not work,.
My current config looks as follows:
media_player:
if you need anything else, I'm happy to help you.
Many thanks.
Getting the following problem:
.homeassistant/custom_components/samsungtv_encrypted$ python ./get_token.py -ip 10.7.7.58 -port 8080 Traceback (most recent call last): File "./get_token.py", line 3, in <module> from PySmartCrypto.pysmartcrypto import PySmartCrypto File "/home/homeassistant/.homeassistant/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 2, in <module> from . import crypto File "/home/homeassistant/.homeassistant/custom_components/samsungtv_encrypted/PySmartCrypto/crypto.py", line 2, in <module> from Crypto.Cipher import AES ImportError: No module named Crypto.Cipher
Just wanted to share the following HA warning, It likely happened right after I adjusted the volume.
Logger: homeassistant.util.async_
Source: util/async_.py:105
First occurred: 5:58:10 PM (1 occurrences)
Last logged: 5:58:10 PM
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for samsungtv_encrypted doing I/O at custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py, line 95: websocket_response = requests.get(step4_url)
Config;
Samsung UE50HU6900
HA: 0.117.5
After I could finally integrate my Samsung UE40J6350 into hass.io I noticed the following problem:
When I opened the UserGuide or the menu on the TV it was closed again shortly after.
I found out that it occurs every time the volume is checked:
2020-03-19 10:03:05 INFO (SyncWorker_6) [custom_components.samsungtv_encrypted.media_player] Samsung TV sending: POST /smp_17_ HTTP/1.0
HOST: 192.168.2.25:7676
CONTENT-TYPE: text/xml;charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
0Master
2020-03-19 10:03:16 INFO (SyncWorker_0) [custom_components.samsungtv_encrypted.media_player] Samsung TV sending: POST /smp_17_ HTTP/1.0
HOST: 192.168.2.25:7676
CONTENT-TYPE: text/xml;charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
0Master
2020-03-19 10:03:27 INFO (SyncWorker_13) [custom_components.samsungtv_encrypted.media_player] Samsung TV sending: POST /smp_17_ HTTP/1.0
HOST: 192.168.2.25:7676
CONTENT-TYPE: text/xml;charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
0Master
Thanks for the awesome work.
Could you add an explanation when to use which version?
In my case - I have my TV connected to a reciever which the HomeAssistant (on RaspberryPi) is connected to, and a streamer and other media players.
Which should I use?
I think it's also better to have this explanation in Readme.md
to avoid ambiguity in this regard
Thanks
I tried the command from Ubuntu and FreeBSD: python3 get_token.py --ip 192.168.3.23 --port 8080
but in both cases I get this error:
Traceback (most recent call last):
File "get_token.py", line 3, in
from PySmartCrypto.pysmartcrypto import PySmartCrypto
File "/home/jlgalindo/Documents/samsung/ha-samsungtv-encrypted/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 2, in
from . import crypto
File "/home/jlgalindo/Documents/samsung/ha-samsungtv-encrypted/custom_components/samsungtv_encrypted/PySmartCrypto/crypto.py", line 2, in
from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
when I click to turn off the tv the following error appears,
Has anyone ever experienced this?
thank you.
Logger: homeassistant.components.websocket_api.http.connection.140102350376592
Source: custom_components/samsungtv_encrypted/PySmartCrypto/command_encryption.py:24
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 21:06:20 (2 occurrences)
Last logged: 21:06:25
Odd-length string
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1253, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1288, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
self._platforms.values(), func, call, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 454, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 597, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 485, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 530, in async_turn_off
await self.hass.async_add_job(self.turn_off)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/samsungtv_encrypted/media_player.py", line 401, in turn_off
self.get_remote().close()
File "/config/custom_components/samsungtv_encrypted/media_player.py", line 225, in get_remote
self._remote = self._remote_class(self._host, self._port, self._token, self._sessionid)
File "/config/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 153, in init
self._aesLib = AESCipher(self._token.upper(), self._sessionid)
File "/config/custom_components/samsungtv_encrypted/PySmartCrypto/command_encryption.py", line 24, in init
self.key = binascii.unhexlify(key)
binascii.Error: Odd-length string
#5 is unresolved.
Unable to use a HassOS terminal to run get_token.py due to compatibility issues on the latest HassOS builds.
Below is the error shown when get_token.py imports pycryptodome.
Python: 3.8
HomeAssistant: 0.107.1
HassOS: 3.12
manifest.json should list all dependencies (including pycryptodome, requests, websockets, etc). This should resolve the issue?
Using Home Assistant OS (HassOS 4.13).
Command 'python3 get_token.py --ip 192.168.x.xxx --port 8080' gives an error: no module named crypto. Uninstall and install (pip install crypto) doesn't solve the problem. Also tried to install pycrypto and pycryptodome instead, but both give an install error (found this possible solution on other topics).
Any suggestions?
Trying to connect to a 2015 Samsung JU6400 series.
Iβve been suffering for 3 weeks! Help me please!
Oh my god, Author, make normal use instructions. Here, not all people are python masters.The author sends me this link, but this does not work. It does not even indicate that you need to install additional modules.
I figured out how to do this myself, but still get_token.py does not work for me.
C:\Windows\system32>cd C:\ha-samsungtv-encrypted-master\custom_components\samsungtv_encrypted
C:\ha-samsungtv-encrypted-master\custom_components\samsungtv_encrypted>get_token.py --ip 192.168.100.2 --port 8080
Traceback (most recent call last):
File "C:\ha-samsungtv-encrypted-master\custom_components\samsungtv_encrypted\get_token.py", line 3, in <module>
from PySmartCrypto.pysmartcrypto import PySmartCrypto
File "C:\Users\Professional\Desktop\ha-samsungtv-encrypted-master\custom_components\samsungtv_encrypted\PySmartCrypto\pysmartcrypto.py", line 2, in <module>
File "C:\Users\Professional\Desktop\ha-samsungtv-encrypted-master\custom_components\samsungtv_encrypted\PySmartCrypto\crypto.py", line 2, in <module>
ImportError: No module named Crypto.Cipher
Hi @sermayoral,
I'm trying to connect a UE32J5200 TV with this integration. Unfortunately I'm stuck at the token retrieval.
Running get_token.py --ip <myip> --port 8080
results in a connection refused
error.
I found that the procedure defined in connect()
method of the PySmartCrypto
library is using the hardcoded port 8000
, so that the port supplied via cli argument is not considered in the pairing section.
This issue has been addressed in #61, but I still can't connect to my device.
Running get_token.py --ip <myip> --port 8080
on the PR #61 results in a different error:
Traceback (most recent call last):
File "get_token.py", line 40, in <module>
main(sys.argv[1:])
File "get_token.py", line 36, in main
PySmartCrypto(ip, port)
File "[omitted]/ha-samsungtv-encrypted/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 123, in __init__
self._connection = self.connect()
File "[omitted]/ha-samsungtv-encrypted/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 99, in connect
connection = websocket.create_connection(websocket_url)
File "[omitted]/lib/python3.6/site-packages/websocket/_core.py", line 515, in create_connection
websock.connect(url, **options)
File "[omitted]/lib/python3.6/site-packages/websocket/_core.py", line 226, in connect
self.handshake_response = handshake(self.sock, *addrs, **options)
File "[omitted]/lib/python3.6/site-packages/websocket/_handshake.py", line 80, in handshake
status, resp = _get_resp_headers(sock)
File "[omitted]/lib/python3.6/site-packages/websocket/_handshake.py", line 165, in _get_resp_headers
raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
websocket._exceptions.WebSocketBadStatusException: Handshake status 400 Bad Request
I tried to debug the issue by myself without success, but I discovered that the value of websocket_response
after its initialization is <Response [403]>
, while the value of websocket_url
after its initialization is
ws://<myip>:8080/socket.io/1/websocket/<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http
which I think it's not what it should be.
So the problem seems to be with the first request receiving a Forbidden
response at line 95.
I'd be glad to help you solving this issue. ππ»
Is there a way to specify and name active sources which can be toggled via dropdown?
Dear @sermayoral
thanks for the Implementation!
I set up an connection to my UE40JU6050 using your custom component. For HA I use the docker based solution. Therefore my only working action was to start the script inside the docker container:
docker -it homeassistant /bin/bash
Navigated to the script:
cd /config/custom_components/samsungtv_encrypted
Then I have started the script (two times):
Note: -ip -port doesn't work for me
python3 get_token.py --ip xx.xx.xx.xx --port 8080
Run a second time to get the message on the display:
python3 get_token.py --ip xx.xx.xx.xx --port 8080
Entered the PIN in less then a minute!
Got the token (ctx) and session id
Configured HA media_player - success
my samsung is ue48ju7500 but i but i can't control the tv. the state is idle
media_player.tv_ue48ju7500 | idle | is_volume_muted: true media_duration: 0 friendly_name: [TV] UE48JU7500 supported_features: 21055 |
---|
and does not respond to
"entity_id": "media_player.tv_ue48ju7500",
"media_content_type": "send_key",
"media_content_id": "KEY_CH_LIST"
error:
14/11/2020, 02:43:59node: media_player.tv_ue48ju7500
msg : string[526]
"Call-service API error. Error Message: Error during async_call(), status: 500, body: <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault>s:ClientUPnPError716Resource not found</s:Fault></s:Body></s:Envelope>"
I'm seeing in the log ALOT of lines such as:
2020-03-18 14:02:25 INFO (SyncWorker_3) [custom_components.samsungtv_encrypted.media_player] Samsung TV sending: POST /smp_17_ HTTP/1.0
HOST: 1.1.1.1:7676
CONTENT-TYPE: text/xml;charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope>
2020-03-18 14:02:26 INFO (SyncWorker_3) [custom_components.samsungtv_encrypted.media_player] Samsung TV received: b'HTTP/1.1 200 OK\r\nContent-Length: 334\r\nContent-Type: text/xml; charset="utf-8"\r\nDATE: Thu, 01 Jan 1970 00:04:37 GMT\r\nEXT:\r\nSERVER: UPnP/1.0\r\nConnection: close\r\n\r\n<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\r\n<s:Body>\r\n<u:GetVolumeResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><CurrentVolume>13</CurrentVolume></u:GetVolumeResponse>\r\n</s:Body>\r\n</s:Envelope>'
Can this be moved to debug - and maybe only show if there's a problem?
I'm trying to get token but i have:
python3 get_token.py --ip 192.168.1.101 --port 8080
Traceback (most recent call last):
File "get_token.py", line 27, in
main(sys.argv[1:])
File "get_token.py", line 24, in main
PySmartCrypto(ip, port)
File "/home/gianni/Scrivania/samsung/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 123, in init
self._connection = self.connect()
File "/home/gianni/Scrivania/samsung/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 99, in connect
connection = websocket.create_connection(websocket_url)
AttributeError: module 'websocket' has no attribute 'create_connection'
In my 55HU7500, mute, vol+/- don't work. Volume bar, and Source select works ok.
Power off is not working too. I pulse it and status change to off but tv is on.
In few seconds the plugins detect that is on and returns status to on.
So I am able to start the get_token.py and I am asked for PIN, which is shown on my TV screen (Samsung UE43J5550).
Result is that I get is :
dest_hash: got it
SKPrime: got it
SKPrimeHash: got it
ctx: got it
But, I do not get the session ID. I get the message:
Unable to get session_id and/or ClientAckMsg!!!
After the installation of 109.x dev and 110 dev I got an deprecation notice:
WARNING (MainThread) [homeassistant.components.media_player] MediaPlayerDevice is deprecated, modify SamsungTVDevice to extend MediaPlayerEntity
I think this was adapted for the original integration in home-assistant/core#34592
Could you please change "MediaPlayerDevice" into "MediaPlayerEntity" in media_player.py?
I lost my media_player entities after updating Home Assistant to 0.115.
Here's the log:
Logger: homeassistant.components.media_player
Source: custom_components/samsungtv_encrypted/media_player.py:129
Integration: Media player (documentation, issues)
First occurred: 8:29:34 PM (2 occurrences)
Last logged: 8:29:34 PM
Error while setting up samsungtv_encrypted platform for media_player
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/samsungtv_encrypted/media_player.py", line 129, in setup_platform
turn_on_action = Script(hass, turn_on_action)
TypeError: __init__() missing 2 required positional arguments: 'name' and 'domain'
Here's the config:
media_player:
- platform: samsungtv_encrypted
host: !secret samsungtv_encrypted_sala_host
token: !secret samsungtv_encrypted_sala_token
sessionid: !secret samsungtv_encrypted_sala_sessionid
port: !secret samsungtv_encrypted_sala_port
name: sala_tv
turn_on_action:
- service: switch.turn_on
data:
entity_id: switch.samsung_tv_power
- platform: samsungtv_encrypted
host: !secret samsungtv_encrypted_suite_host
token: !secret samsungtv_encrypted_suite_token
sessionid: !secret samsungtv_encrypted_suite_sessionid
port: !secret samsungtv_encrypted_suite_port
name: suite_tv
turn_on_action:
- service: switch.turn_on
data:
entity_id: switch.samsung_tv_power
Manualy installed into homeassistant-0.109.6 in virtual environment
See following error in log:
2020-05-19 17:54:20 ERROR (MainThread) [homeassistant.components.homeassistant] Platform error media_player.samsungtv_encrypted - cannot import name 'MediaPlayerEntity' from 'homeassistant.components.media_player' (/home/ubuntu/hass/homeassistant/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py)
There is a small part of my Docker log:
ws://<host>:8000/socket.io/1/websocket/h69NWKFZhek5y_YMAPfB
ws://<host>:8000/socket.io/1/websocket/er1O92hWH2cdgNOuAPfC
ws://<host>:8000/socket.io/1/websocket/G_g-JPb0Sl_m2SjOAPfD
ws://<host>:8000/socket.io/1/websocket/g1d7FksMUSe2XqDAAPfE
ws://<host>:8000/socket.io/1/websocket/zvsG65_E11pb6RlhAPfF
ws://<host>:8000/socket.io/1/websocket/RYqb3qXFgyqHI9rBAPfG
ws://<host>:8000/socket.io/1/websocket/2A-bc81ZAPkgzufMAPfH
ws://<host>:8000/socket.io/1/websocket/OrF5Brs8Tw38aQ9fAPfI
ws://<host>:8000/socket.io/1/websocket/dNKDq1Od0e3dci8OAPfJ
ws://<host>:8000/socket.io/1/websocket/PcsSrYuirz7Ho6pTAPfK
ws://<host>:8000/socket.io/1/websocket/Jr3n4StuoJp-Xos4APfL
ws://<host>:8000/socket.io/1/websocket/Ucxae8o_49IGULqLAPfM
ws://<host>:8000/socket.io/1/websocket/hG5WlCG0NkaU2i_yAPfN
ws://<host>:8000/socket.io/1/websocket/bo4atSCD_GqJxV5JAPfO
A new line appears every few seconds. Can it be fixed?
Please help me, what i must write in config, for turn on my tv?
I can't find service from example:
turn_on_action:
- service: kodi.call_method <------
This is my config section from configuration.yaml
media_player:
- platform: samsungtv_encrypted
host: 192.168.1.176
token: 5ed890fec2c282exxxxxxxxx
sessionid: 1
port: 8080
turn_on_action:
- service: kodi.call_method
data:
entity_id: media_player.samsung_led32_ue32h6400
method: Addons.ExecuteAddon
addonid: script.json-cec
params:
command: turn_on 0
Also i trying this command
turn_on_action:
service: wake_on_lan.send_magic_packet
data:
mac: "24:4B:03:43:C8:19"
And this:
turn_on_action:
- service: switch.turn_on
data:
entity_id: media_player.samsung_led32_ue32h6400
method: Addons.ExecuteAddon
addonid: script.json-cec
params:
command: turn_on 0
And all it's not working for me :(
How to write a correct config for turn on/off this TV from Home Assistant?
Hi Sergio,
When you have some time, I would like to ask you if you could take a look at this problem. My TV HU8500 changes smp port each time I turn it on. Your integration, if I'm not mistaken, only scans the available uPNP ports when runs for the first time. If a TV like mine is turned on on the next day and if it uses other port on the next day, then the integration doesn't work anymore. A simple reboot of the HA solves the problem.
I have captured uPNP info and logs in debug mode. Attached you will find two files, one when the integration works and the other capture on the next day when it does not work because the integration can't connect to TV anymore.
Samsung TV when all OK.docx
Samsung TV when not ok.docx
Thanks
Rui
Hi,
I can't get the turn_on_action to work. I looked at your code and I can't figure out why it wouldn't.
Here's my config:
media_player:
- platform: samsungtv_encrypted
host: 192.168.1.177
token: xxx
sessionid: 1
port: 8080
turn_on_action:
service: switch.turn_on
entity_id: switch.samsung_tv
And this is the error message:
Invalid config for [media_player.samsungtv_encrypted]: [turn_on_action] is an invalid option for [media_player.samsungtv_encrypted]. Check: media_player.samsungtv_encrypted->turn_on_action.
Hi,
when TV (H6400 serie) is turned on I receive exception every 10 seconds.
There is no problem with turning on/off TV (HDMI) , adjusting volume and mute.
Home Assistant 0.108.9
python_version | 3.7.7
ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.samsung_tv_remote fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/samsungtv_encrypted/media_player.py", line 189, in update self._upnp_ports, self._upnp_paths = self.discoverSSDP(timeout=2) File "/config/custom_components/samsungtv_encrypted/media_player.py", line 457, in discoverSSDP if entry.location.startswith('http://{}'.format(self._config['host'])): AttributeError: 'NoneType' object has no attribute 'startswith'
@sermayoral , Installed the component version master and 2.2, but both versions in the error log:
When you try to form a team
entity_id: media_player.samsung_room
media_content_type: send_key
media_content_id: KEY_CHDOWN
2020-04-02 21:52:03 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1770011216] extra keys not allowed @ data['media_content_type']
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1210, in async_call
processed_data = handler.schema(service_data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 208, in __call__
return self._exec((Schema(val) for val in self.validators), v)
File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 287, in _exec
raise e if self.msg is None else AllInvalid(self.msg, path=path)
File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 283, in _exec
v = func(v)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['media_content_type']
When you try to change the sound with the slider in the widget:
2020-04-02 21:44:27 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1770011216] 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1232, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1255, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
self._platforms.values(), func, call, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 412, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 600, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 443, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 542, in async_set_volume_level
await self.hass.async_add_job(self.set_volume_level, volume)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/samsungtv_encrypted/media_player.py", line 359, in set_volume_level
self.SendSOAP(self._smp[0], self._urns[0], 'SetVolume',
The token and session number were received without problems through the execution request get_token.py
bash-5.0# python3 get_token.py --ip 192.168.169.9 --port 8080
ws://192.168.169.9:8000/socket.io/1/websocket/7hwVABdjBnbxQhAWRtVH
Current state: stopped
Pin NOT on TV
Please enter pin from tv: 2646
Got pin: '2646'
AES key: a133e693a5e73c64a5c82f9a26f03d2d
AES encrypted: 16*******6b7611ef4cdedd6645534ced4803208cc66ea
AES swapped: 79d90******422656f45f889478ccb3e53d1e49614357972a30d60dbc292
data buffer: 000000063*********C292
hash: feca1daaf7fdafe1b814fc2bd497096e27fd8eee
secondStepResponse: {"auth_data":"{\"auth_type\":\"SPC\",\"request_id\":\"0\",\"GeneratorClientHello\":\"01010**********2D1B58A2BDF800000000000\"}"}
thirdLen: 138
hello: 01010********d308230e721542d1b58a2bdf800000000000
dest: 0000000636**********27fd8eee
userId: 654321
pEncWBGx: b25809d*********40add528822f828f1c170ba72
pEncGx: 1fff9bc859********a920a982b4c0d9262437ef
pGx: 1b9d430*********38b375f83647a65a0fe59381aa4e6e04b5a38074a0d26c
secret: 9be7***********17cda8492bfcee5acd38e92c39
hash2: 0461e27**********8a2bdf80
secret2: 363534*********5acd38e92c39
hash3: 0461e277169*******21542d1b58a2bdf80
Pin OK :)
dest_hash: c6098041ec*******07b2a6ec187f8cbf5
SKPrime: df142da193b********9046f652a21ff98d
SKPrimeHash: abdac4dd21********4c70c48d476ca149
ctx: 1e66f533***cf950286123
Pin accepted :)
sessionId: 3
SessionID: 3
Authorization successfull :)
Config Home Assistant 0.108.0b0
- platform: samsungtv_encrypted
name: samsung_room
host: 192.168.169.9
token: 2646
sessionid: 3
port: 8080
Can someone tell me what the problem is, in HA only the On / Off status is displayed. The sound level is not displayed, the command does not accept
P.s
TV response at http://192.168.169.9:8001/api/v2/
{
"id": "uuid:409*******************b803",
"name": "[TV] UE48J6530",
"version": "2.0.25",
"device": {
"type": "Samsung SmartTV",
"duid": "uuid:40951******************b803",
"model": "15_HAWKM_2D",
"modelName": "UE48J6300",
"description": "Samsung DTV RCR",
"networkType": "wired",
"ssid": "",
"ip": "192.168.169.9",
"firmwareVersion": "Unknown",
"name": "[TV] UE48J6530",
"id": "uuid:40951**********1b803",
"udn": "uuid:409518***********31b803",
"resolution": "1920x1080",
"countryCode": "RU",
"msfVersion": "2.0.25",
"smartHubAgreement": "true",
"wifiMac": "f8:********:e1",
"developerMode": "0",
"developerIP": ""
},
"type": "Samsung SmartTV",
"uri": "http://192.168.169.9:8001/api/v2/"
Please use this thread to share your experiences with this custom component, tests, etc. The goal of this thread is to avoid saturating threads of specific issues. This thread will remain open
Hi, Thanks for the component, which is the first to work consistently with H6400!
I am running 0.106.6, and before updating to 0.107, ran the configuration checker. I got the following error:
Failed config
General Errors:
- Platform error media_player.samsungtv_encrypted - No module named 'websocket'
What could be the issue? is it safe to upgrade?
Hi to all :)
JS8500 only the power on and off doesn't work, all the rest so far, so good.
Thank you!
Wont install through HACS as a result.
Good day,
someone can help me to launch get_token.py, I have try to launch it on windows CMD, without success.
I already install on my windows Python platform the follow script:
Crypto
Websockets
AES
But i still receive from windws CMD the follow error:
C:\Users\skky8\Desktop\samsungtv_encrypted>py get_token.py
Traceback (most recent call last):
File "get_token.py", line 3, in
from PySmartCrypto.pysmartcrypto import PySmartCrypto
File "C:\Users\skky8\Desktop\samsungtv_encrypted\PySmartCrypto\pysmartcrypto.py", line 2, in
from . import crypto
File "C:\Users\skky8\Desktop\samsungtv_encrypted\PySmartCrypto\crypto.py", line 2, in
from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
Like that crypto isn't correct installed, someone can help me?
Would be posible to change the name from Samsung remote to any desired tv name. With a confing setting???
Dear all,
I've successfully found the token and sessionID.
The TV recognises the component and i have allowed it access to the tv. The outcome is however the same, I can't operate the TV. Simple on/off aren't possible.
Hi,
I'm tring your component with a UE40JU4600K but this method cannot find my TV's services, because it uses port 9197 for the RenderingControl and a different path (http://:9197/dmr) and port 7677 with path http://:7677/MediaTVServer2. Can you handle this configuration? Thanks
EDIT: this is a correct GetVolume request sniffed with Wireshark
POST /upnp/control/RenderingControl1 HTTP/1.1
SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
Content-Length: 352
Content-Type: text/xml
Content-Encoding: utf-8
Host: 192.168.178.26:9197
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume>
</s:Body>
</s:Envelope>
EDIT2: Even if I manually set te services path and port, the method SendSOAP fails. The line that generate error is dataBuffer = client.recv(4096), returning timed out
Hi,
I cant turn off my tv while I can control the input source or the volume ..
can you help me please?
Thanks,
Hi,
Is there a way to labels the sources detected ? As of now the sources available are TV and HDMI 1-4.
I tried adding
sourcelist: '{"TataSky": "KEY_HDMI1", "OSMC": "KEY_HDMI2", "HA": "KEY_HDMI3", "Apple TV": "KEY_HDMI4"}
to the config, but that is throwing up an error:
Invalid config for [media_player.samsungtv_encrypted]: [sourcelist] is an invalid option for [media_player.samsungtv_encrypted].
`
Is there any way to add an apps list similar to the sources list? Allow the selection of Netflix, Youtube and other apps loaded on the TV.
I have a Samsung UA40H5500
I have a few scrape sensors set up, for example:
sensor:
When using this integration these sensors no longer work and I get the following error:
Log Details (ERROR)
Logger: homeassistant.components.sensor
Source: components/scrape/sensor.py:135
Integration: Sensor (documentation, issues)
First occurred: 8:11:32 AM (4 occurrences)
Last logged: 8:11:34 AM
scrape: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 472, in async_device_update
await self.hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/scrape/sensor.py", line 135, in update
value = raw_data.select(self._select)[self._index].text
File "/usr/local/lib/python3.7/site-packages/bs4/element.py", line 1532, in select
for candidate in _use_candidate_generator(tag):
File "/usr/local/lib/python3.7/site-packages/bs4/element.py", line 1493, in recursive_select
for i in tag.select(next_token, recursive_candidate_generator):
File "/usr/local/lib/python3.7/site-packages/bs4/element.py", line 1451, in select
'Only the following pseudo-classes are implemented: nth-of-type.')
NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.