Samsung TV Binding (Beta)

NP, glad you got it going.

Hi everyone,

I have used this binding succesfully in the past with a Samsung Frame TV. I have recently bought a Samsung S95C (rather new model I guess) and am now struggling to get it to work.
Installing the beta-binding from the marketplace unfortunately didn’t work for me (it seemingly installed the 4.1.x version which didnt work on my openhab 4.0.4). I downloaded the version that Nick linked and that then worked.
However even though I was able to scan and detect the TV, I can’t really get it to work. It seems to me that the problem is that I don’t get the webtoken. Even after activating all the settings on the Samsung, I never received the notification window. I was able to get it though by browsing to the 8001/api/v2 url, but that was then not the same machine as my openhab machine.
In the logfile I therfore get:
WebSocketRemote connecting without Token, please accept the connection on the TV within 30 seconds
But since the TV doesnt show the notification window, Im kinda stuck.

Any idea how to debug/proceed further?
Let me add the output of the 8001 api request:

{"device":{"EdgeBlendingSupport":"false","FrameTVSupport":"false","GamePadSupport":"true","ImeSyncedSupport":"true","Language":"de_DE","OS":"Tizen","PowerState":"on","TokenAuthSupport":"true","VoiceSupport":"true","WallScreenRatio":"-1","WallService":"false","countryCode":"DE","description":"Samsung DTV RCR","developerIP":"0.0.0.0","developerMode":"0","duid":"uuid:314fb6e3-be01-4f28-9946-38936b6f2703","firmwareVersion":"Unknown","id":"uuid:314fb6e3-be01-4f28-9946-38936b6f2703","ip":"192.168.178.63","model":"23_PONTUSM_QD","modelName":"QE65S95CATXXH","name":"Samsung S95CA 65","networkType":"wireless","resolution":"3840x2160","smartHubAgreement":"true","ssid":"dc:39:6f:06:ba:a0","type":"Samsung SmartTV","udn":"uuid:314fb6e3-be01-4f28-9946-38936b6f2703","wifiMac":"E0:03:6B:FE:4D:7E"},"id":"uuid:314fb6e3-be01-4f28-9946-38936b6f2703","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":"Samsung S95CA 65","remote":"1.0","type":"Samsung SmartTV","uri":"http://192.168.178.63:8001/api/v2/","version":"2.0.25"}

Make sure your “Device Connect Manager” is set to “first time only”. If it is set to “Off” you will never get asked to approve the connection, and the connection will fail.

I did that. And I guess the fact that I got the popup when I accessed the 8001/api/v2 confirms that it works, but I don’t get it when openhab is attempting to connect…

Then check in your device manager that the device “Openhab” isn’t listed, or set to denied. If it is delete it, and try again.

There is no reason why it shouldn’t work.

Also, accessing the 8001/app/v2 page should not produce this pop up at all. You seem to be getting confused between the two things.

Only accessing the websocket produces this pop up, so you may have accidentally denied the binding access.

I very much appreciate your help.
I am not confused though :slight_smile:
I have tried many times already and just tried again. The device list ist empty. When I access the 8001/app/v2 page from my windows machine (Chrome), it does actually trigger this popup. And unfortunately the addin doesn’t.
In the openhab.log file I see “WebSocketRemote connecting without Token, please accept the connection on the TV within 30 seconds”.
But unfortunately no popup…

I just set the debug level to trace and saw the following:
WebSocketV2 connection error PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Ok, well that’s different then. It’s saying it can’t get the certificate for the secure connection.

Not sure what that is about.

Looks like the certificate on the Samsung TV may be expired. Can you update to a later version of firmware?

Unfortunately, I am on the latest firmware. Kinda regretting that I updated straight away as Samsung doesn’t allow you to downgrade.
I still find it weird that everything works with the Smartthings app, which presumably uses the same approach.
Will try to setup a clean instance of Openhab 4.1 (don’t want to upgrade yet) to see if that makes any difference..

Actually Smartthings uses a completely different access method.

Let me know how OH4.1 works.

Since two weeks I have a QE43q60c (2023 model) and have the same behavior - no popup appears on TV screen. I did not debug yet, but probably the same issue.
With my 2019 Samsung everything is fine.
I am still on OH 3.4 and use an older version of the binding.

I’ve also had trouble getting the popup to appear on a 2023 TV (QN90C), using the OH3.4 version of the binding.

The TV appears online in OH when powered on, but the channels are read-only. If I turn the TV off, the thing goes offline.

Dear @Nicholas_Waterton,

I have tried to install your binding but struggling against the following unsatisfied requirements (I do not think they depend on the binding) I cannot sort out. Can you please suggest how I could move on?

Thanks!
LOG
CONSOLE

Please do not post screenshots. Prefered way is to post as text in code fences.
Your issue is well described. openHAB 4.0 uses an older gson bundle than expected by openHAB 4.1 binding versions.
Use the community search for gson and you will find some posts how to install the required bundle.

It seems to show the same behaviour. I used a docker setup for this test and for some reason it doesn’t let me set the loglevel for the binding. Doesn’t show up in “log:list”. But I have a feeling it is exactly the same. The Thing goes online, but it is unable to retrieve the token as there is no popup on the TV.
I am happy to help further as much as possible.
Will try to see if I can find some non-openhab integration that maybe works and see if we can learn from that…

I did install wscat on my raspberry and while

wscat -c "wss://192.168.178.63:8002/api/v2?name=b3BlbkhBQg=="

gave me a somewhat similar error

error: self-signed certificate in certificate chain

I then added the “-n” parameter to skip cert checks and I did get a response:

 {"data":{"clients":[{"attributes":{"name":"b3BlbkhBQg=="},"connectTime":1702064418781,"deviceName":"b3BlbkhBQg==","id":"f23d39ad-92b0-4888-aa41-1c312bfc4d60","isHost":false}],"id":"f23d39ad-92b0-4888-aa41-1c312bfc4d60"},"event":"ms.channel.connect"}

I haven’t quite figured out what I need to send to get the token, but I’m sure Nick knows that. Now I’m wondering if there is a similar “no-check” option that you could use, if only to figure whether that would work…
Will update when I know more…

I actually managed to get a token by sending this (which triggered the TV popup):

 wscat -n -c "wss://192.168.178.63:8002/api/v2/channels/samsung.remote.control?name=b3BlbkhBQg=="

But specifying the token in a .things file wouldnt change anything because it still needs to establish the websocket connection and fails for the same certificate reason (token or not).

@Msax75 If you are using OH 4.0, you should use the earlier jar file I posted earlier, or install the required gson bundle as described elsewhere.

It’s an OH 4.0 vs 4.1 thing.

I understand that the invalid certificates might be an issue that is caused by Samsung and how that makes anyone hesitant to fix it with a not very clean workaround.
Doesn’t help the ones affected by this though :slight_smile:
I was wondering if you would consider providing such a workaround. Could be an optional parameter to disable certificate checking.
My rather basic understanding is that you are leveraging a WebSocketFactory implementation provided by openhab. It seems to me that Kai who seems to have written this, has actually also provided a TrustAllTrustManager (TrustAllTrustManager (openHAB Core 5.1.0-SNAPSHOT API)) that could be used to help here.
If not, I will either try to fork your addon and hopefully be able to do it on my own or try to use the “SmartThings approach” which is obviously not a local method but seems to work as well (after authenticating you can actually send various commands through HTTP POST).

Thanks!

I’ll take a look at it. I may need you to test it, as I don’t have this problem with my TV’s.

Obviously happy to test it!

@El_Duderino

What platform are you running OpenHab on? (eg Windows, Ubuntu, RPi etc)

If it’s Linux based, can you run the command:

 openssl s_client -connect <tv ip>:8002 2>/dev/null | openssl x509 -text -noout

Where your replace <tv ip> with your actual TV’s ip address

And post the results back here. This should give the certificate details for your TV.

It would be helpful if you could also post the error message you get in the TRACE log for the samsungtv binding.

Thanks.