I have the same error and i tried deleting “pycache” numerous times too and dont worked here.
My HA is running in Synology too.
I had this problem too. Fixed by:
- Delete pycache folder
- Open terminal and type
pip3 install samsungtvws
- Remove the ‘samsungtv_custom’ section from configuration.yaml and restart HA
- Add ‘samsungtv_custom’ section back into configuration.yaml
- Restart HA again
Cant get it working.
Latest HASS
Latest from https://github.com/roberodin/ha-samsungtv-custom
Listening on port 8001
TV: Samsung The Frame 55 inch
Can turn on, but nothing else…
Failed to call service media_player/turn_off. {‘event’: ‘ms.channel.unauthorized’}
Any tips?
EDIT:
some more ino…
I have changed to port 8002 now:
- platform: samsungtv_custom
host: 192.168.1.134
port: 8002
mac: 00:c3:f4:b1:b0:84
sourcelist: ‘{“TV”: “KEY_TV”, “HDMI”: “KEY_HDMI”, “ONKYO”: “KEY_HDMI4”}’
protocol: ctl_qled
name: Samsung The Frame
But I cannot control it again. only turn on. What is strange: if I press on HA “the on button” here:
the accept dialog on the TV appears and I click “accept”
Bu nothing happens and I can continue to do that… click on, accept, on accept, etc…
How do you do this for Docker?
Hi @Saggerus, I got your solution to work and I’m getting a bit further now. The following applies to Synology Docker users:
- Delete pycache folder
- Go into “Docker” in Synology". Go into your “Containers” and open up your Home Assistant Container. Go to the “Terminal” Menu tap and Choose the down arrow beside “Create” and choose “Launch with command”. Paste in “pip3 install samsungtvws” and press “OK”
- Remove the ‘samsungtv_custom’ section from configuration.yaml and restart HA
- Add ‘samsungtv_custom’ section back into configuration.yaml
- Restart HA again
I’m no longer getting the error
Platform error media_player.samsungtv_custom - No module named ‘samsungtvws’
But i’m now getting the following error:
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 275, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 316, in _async_write_ha_state
attr.update(self.state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 832, in state_attributes
for attr in ATTR_TO_PROPERTY
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 833, in <dictcomp>
if getattr(self, attr) is not None
File "/config/custom_components/samsungtv_custom/media_player.py", line 304, in source_list
self._gen_installed_app_list()
File "/config/custom_components/samsungtv_custom/media_player.py", line 219, in _gen_installed_app_list
app_list = self._remote.app_list()
File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 175, in app_list
self._ws_send(payload)
File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 91, in _ws_send
self.connection.send(payload)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 250, in send
return self.send_frame(frame)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 275, in send_frame
l = self._send(data)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 445, in _send
return send(self.sock, data)
File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 117, in send
return sock.send(data)
File "/usr/local/lib/python3.7/ssl.py", line 1003, in send
return self._sslobj.write(data)
ConnectionResetError: [Errno 104] Connection reset by peer
Any help or suggestions as ever are greatly appreciated!
Hi, great component and working pretty well for me on my new Q70 and lets me switch between apps. I’m in Australia and we have a video app called “Stan”. Any way I can grab the code for that app somehow and modify the application.py so I can start it up?
While app switching works well, any of the other controls I try, on/off, play even volume etc pop up the “you must give permission” dialogue box on the TV but doesn’t seem to actually do anything?
Cheers
Thanks for this @xchwarze. Works very well except from the HDMI input selection. For some reason, I can launch apps e.g. Netflix using your method but I can’t switch to a HDMI input.
More importantly, do you know if the Samsung TV has an attribute for “source”? That attribute would return the current source. I use it with my LG TV currently to sync my harmony remote when someone uses another remote and would love to replicate that functionality on my Samsung TV.
Hello,
Does this work for the Samsung J6300 models?
Thanks
Looking to try this again and I am confused as to which version I should be using.
Mostly I just want to be able to turn the TV off when my kids leave it on. lol
{"device":{"FrameTVSupport":"false","GamePadSupport":"true","ImeSyncedSupport":"true","OS":"Tizen","TokenAuthSupport":"true","VoiceSupport":"false","countryCode":"CA","description":"Samsung DTV RCR","developerIP":"0.0.0.0","developerMode":"0","duid":"uuid:6deeb4be-bee3-478c-b07a-4ae21f078337","firmwareVersion":"Unknown","id":"uuid:6deeb4be-bee3-478c-b07a-4ae21f078337","ip":"192.168.20.6","model":"17_KANTM_UHD_BASIC","modelName":"UN65MU6290","name":"[TV] Samsung 6 Series (65)","networkType":"wired","resolution":"3840x2160","smartHubAgreement":"true","type":"Samsung SmartTV","udn":"uuid:6deeb4be-bee3-478c-b07a-4ae21f078337","wifiMac":"54:bd:79:e9:f0:e7"},"id":"uuid:6deeb4be-bee3-478c-b07a-4ae21f078337","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\":\"false\"}\n","name":"[TV] Samsung 6 Series (65)","remote":"1.0","type":"Samsung SmartTV","uri":"https://192.168.20.6:8002/api/v2/","version":"2.0.25"}
I am using the latest version of HASS.IO
Hi!
I have the Q80, could you share your config, please?
Which port are you using?
Have you prepare something before in TV or SmartThing app?
Thanks in advance.
I would use this version. It is for 2016+ samsung TV’s and works great with mine so far. It Turns on / off, Allows me to run an app and also tells me which app is currently running on the TV.
It cant tell you which HDMI you are on though but apart from that, Works a treat
I need some help. I Have looked at all the posts and am not sure of what it is I am doing.
I have a UN65NU8000 TV
Based on the post in the forum and the info on the git hub repo I have tried both the following configs.
media_player:
- platform: samsungtv
host: 192.168.1.40
mac: XX:XX:XX:XX:XX:XX (redacted)
port: 8002
name: Greatroom TV
media_player:
- platform: samsungtv_custom
host: 192.168.1.40
port: 8002
name: Greatroom TV
and this is what I get in the states.
media_player.samsung_tv_remote
on
is_volume_muted: false
source_list: TV,HDMI
friendly_name: Samsung TV Remote
supported_features: 20409
device_class: tv
Any directions or pointers would be greatly appreciated.
carltonb
applist SmartIPTV can be added?
I’m using https://github.com/jaruba/ha-samsungtv-custom and works good. I’m wondering how I can add 2 buttons for previous and next channel.
Good afternoon, I just can’t beat the problem with the integration of Samsung SmartTV
UE48J6300
`http://192.168.169.9:8001/api/v2/
{
"id": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
"name": "[TV] Small room",
"version": "2.0.25",
"device": {
"type": "Samsung SmartTV",
"duid": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
"model": "15_HAWKM_2D",
"modelName": "UE48J6300",
"description": "Samsung DTV RCR",
"networkType": "wired",
"ssid": "",
"ip": "192.168.169.9",
"firmwareVersion": "Unknown",
"name": "[TV] Small room",
"id": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
"udn": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
"resolution": "1920x1080",
"countryCode": "RU",
"msfVersion": "2.0.25",
"smartHubAgreement": "true",
"wifiMac": "f8:77:b8:df:06:e1",
"developerMode": "0",
"developerIP": ""
},
"type": "Samsung SmartTV",
"uri": "http://192.168.169.9:8001/api/v2/"
}`
Nmap 7.80
`Starting Nmap 7.80 ( https://nmap.org ) at 2020-01-12 12:41 RTZ 4 (ceia)
NSE: Loaded 151 scripts for scanning.
NSE: Script Pre-scanning.
Initiating NSE at 12:41
Completed NSE at 12:41, 0.00s elapsed
Initiating NSE at 12:41
Completed NSE at 12:41, 0.00s elapsed
Initiating NSE at 12:41
Completed NSE at 12:41, 0.00s elapsed
Initiating ARP Ping Scan at 12:41
Scanning 192.168.169.9 [1 port]
Completed ARP Ping Scan at 12:41, 0.46s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 12:41
Completed Parallel DNS resolution of 1 host. at 12:41, 0.00s elapsed
Initiating SYN Stealth Scan at 12:41
Scanning 192.168.169.9 [1000 ports]
Discovered open port 8080/tcp on 192.168.169.9
Discovered open port 7676/tcp on 192.168.169.9
Discovered open port 8002/tcp on 192.168.169.9
Discovered open port 9999/tcp on 192.168.169.9
Discovered open port 9090/tcp on 192.168.169.9
Discovered open port 8001/tcp on 192.168.169.9
Discovered open port 8000/tcp on 192.168.169.9
Completed SYN Stealth Scan at 12:41, 0.17s elapsed (1000 total ports)
Initiating Service scan at 12:41
Scanning 7 services on 192.168.169.9
Completed Service scan at 12:42, 44.83s elapsed (7 services on 1 host)
Initiating OS detection (try #1) against 192.168.169.9
NSE: Script scanning 192.168.169.9.
Initiating NSE at 12:42
Completed NSE at 12:42, 11.03s elapsed
Initiating NSE at 12:42
Completed NSE at 12:42, 0.38s elapsed
Initiating NSE at 12:42
Completed NSE at 12:42, 0.00s elapsed
Nmap scan report for 192.168.169.9
Host is up (0.0012s latency).
Not shown: 993 closed ports
PORT STATE SERVICE VERSION
7676/tcp open upnp Samsung AllShare upnpd 1.0 (UPnP 1.1)
8000/tcp open http-alt
| fingerprint-strings:
| FourOhFourRequest, GetRequest, HTTPOptions:
| HTTP/1.1 500 Internal Server Error
| Content-Type: text/plain
| Date: Sun, 12 Jan 2020 07:41:59 GMT
|_ Connection: close
|_http-cors: GET POST PUT DELETE OPTIONS
|_http-favicon: Unknown favicon MD5: 33E3EA7FC9C08D2E72730482906A676C
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-open-proxy: Proxy might be redirecting requests
|_http-title: Site doesn't have a title.
8001/tcp open http Tizen Multiscreen SDK httpd
|_http-cors: GET POST PUT DELETE
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: 404 : Not Found
8002/tcp open ssl/http Tizen Multiscreen SDK httpd
|_http-cors: POST PUT DELETE
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: 404 : Not Found
| ssl-cert: Subject: commonName=SmartViewSDK/organizationName=SmartViewSDK/countryName=KR
| Subject Alternative Name: DNS:127.0.0.1, DNS:localhost
| Issuer: commonName=SmartViewSDK Root Ceritificate Authority/organizationName=SmartViewSDK/countryName=KR
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2016-07-29T05:34:23
| Not valid after: 2036-07-29T05:34:23
| MD5: 189b 2634 fcca f1ef 31e1 7b7b 02ac c5bd
|_SHA-1: b15e 72c0 04b4 3825 651e e7a7 2b66 1856 305d e56b
|_ssl-date: TLS randomness does not represent time
| tls-nextprotoneg:
| http/1.1
|_ http/1.0
8080/tcp open http lighttpd
| http-methods:
|_ Supported Methods: OPTIONS GET HEAD POST
|_http-server-header: WebServer
|_http-title: 404 - Not Found
9090/tcp open http Samsung UE55D7000 TV http config
|_http-favicon: Unknown favicon MD5: D41D8CD98F00B204E9800998ECF8427E
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: Site doesn't have a title (application/octet-stream).
9999/tcp open abyss?
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port8000-TCP:V=7.80%I=7%D=1/12%Time=5E1ACDCD%P=i686-pc-windows-windows%
SF:r(GetRequest,78,"HTTP/1\.1\x20500\x20Internal\x20Server\x20Error\r\nCon
SF:tent-Type:\x20text/plain\r\nDate:\x20Sun,\x2012\x20Jan\x202020\x2007:41
SF::59\x20GMT\r\nConnection:\x20close\r\n\r\n")%r(FourOhFourRequest,78,"HT
SF:TP/1\.1\x20500\x20Internal\x20Server\x20Error\r\nContent-Type:\x20text/
SF:plain\r\nDate:\x20Sun,\x2012\x20Jan\x202020\x2007:41:59\x20GMT\r\nConne
SF:ction:\x20close\r\n\r\n")%r(HTTPOptions,78,"HTTP/1\.1\x20500\x20Interna
SF:l\x20Server\x20Error\r\nContent-Type:\x20text/plain\r\nDate:\x20Sun,\x2
SF:012\x20Jan\x202020\x2007:41:59\x20GMT\r\nConnection:\x20close\r\n\r\n");
MAC Address: F8:77:B8:DF:06:E1 (Samsung Electronics)
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.2 - 3.10, Linux 3.2 - 3.16
Uptime guess: 1.491 days (since Sat Jan 11 00:55:22 2020)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: Device: media device; CPE: cpe:/h:samsung:ue55d7000
TRACEROUTE
HOP RTT ADDRESS
1 1.23 ms 192.168.169.9
NSE: Script Post-scanning.
Initiating NSE at 12:42
Completed NSE at 12:42, 0.00s elapsed
Initiating NSE at 12:42
Completed NSE at 12:42, 0.00s elapsed
Initiating NSE at 12:42
Completed NSE at 12:42, 0.00s elapsed
Read data files from: C:\Program Files (x86)\Nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 61.86 seconds
Raw packets sent: 1023 (45.806KB) | Rcvd: 1020 (41.635KB)`
I used various costume components of various authors xchwarze / ha-samsungtv-custom, roberodin ha-samsungtv-custom, jaruba ha-samsungtv-custom. The result is one, only the actual status of the TV is displayed On / Off, but there is no control! Everything works only through port 8001. When using port 8002 in LOG
`Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 81, in recv
bytes_ = sock.recv(bufsize)
File "/usr/local/lib/python3.7/ssl.py", line 1056, in recv
return self.read(buflen)
File "/usr/local/lib/python3.7/ssl.py", line 931, in read
return self._sslobj.read(len)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 407, in _async_add_entity
await entity.async_update_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
attr.update(self.state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 795, in state_attributes
for attr in ATTR_TO_PROPERTY
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 796, in <dictcomp>
if getattr(self, attr) is not None
File "/config/custom_components/samsungtv_custom/media_player.py", line 286, in source_list
self._gen_installed_app_list()
File "/config/custom_components/samsungtv_custom/media_player.py", line 248, in _gen_installed_app_list
app_list = self._remote.app_list()
File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 175, in app_list
self._ws_send(payload)
File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 89, in _ws_send
self.open()
File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 104, in open
sslopt=sslopt
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 511, in create_connection
websock.connect(url, **options)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 223, in connect
self.handshake_response = handshake(self.sock, *addrs, **options)
File "/usr/local/lib/python3.7/site-packages/websocket/_handshake.py", line 79, in handshake
status, resp = _get_resp_headers(sock)
File "/usr/local/lib/python3.7/site-packages/websocket/_handshake.py", line 150, in _get_resp_headers
status, resp_headers, status_message = read_headers(sock)
File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 298, in read_headers
line = recv_line(sock)
File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 102, in recv_line
c = recv(sock, 1)
File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 84, in recv
raise WebSocketTimeoutException(message)
websocket._exceptions.WebSocketTimeoutException: The read operation timed out`
On costume components of the author xchwarze, the token-192.178.189.9.txt file is created in the folder, but it is empty! The TV does not issue a request for granting access to work with HA on any component, I think this is the main problem, but how to send a request for granting access if nothing happens when you click on the Sound, Channel, Source buttons (
P.s
I also checked on which port the standard Samsung TV Android application accesses via TV via Wireshark. Handling and control occurs via port 8001 with a token request on the TV screen
I had a similar issue with my TV it was showing as off even though it was on and wasn’t saving the token file either.
Double check the permissions on the token-ip.txt it may not be able to write back that’s why it’s not saving(my issue). Also check the TV accepted devices list. If there are any other instances of home assistant in there I would just delete them just incase.
Yes, I read about your problem, it seemed to me similar too. But the token-192.168.169.9.txt file is created by the ha-samsungtv-custom component, I deleted it and started HA. It will be created again, but the file size is 0 kb and it is empty. Also, there was never a message on the television monitor about providing access to an external source HA server. It seems that ha-samsungtv-custom doesn’t even manage to send a request to Samsung TV (for comparison, on a system built on OpenHab2, a component for working with TV immediately generated a request for TV to provide access
What TV do you have? Mine doesn’t tell me which app is running. It’s always just “TV/HDMI” which is the default if it doesn’t find any source.
I have a samsung UN65NU8000 and I cant get it to report back and just shows just “TV/HDMI” and if I spam icons the card goes crazy. Need help please!!!
Any progress?