home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.66k stars 28.82k forks source link

Samsung PIN-based TV intergration (UE32J5200AK) #117694

Open Ferbez opened 1 month ago

Ferbez commented 1 month ago

The problem

Samsung TV integration mentions J-series support, though my UE32J5200AK doesn't really work - it just fails to connect. I tried to play around myself, and had partial success - through port 8080.

Commands like curl -X GET -i http://192.168.1.X:8080/ws/apps/YouTube gave me info about YouTube app, curl -X GET -i http://192.168.1.X:8080/ws/apps/YouTube/install opened SmartHub page with installation and most importantly - curl -X GET -i http://192.168.1.X:8080/ws/pairing\?step\=$\{step\}\&app_id\=$\{this._config.appId\}\&device_id\=$\{this._config.deviceId\} made PIN appear on TV screen. Is it possible to use Samsung TV integration on this TV?

What version of Home Assistant Core has the issue?

core-2024.5.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Samsung Smart TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/samsungtv

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @chemelli74, @epenet, mind taking a look at this issue as it has been labeled with an integration (samsungtv) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `samsungtv` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign samsungtv` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


samsungtv documentation samsungtv source (message by IssueLinks)

chemelli74 commented 1 month ago

Hi @Ferbez, can you show us the issue and the log when it fails with the integration?

Ferbez commented 1 month ago

It doesn't discover my TV automatically and when I try to manually setup integration via IP it just says "failed to connect". Samsung TV-related logs:

x_homeassistant_matching_domains={'samsungtv'})
2024-05-19 21:48:51.347 DEBUG (MainThread) [homeassistant.components.ssdp] Discovered samsungtv at http://192.168.1.X:7676/smp_11_
x_homeassistant_matching_domains={'samsungtv'})
2024-05-19 21:48:51.352 DEBUG (MainThread) [homeassistant.components.ssdp] Discovered samsungtv at http://192.168.1.X:7676/smp_3_
2024-05-19 21:49:27.664 INFO (SyncWorker_7) [homeassistant.loader] Loaded samsungtv from homeassistant.components.samsungtv
2024-05-19 21:49:37.541 DEBUG (MainThread) [homeassistant.loader] Importing platforms for samsungtv executor=['config_flow'] loop=[] took 9.71s
2024-05-19 21:49:37.542 DEBUG (MainThread) [homeassistant.components.samsungtv] Samsung device found via SSDP: SsdpServiceInfo(ssdp_usn='uuid:17d78401-0090-1000-a055-f877b82db53e::urn:schemas-upnp-org:service:RenderingControl:1', ssdp_st='urn:schemas-upnp-org:service:RenderingControl:1', upnp={'deviceType': 'urn:schemas-upnp-org:device:MediaRenderer:1', 'X_compatibleId': 'MS_DigitalMediaDeviceClass_DMR_V001', 'X_deviceCategory': 'Display.TV.LCD Multimedia.DMR', 'X_DLNADOC': 'DMR-1.50', 'friendlyName': '[TV] Samsung', 'manufacturer': 'Samsung Electronics', 'manufacturerURL': 'http://www.samsung.com/sec', 'modelDescription': 'Samsung TV DMR', 'modelName': 'UE32J5200', 'modelNumber': 'AllShare1.0', 'modelURL': 'http://www.samsung.com/sec', 'serialNumber': '20110517DMR', 'UDN': 'uuid:17d78401-0090-1000-a055-f877b82db53e', 'deviceID': 'H3CBBEJV772NS', 'iconList': {'icon': [{'mimetype': 'image/jpeg', 'width': '48', 'height': '48', 'depth': '24', 'url': '/dmr/icon_SML.jpg'}, {'mimetype': 'image/jpeg', 'width': '120', 'height': '120', 'depth': '24', 'url': '/dmr/icon_LRG.jpg'}, {'mimetype': 'image/png', 'width': '48', 'height': '48', 'depth': '24', 'url': '/dmr/icon_SML.png'}, {'mimetype': 'image/png', 'width': '120', 'height': '120', 'depth': '24', 'url': '/dmr/icon_LRG.png'}]}, 'serviceList': {'service': [{'serviceType': 'urn:schemas-upnp-org:service:RenderingControl:1', 'serviceId': 'urn:upnp-org:serviceId:RenderingControl', 'controlURL': '/smp_13_', 'eventSubURL': '/smp_14_', 'SCPDURL': '/smp_12_'}, {'serviceType': 'urn:schemas-upnp-org:service:ConnectionManager:1', 'serviceId': 'urn:upnp-org:serviceId:ConnectionManager', 'controlURL': '/smp_16_', 'eventSubURL': '/smp_17_', 'SCPDURL': '/smp_15_'}, {'serviceType': 'urn:schemas-upnp-org:service:AVTransport:1', 'serviceId': 'urn:upnp-org:serviceId:AVTransport', 'controlURL': '/smp_19_', 'eventSubURL': '/smp_20_', 'SCPDURL': '/smp_18_'}]}, 'ProductCap': 'Y2014,WebURIPlayable,SeekTRACK_NR,NavigateInPause,ScreenMirroringP2PMAC=16:bb:6e:10:b9:72', 'X_hardwareId': 'VEN_0105&DEV_VD0001'}, ssdp_location='http://192.168.1.X:7676/smp_11_', ssdp_nt=None, ssdp_udn='uuid:17d78401-0090-1000-a055-f877b82db53e', ssdp_ext='', ssdp_server='SHP, UPnP/1.0, Samsung UPnP SDK/1.0', ssdp_headers={'CACHE-CONTROL': 'max-age=1800', 'Date': 'Thu, 01 Jan 1970 03:31:33 GMT', 'EXT': '', 'LOCATION': 'http://192.168.1.X:7676/smp_11_', 'SERVER': 'SHP, UPnP/1.0, Samsung UPnP SDK/1.0', 'ST': 'urn:schemas-upnp-org:service:RenderingControl:1', 'USN': 'uuid:17d78401-0090-1000-a055-f877b82db53e::urn:schemas-upnp-org:service:RenderingControl:1', 'Content-Length': '0', '_host': '192.168.1.X', '_udn': 'uuid:17d78401-0090-1000-a055-f877b82db53e', '_location_original': 'http://192.168.1.X:7676/smp_11_', 'location': 'http://192.168.1.X:7676/smp_11_', '_timestamp': datetime.datetime(2024, 5, 19, 21, 48, 48, 117894), '_remote_addr': ('192.168.1.X', 55086), '_port': 55086, '_local_addr': ('0.0.0.0', 0), '_source': <SsdpSource.SEARCH: 'search'>}, ssdp_all_locations={'http://192.168.1.X:7676/smp_11_'}, x_homeassistant_matching_domains={'samsungtv'})
2024-05-19 21:49:37.548 DEBUG (MainThread) [homeassistant.components.samsungtv] Set SSDP RenderingControl location to: http://192.168.1.X:7676/smp_11_
2024-05-19 21:49:37.549 DEBUG (MainThread) [samsungtvws.async_rest] Get device info via rest api
2024-05-19 21:49:37.725 DEBUG (MainThread) [homeassistant.components.samsungtv] Samsung device found via SSDP: SsdpServiceInfo(ssdp_usn='uuid:09896800-00a0-1000-adfd-f877b82db53e::urn:samsung.com:device:RemoteControlReceiver:1', ssdp_st='urn:samsung.com:device:RemoteControlReceiver:1', upnp={'deviceType': 'urn:samsung.com:device:RemoteControlReceiver:1', 'friendlyName': '[TV] Samsung', 'manufacturer': 'Samsung Electronics', 'manufacturerURL': 'http://www.samsung.com/sec', 'modelDescription': 'Samsung TV RCR', 'modelName': 'UE32J5200', 'modelNumber': '1.0', 'modelURL': 'http://www.samsung.com/sec', 'serialNumber': '20090804RCR', 'UDN': 'uuid:09896800-00a0-1000-adfd-f877b82db53e', 'deviceID': 'H3CBBEJV772NS', 'ProductCap': 'Resolution:1920X1080,ImageZoom,ImageRotate,Y2014,ENCP,Y2015', 'serviceList': {'service': {'serviceType': 'urn:samsung.com:service:MultiScreenService:1', 'serviceId': 'urn:samsung.com:serviceId:MultiScreenService', 'controlURL': '/smp_5_', 'eventSubURL': '/smp_6_', 'SCPDURL': '/smp_4_'}}, 'Capabilities': {'Capability': {'@name': 'samsung:multiscreen:1', '@port': '8001', '@location': '/ms/1.0/'}}}, ssdp_location='http://192.168.1.X:7676/smp_3_', ssdp_nt=None, ssdp_udn='uuid:09896800-00a0-1000-adfd-f877b82db53e', ssdp_ext='', ssdp_server='SHP, UPnP/1.0, Samsung UPnP SDK/1.0', ssdp_headers={'CACHE-CONTROL': 'max-age=1800', 'Date': 'Thu, 01 Jan 1970 03:31:33 GMT', 'EXT': '', 'LOCATION': 'http://192.168.1.X:7676/smp_3_', 'SERVER': 'SHP, UPnP/1.0, Samsung UPnP SDK/1.0', 'ST': 'urn:samsung.com:device:RemoteControlReceiver:1', 'USN': 'uuid:09896800-00a0-1000-adfd-f877b82db53e::urn:samsung.com:device:RemoteControlReceiver:1', 'Content-Length': '0', '_host': '192.168.1.X', '_udn': 'uuid:09896800-00a0-1000-adfd-f877b82db53e', '_location_original': 'http://192.168.1.X:7676/smp_3_', 'location': 'http://192.168.1.X:7676/smp_3_', '_timestamp': datetime.datetime(2024, 5, 19, 21, 48, 48, 138490), '_remote_addr': ('192.168.1.X', 54561), '_port': 54561, '_local_addr': ('0.0.0.0', 0), '_source': <SsdpSource.SEARCH: 'search'>}, ssdp_all_locations={'http://192.168.1.X:7676/smp_3_'}, x_homeassistant_matching_domains={'samsungtv'})
2024-05-19 21:49:37.726 DEBUG (MainThread) [samsungtvws.async_rest] Get device info via rest api
2024-05-19 21:49:38.634 DEBUG (MainThread) [samsungtvws.async_rest] Get device info via rest api
2024-05-19 21:49:38.641 DEBUG (MainThread) [samsungtvws.async_rest] Get device info via rest api
2024-05-19 21:49:38.649 DEBUG (SyncWorker_2) [homeassistant.components.samsungtv] Try config: {'name': 'HomeAssistant', 'description': 'HomeAssistant', 'id': 'ha.component.samsung', 'host': '192.168.1.X', 'method': 'legacy', 'port': None, 'timeout': 31}
2024-05-19 21:49:38.653 DEBUG (SyncWorker_1) [homeassistant.components.samsungtv] Try config: {'name': 'HomeAssistant', 'description': 'HomeAssistant', 'id': 'ha.component.samsung', 'host': '192.168.1.X', 'method': 'legacy', 'port': None, 'timeout': 31}
2024-05-19 21:49:38.657 DEBUG (SyncWorker_2) [homeassistant.components.samsungtv] Failing config: {'name': 'HomeAssistant', 'description': 'HomeAssistant', 'id': 'ha.component.samsung', 'host': '192.168.1.X', 'method': 'legacy', 'port': None, 'timeout': 31}, error: [Errno 111] Connection refused
2024-05-19 21:49:38.660 DEBUG (SyncWorker_1) [homeassistant.components.samsungtv] Failing config: {'name': 'HomeAssistant', 'description': 'HomeAssistant', 'id': 'ha.component.samsung', 'host': '192.168.1.X', 'method': 'legacy', 'port': None, 'timeout': 31}, error: [Errno 111] Connection refused
2024-05-19 21:49:38.665 DEBUG (MainThread) [homeassistant.components.samsungtv] Host:192.168.1.X did not return device info
2024-05-19 21:49:38.666 DEBUG (MainThread) [homeassistant.components.samsungtv] Host:192.168.1.X did not return device info

Should I attach full log file?

Ferbez commented 1 month ago

http://192.168.1.X:7676/smp_4_ gives something interesting:

<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<actionList>
<action>
<name>SendKeyCode</name>
<argumentList>
<argument>
<name>KeyCode</name>
<direction>in</direction>
<relatedStateVariable>A_ARG_TYPE_KeyCode</relatedStateVariable>
</argument>
<argument>
<name>KeyDescription</name>
<direction>in</direction>
<relatedStateVariable>A_ARG_TYPE_KeyDescription</relatedStateVariable>
</argument>
</argumentList>
</action>
</actionList>
<serviceStateTable>
<stateVariable sendEvents="no">
<name>A_ARG_TYPE_KeyCode</name>
<dataType>ui4</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>A_ARG_TYPE_KeyDescription</name>
<dataType>string</dataType>
</stateVariable>
</serviceStateTable>
</scpd>
epenet commented 1 month ago

Port 7676 is for UPNP, and is only used AFTER the config entry is successful. For now this port can be ignored.

"UE32J5200AK" is a "J" model, and according to the documentation:

H and J models Some televisions from the H and J series use an encrypted protocol and require manual pairing with the TV. This should be detected automatically when attempting to send commands using the WebSocket connection, and trigger the corresponding authentication flow.

So you should be able to connect using the "legacy" mode. Did you enable logging for samsungctl package or only homeassistant.components.samsungtv?

Ferbez commented 1 month ago

I enabled both samsungctl and homeassistant.components.samsungtv - there's no log entries for samsungctl in log. I even tried to enable debug logging for everything and searched through log - still no samsungctl entries. Looks like this TV just rejects connection - which port is used for configuration?

epenet commented 1 month ago

I don't have an H/J model to test with - so I'm not sure exactly how I can replicate your issue :(