Improving Samsung TV Control

@alex7614 There seem to be commands in the SmartThings API for channel up / down and changing channels, didn’t get to testing them yet though.

This has been working great for me, today I purchased a second Samsung tv however and It currently isn’t working for me.
Is it a matter of just copying the config.yaml and pasting below the original as per what I’ve done or am i doing it wrong?

media_player:
  - platform: samsungtv_tizen
    host: 192.168.*.***
    port: 8002
    mac: 'mymacid'
    app_list: '{"Netflix": "11101200001", "YouTube": "111299001912"}'
  - platform: samsungtv_tizen
    host: 192.168.*.***
    port: 8002
    mac: 'mymacid'
    app_list: '{"Netflix": "11101200001", "YouTube": "111299001912"}'

Further to this is there a way to rename the device from “samsung tv remote” to something else?
and lastly for now has anyone managed to find the app id for Stan?

Maybe stating the obvious… Have you changed the host IP and mac address for the new TV?

I switch my TV completely off through a shelly. So, the IP address of the TV is unreachable.
In the logs I end up having this error message every 10s:

2020-03-14 18:21:05 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    attr = self.capability_attributes
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 774, in capability_attributes
    source_list = self.source_list
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 370, in source_list
    self._gen_installed_app_list()
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 240, in _gen_installed_app_list
    app_list = self._remote.app_list()
  File "/config/custom_components/samsungtv_tizen/remote.py", line 179, in app_list
    self._ws_send(payload)
  File "/config/custom_components/samsungtv_tizen/remote.py", line 93, in _ws_send
    self.open()
  File "/config/custom_components/samsungtv_tizen/remote.py", line 108, in open
    sslopt=sslopt
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 514, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 223, in connect
    options.pop('socket', None))
  File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 120, in connect
    sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
  File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 189, in _open_socket
    raise error
  File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 172, in _open_socket
    sock.connect(address)
socket.timeout: timed out
2020-03-14 18:21:12 INFO (SyncWorker_6) [root] Sending key KEY
2020-03-14 18:21:15 INFO (MainThread) [root] Get app list
2020-03-14 18:21:15 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    attr = self.capability_attributes
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 774, in capability_attributes
    source_list = self.source_list
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 370, in source_list
    self._gen_installed_app_list()
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 240, in _gen_installed_app_list
    app_list = self._remote.app_list()
  File "/config/custom_components/samsungtv_tizen/remote.py", line 179, in app_list
    self._ws_send(payload)
  File "/config/custom_components/samsungtv_tizen/remote.py", line 93, in _ws_send
    self.open()
  File "/config/custom_components/samsungtv_tizen/remote.py", line 108, in open
    sslopt=sslopt
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 514, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 223, in connect
    options.pop('socket', None))
  File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 120, in connect
    sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
  File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 189, in _open_socket
    raise error
  File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 172, in _open_socket
    sock.connect(address)
OSError: [Errno 113] Host is unreachable

Is there a way to avoid this?
It is (kinda) cosmetic… however, avoiding this in the log file would be good. The important messages are flooded with those.
Thanks,
GV

haha, yeah should have stated that sorry.

both ip and mac dress have been modified to suit the new tv, I have since been able to get the tv to ask if its ok to allow access which i accepted but the tv still isn’t receiving commands

Sorry, I had to ask :slight_smile:
Have you tried to remove the working tv and have only the second in the config?
The documentation doesn’t say anything (as far as I can tell) about more than 1 TV…
GV

@greengolfer

Users mainly get that error if they didn’t set app_list manually for a TV.

@AJG

I’ve read that there are some models that use encrypted ws connections on port 8001 (instead of 8002), which might not work with this component’s ws logic yet.

@greengolfer I am using 2 TVs, it works with any number of TVs

It was just a guess… as there is no particular information in the doc

I don’t have this. I’ll try. Thanks for this answer.
GV

All sorted, it was just a lack of patience…

@greengolfer
There is self._gen_installed_app_list() in your error thread, if you look at these lines:

You will see that the only way that method is ever called is if app_list is not set at all, it is the only place that method is called in the entirety of the code. An error that has that method in it’s thread is 100% due to not setting app_list manually (and properly).

You are correct. I have now a small app_list (just netflix) and I do not have the error message any more!!
All good.
Maybe, one last question on the matter.
In the documentation, the list from “List2”, the formats of the app are like this bstjKvX6LM.molotov how to you include this in the app_list?
Thanks,
GV

@greengolfer
I just made a new release, here are the docs for the new app_list feature:

@alex7614
With the new version, I’ve added new SmartThings keys:
ST_CHUP, ST_CHDOWN, ST_CH1, ST_CH2, etc.

so you can do things like:

ST_TV+ST_CH100

and if you have a channel 100, it should turn to it. I also added the ability to combine normal KEY_ keys with ST_ keys, although I’m still not sure there’s a use for it.

Hi jaruba

Thanks all works fine !! It’s instant to switch to TV / Channel number and even from an other source or from an application !

PS : combine KEY_ and ST_ may be good for example when we want to switch to the Apple TV BOX ST_HDMI2 for direct switch and then go to click on the desired application by simulating KEY_

@chris669 srry, I forgot to mention that this component can also open browser pages now, see an example here:

Great! I’ve to reinstall it. After some investigating I concluded that the unwanted auto switch on was due to my Bluetooth remote. When no batteries in the remote, my TV stays off and never switch on by itself. Very strange…

thanks a lot, today I will try it

@amkochaki the latest version has better keys that can be used for this, changing to channel 404 (presuming channel 404 exists), you can just use ST_TV+ST_CH404

I cant get this working…

If I follow the standard configuration.yaml, what would be the default entity id name and how can I change that?