Samsung Smart TV - No control?

Hi, Trying to get some control on my samsung TV

Its a US60H7000 and connected via ethernet to my network.

HA detects it, and can detect its on/off states OK however none of the buttons work, media, volume or power?

Here is my config
#Lounge TV

  • platform: samsungtv
    host: 192.168.100.16
    port: 8001
    name: Lounge Room TV
    mac: “redacted”lrtv
3 Likes

ever get anywhere with this? i have the exact same thing with 3 samsung tvs

1 Like

I have mine connected and the volume and power off are working but there doesn’t seem to be much control besides that. Using anymote on an android tablet gives me complete control over the network so it is possible to do quite a lot, like change channels etc… but the Samsung TV component in home assistant is pretty basic.

I’d really love to have full control through home assistant. Is anybody aware of a way to send commands to the TV that aren’t available in the UI?

I’d rather not go down the IR blaster route as it seems unreliable and requires extra hardware.

1 Like

I second this. I am using the homebridge and Alexa components and right now I could say, “Alexa, turn on/off TV” and “Siri, turn on/off tv”, which is very nice. But this is all I can do.

I would almost like to replace Home Assistant’s TV module with my own that provides more functionality like muting, voluming, etc. so I can use voice control for this.

If anyone has any feedback on how to do this please let us know.

@Cain and @nmajin I ran into the same issue, but using the library called samsungctl on which the Home Assistant component is based on I can do a lot more.

This is the library: https://github.com/Ape/samsungctl.

I’m not sure how to implement the other features yet, but I’m thinking of creating a custom Samsung component with more features.

I btw used that library directly from the command line with commands like the following:

samsungctl --host <host> --port 8001 --method websocket KEY_HOME

The above opens the Smart Hub functionality on my Samsung TV.

3 Likes

Yea this library is great and I can control everything I need to using it. I thought HA was using this but maybe not?

I looked into a custom component as well, but not really clear on how to extend the media player component for it, seemed a little more involved than I thought.

Thanks @thmry. I did find this library while searching for a way to have better control but left the idea on the back burner for a while as I didn’t want to mess around too much with the docker image (would make updates a pain). It’s interesting that this library is already what is being used in HA, it must already be in the container which means I should be able to call it from a command line switch :).

@nmajin and @Cain Yeah, the library I mentioned is already being used by Home Assistant.

I was about to say that the version that is included by Home Assistant is 0.6.0 and that the actual library is already at version 0.7.1, but I just noticed that the version in Home Assistant has been updated to the latest version 7 days ago. So, there’s no problem there anymore.

As you can see on this page you can go to the source (top right; it’s this link). That page shows the Samsung component and it basically only has the commands available that any other media player also has, so no option to open the Hub or switch source, but we could use the send_key method to call one of the other keys (like KEY_HOME) which are available in the library.

I haven’t made a custom component before, so I’m just looking into this and I’m also not sure how to even call the send_key method from the Samsung component, but it seems possible. I might play around with this later this week.

Hello,

Have someone being able to control F6300 successfully?

I can’t make it to turn on ( I have the correct tv mac there)

Also, great community and kudos for all you doing some development.

Cheers,

I don’t know if anyone is watching this thread but I came across it last night and it motivated me to dig into the home assistant code to write a custom component on top of samsungtv to give me access to the “send_key” functionality that I think @thmry was alluding to.

The service is called media_player.send_key and the service data looks like this:

{
  "entity_id": "media_player.samsung_tv",
  "key_code": "KEY_HOME"
}

You need to add the custom component to configuration.yaml the same way you would with a samsungtv.
BE WARNED!
This component essentially replaces samsungtv. I wouldn’t recommend having both in your configuration.

media_player:
  - platform: samsungtv_custom

Finally, put the following code in custom_components/media_player/samsungtv_custom.py. I didn’t name it samsungtv.py because I wanted to re-use as much code as possible and I’m not familiar enough with python to know how to do that properly.

"""
Custom component to allow overriding or adding features to the samsungtv media_player component.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/media_player.samsungtv/
"""

import logging

import voluptuous as vol

import homeassistant.components.media_player.samsungtv as stv
from homeassistant.components.media_player import (DOMAIN)
from homeassistant.const import (ATTR_ENTITY_ID)
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

SAMSUNG_TV_CUSTOM_DATA = 'samsungtv_custom'

SERVICE_KEY = 'send_key'

# Service call validation schemas
ATTR_KEY = 'key_code'

SAMSUNG_TV_CUSTOM_KEY_SCHEMA = vol.Schema({
    vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
    vol.Required(ATTR_KEY): cv.string,
})

def setup_platform(hass, config, add_devices, discovery_info=None):
    if SAMSUNG_TV_CUSTOM_DATA not in hass.data:
        hass.data[SAMSUNG_TV_CUSTOM_DATA] = []

    # Use this to get my hands on the SamsungTVDevices that get added
    def add_devices_custom(devices):
        add_devices(devices)
        for device in devices:
            hass.data[SAMSUNG_TV_CUSTOM_DATA].append(device)
    
    # pass in my add_devices_custom function
    stv.setup_platform(hass, config, add_devices_custom, discovery_info)    
    _LOGGER.debug("hass.data[SAMSUNG_TV_CUSTOM_DATA] = %s.", hass.data[SAMSUNG_TV_CUSTOM_DATA])
    
    def service_handle(service):
        _LOGGER.debug("service_handle called for %s with %s", service.service, service.data)
        entity_ids = service.data.get('entity_id')
        devices = hass.data[SAMSUNG_TV_CUSTOM_DATA]
        
        for device in devices:
            if device.entity_id in entity_ids:
                if service.service == SERVICE_KEY:
                    device.send_key(service.data.get(ATTR_KEY))
                    
                    device.schedule_update_ha_state(True)

    hass.services.register(
        DOMAIN, SERVICE_KEY, service_handle,
        schema=SAMSUNG_TV_CUSTOM_KEY_SCHEMA)
6 Likes

ive just tried this and i get

2018-05-20 08:15:52 WARNING (SyncWorker_9) [homeassistant.components.media_player.samsungtv] Cannot determine device

i my samsung is auto discovered

i my samsung is auto discovered

This error occurs when you have no manual configuration and it doesn’t auto-detect your TV. Does your TV normally get auto-discovered correctly without this warning? Mine doesn’t so I have everything specified:

media_player:
  - platform: samsungtv_custom
    host: xxx.xxx.xxx.xxx
    port: 8001
    name: Samsung TV
    timeout: 30
    mac: n0:t4:r3:a1:m4:c1
2 Likes

dude you rock!
works perfectly

are you able to control other things aside from volume?

Glad it’s sort of working for you. I have noticed that my TV tends to ignore the first button press if it’s been a while since the last one. That said, these are the keys I’ve found useful outside of volume and mute on my MU6300:

KEY_POWER

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

KEY_RETURN

  • this is the ‘back’ button on my remote. Go up one level in menus, close the smart hub, etc…

KEY_HOME

  • this brings up the smart menu. I use it to auto-navigate to Netflix and Plex.
  • can also be used to close the smart hub but if I do that I lose track of the state.

KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN

  • Navigation

KEY_ENTER

  • Item selection

I do have my TV in developer mode which may have some kind of impact. I’m going to turn that off in my next round of tests when I try a bunch of the “KEY_AUTO_ARC_” codes to see if I can prevent the TV from turning on my PS4 without having to disable HDMI-CEC.

I also saw a weird issue where websocket didn’t connect to my TV when it was turned on with the remote. I didn’t have debug logging enabled when that happened but I do now. I may end up customizing the item discovery a little bit.

Let me know if you have any other questions or problems.

Not much else to report.

  • Turning off developer mode had no impact on functionality.
  • KEY_EXIT functions somewhat like KEY_RETURN
  • KEY_SOURCE provides a shortcut to source selection but I can’t find anything that allows source selection directly (i.e. KEY_HDMI1)

Hi, just wondering how the wake-on-lan works?

I too have got a samsung smart TV and have been using my logitech harmony hub to turn the tv on due to the lack of network discovery when the tv is off.

Does adding the mac address to the config file enable wake-on-lan? I’d love to get rid of the harmony hub considering i literally only use it to turn the tv on.

Yes, adding the mac address to the config file enables wake-on-lan in the default samsung_tv component. I completely missed this in the documentation when I was setting up a couple of weeks ago:

  • mac (Optional): The MAC address of the Samsung Smart TV, eg. 00:11:22:33:44:55:66. Required for power on support via wake on lan.

If I don’t mistake myself wake on lan only work with cabled connection, not with wifi (in case someone tries that with a tv connected wirelessly:-) )

Hi,

I have a samsung, connected by wifi and i can switch on/off, so wake on lan works with wifi.

Just now i executed.

2 Likes