Samsung TV Binding (Beta)

@Nicholas_Waterton

Thank you very much for your fast reply. Yesterday evening did some more testing with the binding and strangely the TV’s where not detected at all. So today, as i have a test instance of openhabian in a debian server, I did some test with it. Installed UPNP Binding and your Samsung Binding and everything works as expected with no issues. Also downloaded an Android APP UPnP Tool, to try and see if the TV’s appear when they are ON and disappear when they are OFF, and from what I see and understand the behavior is as expected.

Here are the output’s of the https://ip:8002/api/v2/ for both TV’s:

{"device":{"FrameTVSupport":"false","GamePadSupport":"true","ImeSyncedSupport":"true","Language":"pt_PT","OS":"Tizen","PowerState":"on","TokenAuthSupport":"true","VoiceSupport":"false","WallScreenRatio":"0","WallService":"false","countryCode":"PT","description":"Samsung DTV RCR","developerIP":"0.0.0.0","developerMode":"0","duid":"uuid:7ada6874-9ec5-433f-9859-1ca9b4843420","firmwareVersion":"Unknown","id":"uuid:7ada6874-9ec5-433f-9859-1ca9b4843420","ip":"192.168.1.162","model":"19_MUSEL_UHD_BASIC","modelName":"UE55RU7105KXXC","name":"[TV] Samsung 7 Series (55)","networkType":"wired","resolution":"3840x2160","smartHubAgreement":"true","type":"Samsung SmartTV","udn":"uuid:7ada6874-9ec5-433f-9859-1ca9b4843420","wifiMac":"d0:d0:03:05:86:f3"},"id":"uuid:7ada6874-9ec5-433f-9859-1ca9b4843420","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 7 Series (55)","remote":"1.0","type":"Samsung SmartTV","uri":"https://192.168.1.162:8002/api/v2/","version":"2.0.25"}

{"device":{"FrameTVSupport":"false","GamePadSupport":"true","ImeSyncedSupport":"true","Language":"pt_PT","OS":"Tizen","PowerState":"on","TokenAuthSupport":"true","VoiceSupport":"true","WallScreenRatio":"0","WallService":"false","countryCode":"PT","description":"Samsung DTV RCR","developerIP":"0.0.0.0","developerMode":"0","duid":"uuid:d08d67ff-a2f8-4d5a-9416-f392c59aeb3d","firmwareVersion":"Unknown","id":"uuid:d08d67ff-a2f8-4d5a-9416-f392c59aeb3d","ip":"192.168.1.163","model":"19_MUSEM_UHD","modelName":"UE65RU8005UXXC","name":"[TV] Samsung 8 Series (65)","networkType":"wired","resolution":"3840x2160","smartHubAgreement":"true","type":"Samsung SmartTV","udn":"uuid:d08d67ff-a2f8-4d5a-9416-f392c59aeb3d","wifiMac":"d4:9d:c0:1d:8a:b2"},"id":"uuid:d08d67ff-a2f8-4d5a-9416-f392c59aeb3d","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 8 Series (65)","remote":"1.0","type":"Samsung SmartTV","uri":"https://192.168.1.163:8002/api/v2/","version":"2.0.25"}

Both models are from 2019.

Today I am going to do further testing and keep you posted on the results.

Thanks again.

Best regards.

@rjduraocosta

That’s odd.

Can you capture a TRACE level log from the problem instance of OH (I need a good 60 seconds of log or more, where the TV’s are discovered, turned on/off) and I’ll take a look.

Hello @Nicholas_Waterton ,

Log captured with one of the TV’s.
samsungtv.log (226.3 KB)

Tried multiple times to switch TV ON/OFF with remote and with binding but the thing did only go OFFLINE once and then never again.

Thank you for your time in looking into this.

Best regards

@rjduraocosta

Thanks for the log. i can see that UPNP is working, and the TV is discovered correctly.

Your TV is not responding to WOL requests (that’s why it won’t turn on). Have you enabled WOL on the TV? also do you have a soundbar connected to your TV? I ask, because I have found that some Samsung TV’s do not respond to WOL packets if they are wired to ethernet, and have a soundbar connected. They do respond to WOL if they are connected via WiFi (even with a soundbar connected). Just more Samsung weirdness. This all assumes you have enabled WOL on the TV of course.

I think the option is under network and is called “Allow power on by Mobile”.

Volume and Mute are working, but when you power off the TV, the MediaRenderer service does not disappear, which is why the TV does not go offline (I think it does disappear, but it doesn’t register via UPNP as having been removed). Hence the TV will not try to turn ON again, as it doesn’t know it’s Off.

So UPNP is behaving oddly on your OH system. I don’t know why. You could try unplugging your TV for 60 seconds, and plugging it back in (I know, but it has been known to sort out some unexplained weirdness in the past).

Also, you don’t need to keep adding and removing the binding (and accepting the connection on your TV) - just going into the Thing configuration and clicking on “save” will restart the binding, without having to redo the tokens or anything. If you do it with the TV on, it should connect to the TV right away.

Try that and watch the logs, you should see:

192.168.1.163: remoteDeviceAdded: MediaRenderer, http://192.168.1.163:9197/dmr, upnpUDN=39537c15-1ed2-4502-a67d-50342b328caa

When the TV turns on (This is what sets the TV Online and ON, and starts the websockets connecting).

You should see:

[DEBUG] [nternal.service.MediaRendererService] - 192.168.1.163: onStatusChanged: status=false
.
.
.
192.168.1.163: Device removed: udn=39537c15-1ed2-4502-a67d-50342b328caa

When the TV turns off (this is what’s missing) - this puts the TV offline and OFF, and shuts down the websockets etc.

I should mention, the first time you turn the TV off, the UPNP services do register as being removed correctly, it’s after the WOL failure and you turn on manually that they don’t register as being removed when you turn the TV off again (they do register being added when the TV turns ON.

Let me know what you find.

Hello @Nicholas_Waterton,

Thank you for the log analysis.

Answering your questions:

Your TV is not responding to WOL requests (that’s why it won’t turn on). Have you enabled WOL on the TV? also do you have a soundbar connected to your TV? I ask, because I have found that some Samsung TV’s do not respond to WOL packets if they are wired to ethernet, and have a soundbar connected. They do respond to WOL if they are connected via WiFi (even with a soundbar connected). Just more Samsung weirdness. This all assumes you have enabled WOL on the TV of course.

I think the option is under network and is called “Allow power on by Mobile”.

I do not have a soundbar connected. Checked the option for WOL and it is enabled.

So UPNP is behaving oddly on your OH system. I don’t know why. You could try unplugging your TV for 60 seconds, and plugging it back in (I know, but it has been known to sort out some unexplained weirdness in the past).

Tried unplugging but ii did not produce any changes, everything behaves the same way.

Also, you don’t need to keep adding and removing the binding (and accepting the connection on your TV) - just going into the Thing configuration and clicking on “save” will restart the binding, without having to redo the tokens or anything. If you do it with the TV on, it should connect to the TV right away.

This does not solve the issue. I only gain control again after removing and adding the Thing.

Justo be sure, tested everything again in my test server, with both TV’s and everything works as expected. Thing Status, Power (ON/OFF), Mute, Volume, Application. So it is an issue in my production OH system, what I do not know is what and have no clue on how to start searching. Maybe it is something to do with another binding, but it is hard to know or find out, at least to me.

You binding is working perfectly fine.

Thanks again for all your help and support regarding this matter.

Best regards

I think your problem is somehow network related. The fact that WOL does not work, and that the UPNP devices are behaving oddly points to a multicast problem.

When a UPNP device is shutting down, it sends BYEBYE messages via multicast to all registered listeners. This uses the IGMP protocol. This is what the binding is listening for (via UPNP).

Your OH installation is not receiving these messages (or at least not reliably). It looks as though you have some sort of multicast or IGMP filtering enabled on your network - possibly at the switch level.

You may want to check your network and/or switches to make sure there isn’t any sort of multicast filtering or IGMP snooping/filtering enabled.

What is the difference between your test OH set up, and your production set up (from a network point of view)?

So I don’t think OH is the problem, its your network configuration.

Best of luck.

I am using Unifi based network with UDM-PRO. OH instance and TV’s are on the same main LAN, to my understanding there should be no issues, but you never know right :slight_smile:.

My test OH setup is in a virtual machine with debian OS running openhabian, also on the main LAN. From one TV’s perspective they are on the same switch, but from the other TV’s perspective they are on different switches and it works flawlessly on both. I guess this should not be relevant because all the traffic get’s managed by the UDM-PRO anyway.

Well, I am going to try and dig into the network configurations to see if I can find anything.

Thanks again for your time and patience.

Best regards

Edit:
Found the situation thanks to you @Nicholas_Waterton . Started looking in UNIFI setup, but saw that mDNS repeater was enabled, so it should be working. Then I remembered that I still have a TP-Link switch in the middle of the network (this is going to be removed but I still have to partially redo my ethernet wiring for that to happen). So there was a configuration that Enabled IGMP Snooping. After turning it off, in my production OH system everything started to working correctly.

Thanks again for you patience and all your help.

@rjduraocosta

Glad you found it!

Interestingly enough I have the same network setup (Unifi UDMP etc). My main OH setup is in a VM on a Proxmox server (Debian 10). Everything works fine, except WOL does not work to one of my TV’s.

I always thought that this was due to my soundbar being connected to that TV (it stopped working when I installed the soundbar), but then reading what I wrote to you, I remembered that when I connected the soundbar, I used the TV ethernet connection for the soundbar (Sonos beam), and connected the TV to a USW-Flex Mini, back to my USW-24-250 POE switch.

Investigating further, I believe that the USW-Flex-mini is blocking the WOL packets. I need to do more testing, but you may have solved another mystery that was puzzling me.

Thanks.

Hello @Nicholas_Waterton,

Just as as an additional info to your thoughts/investigations, I also have USW-Flex Mini’s back to my main switch, in my case USW-24. Both of my Samsung TV’s are connected to one USW-Flex Mini each and WOL is working correctly. I guess, based on my system, that it could not be the USW-Flex Mini blocking the WOL packets.

Thanks again.

Best regards

@rjduraocosta

You are right, I have another Mini PC connected to the same USW-Flex-Mini, that supports WOL, and I send that one WOL packet, and it boots, no problem.

Samsung TV - nothing. So I guess it is the soundbar. Weird.

I have a workaround in place that sends an IR command to turn the TV on, but it’s annoying.

Hi Nicholas, i cannot connect to my QE55Q7FN, scan is not showing anything and manual thing creation does detect socket and mac, but after that thing is offline forever. TV settings are ok. Log trace shows thing going from uninitialised to offline and “Check and create missing services”. Openhab is running in docker. I’ve ran feature:install multiple times. api/v2 on 8001 available. What am i missing?

@11194

The problem is likely that UPNP multicasts are being filtered on your network. Or you possibly haven’t installed the upnp.transport.io that is required by the binding.

Look for a setting in your router or switches that says “IGMP Snooping”, and disable it if enabled (IGMP Snooping filters multicast broadcasts).

You can also look for “IGMP multicast enhancement”, try enabling/disabling that, as it affects how multicast broadcasts are handled.

IGMP snooping is disabled and i’ve ran feature:install openhab-transport-upnp multiple times. Other UPNP services like Plex or GameStream are alive.

@11194

Ok, can you enable TRACE logging for the binding, and send me a log. I’ll take a look.

API v2 is using port 8001

openhab> log:set TRACE org.openhab.binding.samsungtv
openhab> log:tail org.openhab.binding.samsungtv
16:19:33.702 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: Disposing SamsungTvHandler
16:19:33.703 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: Shutdown all Samsung services
16:19:47.283 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: Create a Samsung TV Handler for thing 'samsungtv:tv:b7f7bd46e1'
16:19:47.287 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: Initializing Samsung TV handler for uid 'samsungtv:tv:b7f7bd46e1'
16:19:47.290 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: Updated artModeSupported: false and PowerState: false
16:19:47.290 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: Check and create missing services
16:19:47.291 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: TV is Offline
16:19:47.291 [DEBUG] [gtv.internal.handler.SamsungTvHandler] - 192.168.2.10: TV is NOT online

@11194
Have you changed the binding settings? Port 8001 is not the correct port.

You should have websocketsecure as the protocol, port 8002 selected.

Also, powerstate: false means that the tv is off or unreachable over the network

Having said that, you are missing the UPNP discovery messages, so the problem still seems to be missing multicast UPNP packets. Or the tv is unreachable.

What platform are you running OpenHAB on? How is your network configured?

What is the output of http://192.168.2.10:8001/api/v2/

I did changed settings. But with secure socket and port 8002 i get the same result. At least i see upnp announcements of port 8001 with wireshark. Openhab is running on debian bullseye linux inside docker container with network:host.

{"device":{"FrameTVSupport":"false","GamePadSupport":"true","ImeSyncedSupport":"true","OS":"Tizen","TokenAuthSupport":"true","VoiceSupport":"true","countryCode":"RU","description":"Samsung DTV RCR","developerIP":"0.0.0.0","developerMode":"0","duid":"uuid:429c38db-f6bf-4160-9576-bd6ee9b42d61","firmwareVersion":"Unknown","id":"uuid:429c38db-f6bf-4160-9576-bd6ee9b42d61","ip":"192.168.2.10","model":"18_KANTM2_QTV","modelName":"QE55Q7FNA","name":"[TV] Samsung Q7 Series (55)","networkType":"wired","resolution":"3840x2160","smartHubAgreement":"true","type":"Samsung SmartTV","udn":"uuid:429c38db-f6bf-4160-9576-bd6ee9b42d61","wifiMac":"c0:"},"id":"uuid:429c38db-f6bf-4160-9576-bd6ee9b42d61","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 Q7 Series (55)","remote":"1.0","type":"Samsung SmartTV","uri":"http://192.168.2.10:8001/api/v2/","version":"2.0.25"}

The docker container is probably the problem. I suspect it is filtering multicasts.

Websocketsecure and port 8002 are the only settings that will work. Multicasts are on port 1900.

Thanks for posting the output. There are some fundamental problems!

Your TV is not reporting powerState And your wifiMac address is invalid. I have never seen this before.

Wifimac is just deleted by me. Docker network:host shouldn’t filter anything, it’s a direct connection to eth0.
capture-Bridge0-Jan 30 16-09-53.txt (76.9 KB)

You also have no language shown.

The output should look like this

{"device":{"FrameTVSupport":"true","GamePadSupport":"true","ImeSyncedSupport":"true","Language":"en_US","OS":"Tizen","PowerState":"on","TokenAuthSupport":"true","VoiceSupport":"true","WallScreenRatio":"-1","WallService":"false","countryCode":"CA","description":"Samsung DTV RCR","developerIP":"0.0.0.0","developerMode":"0","duid":"uuid:e6b20cd8-719b-4225-81e2-897c3198068f","firmwareVersion":"Unknown","id":"uuid:e6b20cd8-719b-4225-81e2-897c3198068f","ip":"192.168.100.73","model":"21_NIKEM2_FRAME","modelName":"QN55LS03AAFXZC","name":"Samsung TV","networkType":"wired","resolution":"3840x2160","smartHubAgreement":"true","type":"Samsung SmartTV","udn":"uuid:e6b20cd8-719b-4225-81e2-897c3198068f","wifiMac":"10:2b:41:01:6d:27"},"id":"uuid:e6b20cd8-719b-4225-81e2-897c3198068f","isSupport":"{\"DMP_DRM_PLAYREADY\":\"false\",\"DMP_DRM_WIDEVINE\":\"false\",\"DMP_available\":\"true\",\"EDEN_available\":\"true\",\"FrameTVSupport\":\"true\",\"ImeSyncedSupport\":\"true\",\"TokenAuthSupport\":\"true\",\"remote_available\":\"true\",\"remote_fourDirections\":\"true\",\"remote_touchPad\":\"true\",\"remote_voiceControl\":\"true\"}\n","name":"Samsung TV","remote":"1.0","type":"Samsung SmartTV","uri":"http://192.168.100.73:8001/api/v2/","version":"2.0.25"}