Home

Awesome

hacs_badge

HomeAssistant - SamsungTV Smart Component

This is a custom component to allow control of SamsungTV devices in HomeAssistant. Is a modified version of the built-in samsungtv with some extra features.<br/> This plugin is only for 2016+ TVs model! (maybe all tizen family)

This project is a fork of the component SamsungTV Tizen. I added some feature like the possibility to configure it using the HA user interface, simplifing the configuration process. I also added some code optimizition in the comunication layer using async aiohttp instead of request. Part of the code and documentation available here come from the original project.<br/>

Additional Features:

N|Solid N|Solid

Installation

1. Easy Mode

Install via HACS.

2. Manual

Install it as you would do with any homeassistant custom component:

  1. Download custom_components folder.
  2. Copy the samsungtv_smart directory within the custom_components directory of your homeassistant installation. The custom_components directory resides within your homeassistant configuration directory. Note: if the custom_components directory does not exist, you need to create it. After a correct installation, your configuration directory should look like the following.
    └── ...
    └── configuration.yaml
    └── custom_components
        └── samsungtv_smart
            └── __init__.py
            └── media_player.py
            └── websockets.py
            └── shortcuts.py
            └── smartthings.py
            └── upnp.py
            └── exceptions.py
            └── ...
    

Configuration

Once the component has been installed, you need to configure it in order to make it work. There are two ways of doing so:

Important: To complete the configuration procedure properly, you must be sure that your TV is turned on and connected to the LAN (wired or wireless). Stay near to your TV during configuration because probably you will need to accept the access request that will prompt on your TV screen.

Note: To configure the component for using SmartThings (strongly suggested) you need to generate an access token as explained in this guide. Also make sure your TV is logged into your SmartThings account and registered in SmartThings phone app before starting configuration.

Option A: Configuration using the web UI [recommended]

  1. From the Home Assistant front-end, navigate to 'Configuration' then 'Integrations'. Click + button in botton right corner, search 'SamsungTV Smart' and click 'Configure'.
  2. In the configuration mask, enter the IP address of the TV, the name for the Entity and the SmartThings personal access token (if created) and then click 'Submit'
  3. Important: look for your TV screen and confirm immediately with OK if a popup appear.
  4. Congrats! You're all set!

Note: be sure that your TV and HA are connected to the same VLAN. Websocket connection through different VLAN normally not work because not supported by Samsung TV. If you have errors during configuration, try to power cycle your TV. This will close running applications that can prevent websocket connection initialization.

Option B: Configuration via editing configuration.yaml

From v0.3.16 initial configuration from yaml is not allowed.<br> You can still use configuration.yaml to set the additional parameter as explained below.

Configuration options

From the Home Assistant front-end, navigate to 'Configuration' then 'Integrations'. Identify the 'SamsungTV Smart' integration configured for your TV and click the OPTIONS button.<br/> Here you can change the following options:

Advanced options

Synched entities configuration

Sources list configuration

This contains the KEYS visible sources in the dropdown list in media player UI.<br/> You can configure the pair list Name: Key using the yaml editor in the option page. If a source list is present in configuration.yaml, it will be imported in the options the first time that the integration is loaded.<br/>

Default value:<br/>

    1| TV: KEY_TV
    2| HDMI: KEY_HDMI

If SmartThings is configured and the source_list not, the component will try to identify and configure automatically the sources configured on the TV with the relative associated names (new feature, tested on QLed TV). The created list is available in the HA log file.<br/> You can also chain KEYS, example:

    1| TV: KEY_SOURCES+KEY_ENTER

And even add delays (in milliseconds) between sending KEYS, example:<br/>

    1| TV: KEY_SOURCES+500+KEY_ENTER

Resources: key codes / key patterns<br/> Warning: changing input source with voice commands only works if you set the device name in source_list as one of the whitelisted words that can be seen on this page (under "Mode Settings")<br/>

Application list configuration

This contains the APPS visible sources in the dropdown list in media player UI.<br/> You can configure the pair list Name: Key using the yaml editor in the option page. If an application list is present in configuration.yaml, it will be imported in the options the first time that the integration is loaded.<br/>

If the Application list is not manually configured, during startup the integration will try to automatically generate a list of available application and a log message is generated with the content of the list. This list can be used to create a manual list following app_list guide. Automatic list generation not work with some TV models.<br/>

Example value:

    1| Netflix: "11101200001"
    2| YouTube: "111299001912"
    3| Spotify: "3201606009684"

Known lists of App IDs: List 1, List 2<br/>

Channel list configuration

This contains the tv CHANNELS visible sources in the dropdown list in media player UI. To guarantee performance keep the list small, recommended maximum 30 channels.<br/> You can configure the pair list Name: Key using the yaml editor in the option page. If a channel list is present in configuration.yaml, it will be imported in the options the first time that the integration is loaded.<br/>

Example value:

    1| MTV: "14"
    2| Eurosport: "20"
    3| TLC: "21"

You can also specify the source that must be used for every channel. The source must be one of the source name defined in the source_list<br/> Example value:

    1| MTV: 14@TV
    2| Eurosport: 20@TV
    3| TLC: 21@HDMI

Custom configuration parameters

You can configure additional option for the component using configuration variable in configuration.yaml section.<br/>

Section in configuration.yaml file can also not be present and is not required for component to work. If you want to configure any parameters, you must create one section that start with - host as shown in the example below:<br/>

samsungtv_smart:
  - host: <YOUR TV IP ADDRES>
    ...

Then you can add any of the following parameters:<br/>

Deprecated configuration parameters

Deprecated parameters were used by old integration version. Are still valid but normally are automatically imported in application options and not used anymore, so after first import can be removed from configuration.yaml.

Removed configuration parameters

Removed parameters were used by old integration version, are not used and supported anymore and replaced by application option. For this reason should be removed from configuration.yaml.

Usage

Known Supported Voice Commands

(if you find more supported voice commands, please create an issue so I can add them here)

Cast to TV

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "url",
  "media_content_id": "FILE_URL",
}

Replace FILE_URL with the url of your file

Cast to YouTube

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "url",
  "media_content_id": "YOUTUBE_URL",
  "enqueue": "play",
}

Replace YOUTUBE_URL with the url of the video you want to play All 4 enqueue modes are supported. Shorts videos URL are also supported. Note: enqueue is required, or the service will open the video using TV Web Browser.

Send Keys

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "send_key",
  "media_content_id": "KEY_CODE"
}

Note: Change "KEY_CODE" by desired key_code. (also works with key chaining and SmartThings keys: ST_TV, ST_HDMI1, ST_HDMI2, ST_HDMI3, etc. / see more at SmartThings Keys)

Script example:

tv_channel_down:
  alias: Channel down
  sequence:
  - service: media_player.play_media
    data:
      entity_id: media_player.samsung_tv55
      media_content_type: "send_key"
      media_content_id: KEY_CHDOWN

Hold Keys

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "send_key",
  "media_content_id": "KEY_CODE, <hold_time>"
}

Note: Change "KEY_CODE" by desired key_code and <hold_time> with a valid numeric value in milliseconds (this also works with key chaining but not with SmartThings keys).

Key Chaining Patterns

Key chaining is also supported, which means a pattern of keys can be set by delimiting the keys with the "+" symbol, delays can also be set in milliseconds between the "+" symbols.

See the list of known Key Chaining Patterns

Open Browser Page

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "browser",
  "media_content_id": "https://www.google.com"
}

Send Text

To send a specific text to a selected text input

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "send_text",
  "media_content_id": "your text"
}

Select sound mode (SmartThings only)

service: media_player.select_sound_mode
{
  "entity_id": "media_player.samsungtv",
  "sound_mode": "your mode"
}

Note: You can get list of valid sound_mode in the sound_mode_list state attribute

Select picture mode (SmartThings only)

service: samsungtv_smart.select_picture_mode
{
  "entity_id": "media_player.samsungtv",
  "picture_mode": "your mode"
}

Note: You can get list of valid picture_mode in the picture_mode_list state attribute

Set Art Mode (for TV that support it)

service: samsungtv_smart.set_art_mode
{
  "entity_id": "media_player.samsungtv"
}

Be kind!

If you like the component, why don't you support me by buying me a coffe? It would certainly motivate me to further improve this work.

Buy me a coffe!

Credits

This integration is developed by Ollo69 based on integration SamsungTV Tizen.<br/> Original SamsungTV Tizen integration was developed by jaruba.<br/> Logo support is based on jaruba channels-logo and was developed with the support of Screwdgeh.<br/>