Samsung TV Binding (Beta)

Thanks for the capture, I can see the SSDP NOTIFY messages, but I don’t see a MediaRenderer notification (the binding uses the MediaRenderer alive notification to trigger Online status).

Can you run netcat -ukl 1900
Then turn your tv on and off a couple of times.

You should see NOTIFY messages. The ones we are looking for have NT urn:schemas-upnp-org:device:MediaRenderer:1 and NTS ssdp:alive in them (LOCATION your tv ip).

Can you post these notify messages.

Also, what do you get back from http://192.168.2.10:9197/dmr

HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
DATE: Sun, 30 Jan 2022 17:28:32 GMT
LOCATION: http://192.168.2.10:9197/dmr
NT: urn:schemas-upnp-org:device:MediaRenderer:1
NTS: ssdp:alive
SERVER: SHP, UPnP/1.0, Samsung UPnP SDK/1.0
USN: uuid:2fcbf741-f7a9-4041-bfc5-a08e4b09cd66::urn:schemas-upnp-org:device:MediaRenderer:1
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11" xmlns:df="http://schemas.microsoft.com/windows/2008/09/devicefoundation" xmlns:sec="http://www.sec.co.kr/dlna">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
<pnpx:X_compatibleId>MS_DigitalMediaDeviceClass_DMR_V001</pnpx:X_compatibleId>
<df:X_deviceCategory>Display.TV.LCD Multimedia.DMR</df:X_deviceCategory>
<dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
<friendlyName>[TV] Samsung Q7 Series (55)</friendlyName>
<manufacturer>Samsung Electronics</manufacturer>
<manufacturerURL>http://www.samsung.com/sec</manufacturerURL>
<modelDescription>Samsung TV DMR</modelDescription>
<modelName>QE55Q7FNA</modelName>
<modelNumber>AllShare1.0</modelNumber>
<modelURL>http://www.samsung.com/sec</modelURL>
<serialNumber>0BZJ3LMK400241H</serialNumber>
<UDN>uuid:2fcbf741-f7a9-4041-bfc5-a08e4b09cd66</UDN>
<iconList>
<icon>
<mimetype>image/jpeg</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/icon_SML.jpg</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/icon_LRG.jpg</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/icon_SML.png</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/icon_LRG.png</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
<serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
<controlURL>/upnp/control/RenderingControl1</controlURL>
<eventSubURL>/upnp/event/RenderingControl1</eventSubURL>
<SCPDURL>/RenderingControl_1.xml</SCPDURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
<controlURL>/upnp/control/ConnectionManager1</controlURL>
<eventSubURL>/upnp/event/ConnectionManager1</eventSubURL>
<SCPDURL>/ConnectionManager_1.xml</SCPDURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
<serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
<controlURL>/upnp/control/AVTransport1</controlURL>
<eventSubURL>/upnp/event/AVTransport1</eventSubURL>
<SCPDURL>/AVTransport_1.xml</SCPDURL>
</service>
</serviceList>
<sec:ProductCap>Tizen,Y2018,WebURIPlayable,NavigateInPause,ScreenMirroringP2PMAC=66:1c:b0:13:e8:e7,UHD_SCREEN,SerialNumber=0BZJ3LMK400241H,vdProductType=TV,OCF=1</sec:ProductCap>
<pnpx:X_hardwareId>VEN_0105&DEV_VD0001</pnpx:X_hardwareId>
</device>
</root>

@11194
And this is from within your docker container? because if so, there is no reason why the binding should not work.

Or is this from the Debian host?

Well the same result from containers console. Maybe something missing in docker install, or that’s all because of missing powerState?

@11194
powerState is only really used for Frame TV’s. It shouldn’t make any difference to the initial UPnP discovery (which is not happening).

If you can share your docker yaml file or startup script, I’ll try creating an OH docker container tomorrow, and see what I get.

Did you create your own container, or download a packaged one? Just so I can follow the same process.

Just fyi, I’m running OH in a Proxmox VM, but I’ve never tried it in a docker container.

Well, it’s totally standard: https://hub.docker.com/r/openhab/openhab/

Hello,

Nice work, the legacy binding was just showing me info, and not letting me set things.
This one allows me to manage power, mute, volume (at least)
I have removed source, channel,… (don’t want to poll Samsung cloud if I well understood).

BTW, I have a smart monitor M7 (model":“20_KANTSU2_UHD_MNT”,“modelName”:“LS32AM700URXEN”)

Do you know if Samsung still let a webservice to send a message to the screen like with old smart TV of 2006 ? (samsung messagebox service)
I would like to use this in order to send somekind of broadcasted notification on all the house devices.

Thanks

Not as far as I know.

The Samsung cloud is not polled if you don’t enter a PAT (api key), even if the Channels are linked.

ok, as the channels were not updated, I’ve removed them.

BTW, the message box system was something like that:

Hi, I wrote about my Samsung QN91AA 65 TV in the comment of the GitHub pull request openhab/openhab-addons #11895.

What can I do to help debugging and having the TV connected?
It would be great if I don’t have to use the SmartThings app anymore :slightly_smiling_face:

@11194

So I created a basic Debian 11.2 VM, installed Docker, and started openhab (3.2.0). I did create the user openhab first.

Added the required feature:install openhab-transport-upnp and dropped my samsungtv binding into the addons folder (directly from the marketplace link).

Watching the logs, everything works normally, on both my old Samsung TV (2012), and my new Samsung TV (2021).

Here is the log from the openhab instance running in the docker container on my Debian 11.2 VM:

2022-01-31 15:46:07.303 [DEBUG] [tv.internal.handler.SamsungTvHandler] - 192.168.100.73: TV is Offline
...
... Turn TV on
...
2022-01-31 15:46:32.050 [DEBUG] [tv.internal.handler.SamsungTvHandler] - 192.168.100.73: remoteDeviceAdded: MediaRenderer, http://192.168.100.73:9197/dmr, upnpUDN=ea645e34-d3dd-4b9b-a246-e2947f8973d6
2022-01-31 15:46:32.050 [DEBUG] [covery.SamsungTvDiscoveryParticipant] - Retrieved Thing UID for a Samsung TV 'Samsung TV' model 'QN55LS03AAFXZC' thing with UDN 'ea645e34-d3dd-4b9b-a246-e2947f8973d6'
2022-01-31 15:46:32.050 [DEBUG] [tv.internal.handler.SamsungTvHandler] - 192.168.100.73: Check and create missing services
2022-01-31 15:46:32.050 [DEBUG] [covery.SamsungTvDiscoveryParticipant] - Created a DiscoveryResult for device 'QN55LS03AAFXZC' with UDN 'ea645e34-d3dd-4b9b-a246-e2947f8973d6' and properties: {hostName=192.168.100.73}
2022-01-31 15:46:32.050 [DEBUG] [nternal.service.MediaRendererService] - 192.168.100.73: Creating a Samsung TV MediaRenderer service
2022-01-31 15:46:32.051 [DEBUG] [tv.internal.handler.SamsungTvHandler] - 192.168.100.73: Started service for: QN55LS03AAFXZC, MediaRenderer (ea645e34-d3dd-4b9b-a246-e2947f8973d6)
2022-01-31 15:46:32.051 [DEBUG] [rnal.service.RemoteControllerService] - 192.168.100.73: Creating a Samsung TV RemoteController service: is UPNP:false
2022-01-31 15:46:32.056 [TRACE] [l.protocol.RemoteControllerWebSocket] - 192.168.100.73: openConnection()
2022-01-31 15:46:32.056 [DEBUG] [l.protocol.RemoteControllerWebSocket] - 192.168.100.73: RemoteControllerWebSocket start Client
2022-01-31 15:46:32.057 [TRACE] [l.protocol.RemoteControllerWebSocket] - 192.168.100.73: WebSocketClient starting
2022-01-31 15:46:32.063 [TRACE] [l.protocol.RemoteControllerWebSocket] - 192.168.100.73: WebSocketClient started
2022-01-31 15:46:32.063 [TRACE] [l.protocol.RemoteControllerWebSocket] - 192.168.100.73: connectWebSockets()
2022-01-31 15:46:32.064 [DEBUG] [ngtv.internal.protocol.WebSocketBase] - 192.168.100.73: WebSocketRemote connecting to: wss://192.168.100.73:8002/api/v2/channels/samsung.remote.control?name=b3BlbkhBQg==&token=15829348
... normal startup

I did have to accept the remote connection on the TV, otherwise commands to change volume/power etc don’t work, but that’s normal.

I didn’t have to do anything else. The TV’s were auto discovered, appeared in the inbox (without having to search), and when added, configured themselves properly. I had to accept the pop-up message on the TV, and link some channels to test volume/power/mute etc. But everything just worked. I turned the TV on and off several times, but still with no issues.

This is my docker run script:

docker run \
  --name openhab \
  --net=host \
  -v /etc/localtime:/etc/localtime:ro \
  -v /etc/timezone:/etc/timezone:ro \
  -v /opt/openhab/addons:/openhab/addons \
  -v /opt/openhab/conf:/openhab/conf \
  -v /opt/openhab/userdata:/openhab/userdata \
  -e "EXTRA_JAVA_OPTS=-Duser.timezone=America/Toronto" \
  -d \
  --restart=always \
  openhab/openhab

this is from the OH console list command:

238 │ Active │  80 │ 2.6.0                 │ JUPnP Library
239 │ Active │  80 │ 3.2.0                 │ openHAB Core :: Bundles :: Configuration UPnP Discovery
240 │ Active │  80 │ 3.2.0                 │ openHAB Core :: Bundles :: UPnP Transport
241 │ Active │  80 │ 3.3.0.202201061617    │ openHAB Add-ons :: Bundles :: SamsungTV Binding

So unfortunately this sheds no light on the problems you are seeing. It must be something specific to your configuration.

What other bindings do you have installed? any unusual configurations?

@pleky

Just because the channels aren’t updated, doesn’t mean you can’t use them (well the Channel channel can be used). You can send a number to the Channel channel, and it will change the TV channel, you just can’t read the current TV channel without polling the Smartthings API.

Not too many people use this feature anyway, just clarifying that reading and writing a channel are two different things.

1 Like

@mmat

With the original binding it does connect. But the Thing is reported as Offline and there are problems with the channels - the only channel that worked for me was mute.

This problem right?

The first thing to understand is that not all channels work for all TV’s. Usually you can get Power, Mute and Volume to work. Some old TV’s will not turn On though, only Off.

On all TV’s you have to accept the pop-up that appears on the TV about 30 seconds after you turn the TV on asking for permission for the device OpenHAB to connect. Do NOT change the binding configuration unless you know what you are doing, picking random protocols and port number generally doesn’t help.

Can you give me the output of http://ip_address:8001/api/v2/ where ip_address is the ip of your TV.

A TRACE level capture of your logs for the samsungtv binding would be helpful also. I need 30 seconds of logs from before you turn the TV on to 30 seconds after you turn the TV on (using the remote control). Read the documentation if you don’t know how to do this (read it anyway…).

I’ll do what I can to help.

@Nicholas_Waterton,

I’m finally getting around to working with your binding v1.07 and my TV’s. I only use the power on/off feature for my rules.

All my TV’s are defined in a .thing file.

My two port 8002 TV’s work grabbing the token then putting it in the .thing file

My three port 8001 TV’s doesn’t give me a prompt/token option. I do see the TV Thing going online/offline with power status though. What should I try to get the power item to work with them next?

My port 55000 TV only powers off, not on. I understand this TV is too old to address it.

Great job on this binding, you have done a TON of work to address so many variables.

Best, Jay

@jwiseman

Thanks, Jay.

As far as I understand it, the TV’s that use port 8001 do not use the secure token method. They should prompt you to accept the remote connection though, regardless.

Normally, when you turn the TV on, the binding will detect the TV via UPNP (hence it goes ONLINE), and attempt to connect to the remote control websocket on port 8001. The TV should at this point prompt you to accept the remote connection (you have 30 seconds to accept). If accepted, the TV will remember the combination of ip address and “name” (openHAB) and allow the websocket to connect. If the TV supports “secureToken”, it is at this point it returns the token. Not all TV’s return a token (in which case you leave the “webSocketToken” blank (or leave it out altogether). The port and websocket type have nothing to do with whether a token is used or not, except if the TV does use tokens, you have to use port 8002 (not 8001). if it doesn’t you can use either port.

When the TV turns off, the binding detects this (via UPNP) and puts the Thing OFFLINE.

First thing to do is check your TV under “External Device Manager”, there should be an entry somewhere that lists devices, and you should be able to see if there is an entry for openHAB, and whether it is "allowed’ or “denied”.

The other thing is an entry for whether the TV prompts you to allow external devices. This should be “First time only”, if it’s disabled, it won’t prompt you, and you can’t connect. There is another setting on the TV that you need to set called something like “allow remote IP control” which also has to be enabled.

I can’t remember if you have given me the output before, but can you post the results of http://ip_address:8001/api/v2/ so I can see what is supported on your 8001 port TV’s?

Could you post a TRACE log of you turning the TV On, so I can confirm the remoteControl is attempting to connect?

To turn the TV ON, the TV has to have WOL enabled, there is a setting on the TV for this also, it’s something like “allow IP power on”. Turning the TV on from your power item should work, as it just sends WOL packets to the mac address of your TV. I don’t know if all TV’s support WOL over WiFi though.

Thanks.

I looked all over for these options to enable on these three 8001 TV’s but couldn’t find anything like that.

The URL doesn’t work either for 8001 or 8002.

http://192.168.0.142:8001/api/v2/

The three TV’s are all WiFi so that may be the issue at hand also?

No worries, Jay

@jwiseman

Do you know what model or year these TV’s are? If the URL doesn’t work, they may not be Tizen TV’s.

This is odd though, as the way the binding decides on port 8001 or 8002 (and the websocket protocol) is by reading that URL, and reading the OS value as “Tizen”. If it doesn’t read that value, the TV is a “Legacy” TV, and the binding tries various other ports using the legacy protocol.

On your Pi 4, can you run:

sudo nmap -sT -p- 192.168.0.142

With your 192.168.0.142 TV on. This will scan the ports on that TV, and should give a list of the open ports. This will help identify which port your TV is using for remote control.

You may have to install nmap first with

sudo apt install nmap

If it’s not installed on your Pi.

WiFi shouldn’t be an issue, other than for possibly turning the TV On.

Here’s my output on this TV that is currently OFF. It probably is a Tizen TV. Not by the TV to grab the model/year right now.

[09:43:41] root@openhabian:~# sudo nmap -sT -p- 192.168.0.142
Starting Nmap 7.70 ( https://nmap.org ) at 2022-02-04 09:43 CST
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 0.76 seconds

Here’s the output on a TV that is ON and is working with port 8002 to insure nMap is working.

[09:44:22] root@openhabian:~# sudo nmap -sT -p- 192.168.0.128
Starting Nmap 7.70 ( https://nmap.org ) at 2022-02-04 09:46 CST
Nmap scan report for 192.168.0.128
Host is up (0.00042s latency).
Not shown: 65517 closed ports
PORT STATE SERVICE
1515/tcp open ifor-protocol
7676/tcp open imqbrokerd
7678/tcp open unknown
8001/tcp open vcom-tunnel
8002/tcp open teradataordbms
8080/tcp open http-proxy
8187/tcp open unknown
9110/tcp open unknown
9119/tcp open mxit
9197/tcp open unknown
15500/tcp open unknown
32768/tcp open filenet-tms
32769/tcp open filenet-rpc
32770/tcp open sometimes-rpc3
32771/tcp open sometimes-rpc5
34037/tcp open unknown
40942/tcp open unknown
56022/tcp open unknown
MAC Address: 9C:8C:6E:69:B6:FE (Samsung Electronics)
Nmap done: 1 IP address (1 host up) scanned in 5.08 seconds

Best, Jay

Here’s the output with the TV ON now.

[09:49:41] root@openhabian:~# sudo nmap -sT -p- 192.168.0.142
Starting Nmap 7.70 ( https://nmap.org ) at 2022-02-04 09:49 CST
Nmap scan report for 192.168.0.142
Host is up (0.062s latency).
Not shown: 65534 closed ports
PORT STATE SERVICE
7676/tcp open imqbrokerd
MAC Address: 40:16:3B:22:AF:96 (Samsung Electronics)
Nmap done: 1 IP address (1 host up) scanned in 13.76 seconds

Best, Jay

Thanks,

So the only port that is open is port 7676, which is the UPNP port. So it’s definitely not using port 8001, or the websocket protocol.

can you give me the output of the following:

http://192.168.0.142:7676/smp_18_

and

http://192.168.0.142:7676/smp_10_

With the TV on. That will give me the UPNP information, if you get any output, UPNP is a bit finnicky sometimes.

I don’t check port 7676 for remote control, as I know that is the UPNP port for some older TV’s, and usually those TV’s have another open port, specifically for remote IP control. There is a way to get control of TV’s with only UPNP ports (the RemoteControllerReceiver service on snmp_2_), but it’s not implemented, as I’ve never found a TV that didn’t have a dedicated IP control port before.

if you could give me a TRACE log as well for the samsungtv binding, I can see what services are detected.

Sorry to keep asking you for stuff, but this is an unusual TV.