Samsung Smart TV - No control?

The default Samsung TV component (and my custom extension) both turn my TV on fine. Maybe you’re referring to this?

KEY_POWER

  • turns the TV off but not on which is why I include my mac address for wake-on-lan.

My TV does not accept incoming network requests when it’s turned off which is why I can’t use KEY_POWER to turn it on.

Right I guess we have the same issue then. I even tried using the volume but it doesn’t work for me. However your component does detect when I turn my on or off from the remote.

@bachoo786 - Is there a reason you don’t want to use the wake-on-lan functionality provided by the Samsung-TV component?

@Drywcyfyr sorry how do I use that? Because with the Samsung component I can only determine the status of my tv and nothing else I can’t control it.

@bachoo786 - I guess it’s not guaranteed to work on all models but when I provide my TV’s mac address in its configuration, the samsungtv component will fire a wake-on-lan packet when I call the media_player.turn_on service.

media_player:

  • platform: samsungtv
    host: 192.168.178.XX
    port: 8001
    name: “TV2”
    mac: “xx:xx:xx:xx:xx”

I have the same configuration but it doesnt work for me, my tv is 2015 model.

However I have tried the openhab addon and works for me. I heard they use java which would need to be ported to python for it to work.

Hey, did you manage to get the commands to switch HDMI inputs?

1 Like

It is possible to set the HDMI input over UPnP. I don’t know if newer Samsung TVs has still the API, but on older TVs (2012, 2013) it was possible. The “MainTVAgent2” UPnP-service has the method “SetMainTVSource”. Also there are several other methods like “SetMainTVChannel”, “SetVolume”, “Play”, “Pause”, “Stop”, etc. I used gupnp-tools on Ubuntu to discover the services and play around with them.

I have Samsung 2011 ue40d6100sw is determined by HA but constantly shows that is turned off.

media_player:
  - platform: samsungtv
    host: 192.168.13.99
    mac: xx:xx:xx:xx:xx:xx
    port: 8001

Who can tell me what the problem is?

Please follow the thread here.

Thank you so much, my friend. Temporarily question decided to =)

How/where do I implement this code for KEY_“XX” sends?

I’m not sure where to add or find the custom_components/media_player/ folder.

Any insights would be appreciated!

EDIT

I think I’ve worked it out. The folders need to be created in /config.

I get “ms.channel.unauthorized” when connecting to Samsung TV UE55NU6035 and I haven’t been able to figure it out.

Here are the logs when pressing the on/off button in the UI:

2019-03-07 16:38:59 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.4552020656] {'event': 'ms.channel.unauthorized'}
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1155, in _execute_service
    await handler.func(service_call)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 278, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 292, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/samsungtv.py", line 214, in turn_off
    self.get_remote().close()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/samsungtv.py", line 138, in get_remote
    self._remote = self._remote_class(self._config)
  File "/Users/henrik/.homeassistant/deps/lib/python/site-packages/samsungctl/remote.py", line 11, in __init__
    self.remote = RemoteWebsocket(config)
  File "/Users/henrik/.homeassistant/deps/lib/python/site-packages/samsungctl/remote_websocket.py", line 30, in __init__
    self._read_response()
  File "/Users/he

Same problem on UE50MU6100. Running HA on HASSIO. He find the name of the device but can’t control the tv.

Failed to call service media_player/turn_off. {'event': 'ms.channel.unauthorized'}

I got this as well when pressing the on/off.

Samsung Tv Nu8000 (2018)

media_player:
  - platform: samsungtv
    host: xxx.xxx.xxx.xxx
    port: 8001
    name: Samsung TV
    timeout: 30
    mac: 64:1c:ae:11:14:d5
1 Like

After Update to 0.91.0 changing the Line 11 to

import homeassistant.components.samsungtv.media_player as stv

does the trick and the component is working again

greetings

where is the file where you changed?

In my setup this is the media_player.py file which is located in the custom_components/samsungtv_custom directory.

Hi,
I wonder what to do about the warnings I am getting that for all custom components all dependencies need to be included in the custom component. Which files should we move to the samsungtv_custom directory? How should the includes change in the media_player.py file which contains the samsungtv_custom code?

I tried this but not much luck. I do see the TV comes, but it takes like 3-5 minutes before that happens and when turning my tv off manually, HA doesn’t reflect that. I do also get errors when trying to set the Voume:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py”, line 122, in handle_call_service
connection.context(msg))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1138, in async_call
self._execute_service(handler, service_call))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1160, in _execute_service
await handler.func(service_call)
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py”, line 188, in handle_service
self._platforms.values(), func, call, service_name
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py”, line 314, in entity_service_call
future.result() # pop exception if have
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py”, line 330, in _handle_service_platform_call
await func(entity, data)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/init.py”, line 504, in set_volume_level
raise NotImplementedError()
NotImplementedErrorTraceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py”, line 122, in handle_call_service
connection.context(msg))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1138, in async_call
self._execute_service(handler, service_call))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1160, in _execute_service
await handler.func(service_call)
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py”, line 188, in handle_service
self._platforms.values(), func, call, service_name
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py”, line 314, in entity_service_call
future.result() # pop exception if have
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py”, line 330, in _handle_service_platform_call
await func(entity, data)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/init.py”, line 504, in set_volume_level
raise NotImplementedError()
NotImplementedError

How does your samsungtv.py fole look like?