Improving Samsung TV Control

Great Custom componet.
How to add a second tv?

@raidptn You can add as many TVs as you want in the exact same way you added the first one. Here’s my config for my 2 TVs (I used XXX to censor sensitive data):

media_player:
  - platform: samsungtv_custom
    host: XXX
    name: Living Room TV
    mac: XXX
    port: 8002
    source_list: '{"TV":"KEY_SOURCE+KEY_LEFT+KEY_LEFT+KEY_ENTER","Manual":"KEY_SOURCE+KEY_LEFT+KEY_LEFT+KEY_RIGHT+KEY_RIGHT+KEY_ENTER","Chromecast":"KEY_SOURCE+KEY_LEFT+KEY_LEFT+KEY_RIGHT+KEY_ENTER"}'
    app_list: '{"Netflix": "11101200001", "YouTube": "111299001912", "Spotify": "3201606009684"}'
    update_method: "ping"
  - platform: samsungtv_custom
    host: XXX
    name: Bedroom TV
    mac: XXX
    port: 8002
    source_list: '{"TV":"KEY_SOURCE+KEY_DOWN+KEY_UP+KEY_LEFT+KEY_LEFT+KEY_ENTER","Manual":"KEY_SOURCE+KEY_DOWN+KEY_UP+KEY_LEFT+KEY_LEFT+KEY_RIGHT+KEY_ENTER","Chromecast":"KEY_SOURCE+KEY_DOWN+KEY_UP+KEY_LEFT+KEY_LEFT+KEY_RIGHT+KEY_RIGHT+KEY_ENTER"}'
    app_list: '{"Netflix": "11101200001", "YouTube": "111299001912", "Spotify": "3201606009684"}'
    update_method: "ping"
2 Likes

Hi

I added the

media_player:

  • platform: samsungtv_custom
    host: XXX
    name: Kitchen TV
    mac: XXX
    port: 8002
    source_list: ‘{“TV”:“KEY_HOME+KEY_RIGHT+KEY_RIGHT+KEY_ENTER”}’

But when i run Check Config or try to restart HASSIO i get source_list is an invalid option.

TIA

Are you sure that you’re using my component? There are 2 more components with the same name.

Yeah, downloaded via git link on your post. Wife’s using TV at the min but if I don’t add the source list it has auto detected the sources. Will try to see if they work and let you know :+1:

I’ve renamed this component to “SamsungTV Tizen” (renamed the github repository too to jaruba/ha-samsungtv-tizen).

I’ve released a new version that adds support for the SmartThings API, which is enabled by setting the api_key and device_id properties. SmartThings adds many benefits: see TV channel names, see which HDMI source is selected, improved on / off states, new keys: ST_TV , ST_HDMI1 , ST_HDMI2 , ST_HDMI3

I’ve also submitted this custom component to HACS, here is the PR:

5 Likes

Does this work with NU models? Specifically NU8000 - it has the Magic remote with only a handful of buttons. Thanks.

@Stooovie There is a good chance that it will work, but there’s only one way to find out… And it presumes trying it to see if it works. :slight_smile:

Yeah, it’s just the integration I use now (Samsung custom plus Alexa) is kinda fragile and I didn’t wanna disturb anything :wink: backups don’t always work as they should. I’ll try anyway.

@Stooovie I recommend u also set a value for the app_list property. Although this is optional, there have been users that got errors when not setting it.

okay thanks!

@jaruba
In my custom_component folder once the connexion with the TV is created there is an additional file : token-a.b.c.d.txt where a.b.c.d is the fixed IP address of the TV.
All good.
However, when I restart Home Assistant, the connexion to the TV won’t be reestablished until I delete that file which is then created again.
Is that normal?
Do you have the same behaviour?
Thanks,
GV

@greengolfer I can’t say I’ve experienced this, but I just came back from a 7 day trip, and have made some changes to the component before leaving.

I’ll make some tests in the next few days to see if I can reproduce this behavior.

Thanks for the quick answer.
I don’t yet use the “tizen” version but the one that was available early February.
What is the use of the (empty) token file?
GV

I just use the ESPHome which has IR connected, controls all the TVs :slight_smile: However, for various options, like changing sources, you need to exactly run the IR commands in sequence just like you would be pressing on Remote. But once you have setup, it works beautifully.

I am testing out the new HACS SamsungTV Tizen Component and it’s pretty buggy for me:

  • Source only works for “HDMI” and Apps (Google Assistant works for both of these as well)

  • Google Assistant doesn’t change change volume (up/down/mute) (UI works though)

  • If I configure the api_key and device_id, I get these errors in my log and I assume the SmartThings API inegration is not working then:

2020-02-23 13:58:38 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.samsung_tv_remote fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 260, in update
    smartthings.device_update(self)
    data = resp.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-02-23 13:58:48 INFO (SyncWorker_11) [root] Sending key KEY
2020-02-23 13:58:48 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.samsung_tv_remote fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 260, in update
    smartthings.device_update(self)
  File "/config/custom_components/samsungtv_tizen/smartthings.py", line 37, in device_update
    data = resp.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-02-23 13:58:59 INFO (SyncWorker_17) [root] Sending key KEY
2020-02-23 13:58:59 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.samsung_tv_remote fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
2020-02-23 13:59:10 INFO (SyncWorker_10) [root] Sending key KEY
2020-02-23 13:59:10 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.samsung_tv_remote fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 260, in update
    smartthings.device_update(self)
  File "/config/custom_components/samsungtv_tizen/smartthings.py", line 37, in device_update
    data = resp.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-02-23 13:59:21 INFO (SyncWorker_3) [root] Sending key KEY
2020-02-23 13:59:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.samsung_tv_remote fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Details on my 2016 Samsung TV (Tizen) are below:

{
"id": "<REDACTED>",
"name": "[TV] Living Room TV",
"version": "2.1.0",
"device": {
"type": "Samsung SmartTV",
"duid": "<REDACTED>",
"model": "16_JAZZL_UHD_BASIC",
"modelName": "UN55KU6290",
"description": "Samsung DTV RCR",
"networkType": "wireless",
"ssid": "<REDACTED>",
"ip": "<REDACTED>",
"firmwareVersion": "Unknown",
"name": "[TV] Living Room TV",
"id": "<REDACTED>",
"udn": "<REDACTED>",
"resolution": "3840x2160",
"countryCode": "US",
"msfVersion": "2.1.0",
"smartHubAgreement": "true",
"VoiceSupport": "false",
"GamePadSupport": "true",
"wifiMac": "<REDACTED>",
"developerMode": "1",
"developerIP": "...",
"OS": "Tizen"
},
"type": "Samsung SmartTV",
"uri": "http://<REDACTED>:8001/api/v2/",
"remote": "1.0",
"isSupport": "{\"remote_available\":\"true\",\"remote_fourDirections\":\"true\",\"remote_touchPad\":\"true\",\"remote_voiceControl\":\"false\",\"DMP_available\":\"true\",\"DMP_DRM_PLAYREADY\":\"false\",\"DMP_DRM_WIDEVINE\":\"false\",\"EDEN_available\":\"true\"}"
}

And for the SmartThings API setup, I do in fact have an API key and added my TV to the “Devices” but one things that could be of an issue is that I see it stated as “INACTIVE” and I had to get the device_id from the URI, doesn’t get listed in the device info:

So the SmartThings API issue was due to the API key, something must have changed over time to not allow me to use my existing key so I added a new one and I no longer have these errors.

However, plenty of issues still with this component, wish Google Assistant worked 100% with all of the functionality in the HA UI, still can’t get any of the audio commands working via Google Assistant and I also discovered that the source cannot be changed back to HDMI once in an app, it can only jump from app to app.

@greengolfer

I don’t yet use the “tizen” version but the one that was available early February.

I do not offer support for old versions of my component. Please update to the latest version if you wish to be assisted.

@manju-rn

I just use the ESPHome which has IR connected, controls all the TVs

I fail to see how this is in any way relevant to this discussion… IR blasters are a one way street, this component offers 1000x more features then just sending IR codes to a TV…

@nmajin

Source only works for “HDMI” and Apps (Google Assistant works for both of these as well)

You said you fixed the SmartThings API feature (which was due to an invalid token), so use the SmartThing Key Codes: ST_TV , ST_HDMI1 , ST_HDMI2 , ST_HDMI3 , etc.

Google Assistant doesn’t change change volume (up/down/mute) (UI works though)

Try saying “ok google, sync my devices”, then try the voice commands again. Do this 2-3 times to ensure it’s not a HA / Google Home sync issue that is causing this. I sometimes need to sync them a few times to get all TV features working for some reason.

Hi @jaruba,

I have installed your custom component to try to control HW-Q80R Soundbar. It’s running Tizen 4.1.10 and has support for Smartthings. After defining an empty app_list (app_list: '{}') it has finally appeared in HA, but I am not able to control it. All I can do is see current volume (but not control it) and turn soundbar off.

Are there any chances for a wider support?

@3_14

This is a component for Samsung TVs that use Tizen, it uses the WS API, UPnP and SmartThings. It sounds like the only thing that your Soundbar supports from this stack is SmartThings.

The SmartThings integration is not used everywhere, as in many scenarios the local APIs will be much faster then the cloud API.

Also, the SmartThings API integration of this component is based off of the work of a contributor of this component, you can find his own component that is fully SmartThings linked in this comment:

It should work better for ur case.