Skip to content

πŸ“Ί HomeAssistant - SamsungTV Tizen Component with SmartThings API Support

License

Notifications You must be signed in to change notification settings

PowderTech/ha-samsungtv-tizen

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

84 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

hacs_badge

HomeAssistant - SamsungTV Tizen 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.
This plugin is only for 2016+ TVs model! (maybe all tizen family)

Development for this project relies solely on donations, so if you enjoy this component, please consider becoming a patron or donating to ensure it's continued survival.

Additional Features:

  • Ability to send keys using a native Home Assistant service
  • Ability to send chained key commands using a native Home Assistant service
  • Supports Assistant commands (Google Home, should work with Alexa too, but untested)
  • Extended volume control
  • Ability to customize source list at media player dropdown list
  • Migrate SamsungCtl to SamsungTvWs
  • Cast video URLs to Samsung TV
  • Connect to SmartThings Cloud API for additional features: see TV channel names, see which HDMI source is selected, improved on / off states

N|Solid N|Solid

Installation

1. Easy Mode

TODO

2. Manual

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

  1. Download custom_components folder.
  2. Copy the samsungtv_tizen direcotry 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_tizen
            └── __init__.py
            └── media_player.py
            └── remote.py
            └── shortcuts.py
            └── smartthings.py
            └── manifest.json
    

Configuration

  1. Enable the component by editing the configuration.yaml file (within the config directory as well). Edit it by adding the following lines:

    # Example configuration.yaml entry
    media_player:
      - platform: samsungtv_tizen
        host: IP_ADDRESS
        port: 8002
        mac: MAC_ADDRESS
    

    Note: This is the same as the configuration for the built-in Samsung Smart TV component.

    Custom configuration variables

    update_method:
    (string)(Optional)
    This change the ping method used for state update. Values: "default" and "ping"
    Default value: "default"
    Example value: "ping"

    update_custom_ping_url:
    (string)(Optional)
    Use custom endpoint to ping.
    Default value: PING TO 8001 ENDPOINT
    Example value: "http://192.168.1.77:9197/dmr"

    source_list:
    (json)(Optional)
    This contains the KEYS visible sources in the dropdown list in media player UI.
    Default value: '{"TV": "KEY_TV", "HDMI": "KEY_HDMI"}'
    You can also chain KEYS, example: '{"TV": "KEY_SOURCES+KEY_ENTER"}'
    And even add delays (in milliseconds) between sending KEYS, example:
    '{"TV": "KEY_SOURCES+500+KEY_ENTER"}'
    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")

    app_list:
    (json)(Optional)
    This contains the APPS visible sources in the dropdown list in media player UI.
    Default value: AUTOGENERATED
    Example value: '{"Netflix": "11101200001", "YouTube": "111299001912", "Spotify": "3201606009684"}'
    Known lists of App IDs: List 1, List 2

    api_key:
    (string)(Optional)
    API Key for the SmartThings Cloud API, this is optional but adds better state handling on, off, channel name, hdmi source, and a few new keys: ST_TV, ST_HDMI1, ST_HDMI2, ST_HDMI3, etc. How to get an API Key for SmartThings
    You must set both an api_key and device_id to enable the SmartThings Cloud API

    device_id:
    (string)(Optional)
    Although this is an optional value, it is mandatory if you've set a SmartThings API Key in order to identify your device in the API. How to get a device ID from SmartThings
    You must set both an api_key and device_id to enable the SmartThings Cloud API

  2. Reboot Home Assistant

  3. Congrats! You're all set!

Usage

Known Supported Voice Commands

  • Turn on SAMSUNG-TV-NAME-HERE (for some older TVs this only works if the TV is connected by LAN cable to the Network)
  • Turn off SAMSUNG-TV-NAME-HERE
  • Volume up on SAMSUNG-TV-NAME-HERE (increases volume by 1)
  • Volume down on SAMSUNG-TV-NAME-HERE (decreases volume by 1)
  • Set volume to 50 on SAMSUNG-TV-NAME-HERE (sets volume to 50 out of 100)
  • Mute SAMSUNG-TV-NAME-HERE (sets volume to 0)
  • Change input source to DEVICE-NAME-HERE on SAMSUNG-TV-NAME-HERE (only works if DEVICE-NAME-HERE is a whitelisted word from this page under "Mode Settings")

(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.

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_CODEKEY" by desired key_code.

Script example:

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

Key codes

If SmartThings API was enabled by setting api_key and device_id, then these codes are also supported: ST_TV, ST_HDMI1, ST_HDMI2, ST_HDMI3, etc.

The list of accepted keys may vary depending on the TV model, but the following list has some common key codes and their descriptions.

Power Keys


Key Description
KEY_POWEROFF PowerOFF
KEY_POWERON PowerOn
KEY_POWER PowerToggle

Input Keys


Key Description
KEY_SOURCE Source
KEY_COMPONENT1 Component1
KEY_COMPONENT2 Component2
KEY_AV1 AV1
KEY_AV2 AV2
KEY_AV3 AV3
KEY_SVIDEO1 SVideo1
KEY_SVIDEO2 SVideo2
KEY_SVIDEO3 SVideo3
KEY_HDMI HDMI
KEY_FM_RADIO FMRadio
KEY_DVI DVI
KEY_DVR DVR
KEY_TV TV
KEY_ANTENA AnalogTV
KEY_DTV DigitalTV

Number Keys


Key Description
KEY_1 Key1
KEY_2 Key2
KEY_3 Key3
KEY_4 Key4
KEY_5 Key5
KEY_6 Key6
KEY_7 Key7
KEY_8 Key8
KEY_9 Key9
KEY_0 Key0

Misc Keys


Key Description
KEY_PANNEL_CHDOWN 3D
KEY_ANYNET AnyNet+
KEY_ESAVING EnergySaving
KEY_SLEEP SleepTimer
KEY_DTV_SIGNAL DTVSignal

Channel Keys


Key Description
KEY_CHUP ChannelUp
KEY_CHDOWN ChannelDown
KEY_PRECH PreviousChannel
KEY_FAVCH FavoriteChannels
KEY_CH_LIST ChannelList
KEY_AUTO_PROGRAM AutoProgram
KEY_MAGIC_CHANNEL MagicChannel

Volume Keys


Key Description
KEY_VOLUP VolumeUp
KEY_VOLDOWN VolumeDown
KEY_MUTE Mute

Direction Keys


Key Description
KEY_UP NavigationUp
KEY_DOWN NavigationDown
KEY_LEFT NavigationLeft
KEY_RIGHT NavigationRight
KEY_RETURN NavigationReturn/Back
KEY_ENTER NavigationEnter

Media Keys


Key Description
KEY_REWIND Rewind
KEY_STOP Stop
KEY_PLAY Play
KEY_FF FastForward
KEY_REC Record
KEY_PAUSE Pause
KEY_LIVE Live
KEY_QUICK_REPLAY fnKEY_QUICK_REPLAY
KEY_STILL_PICTURE fnKEY_STILL_PICTURE
KEY_INSTANT_REPLAY fnKEY_INSTANT_REPLAY

Picture in Picture


Key Description
KEY_PIP_ONOFF PIPOn/Off
KEY_PIP_SWAP PIPSwap
KEY_PIP_SIZE PIPSize
KEY_PIP_CHUP PIPChannelUp
KEY_PIP_CHDOWN PIPChannelDown
KEY_AUTO_ARC_PIP_SMALL PIPSmall
KEY_AUTO_ARC_PIP_WIDE PIPWide
KEY_AUTO_ARC_PIP_RIGHT_BOTTOM PIPBottomRight
KEY_AUTO_ARC_PIP_SOURCE_CHANGE PIPSourceChange
KEY_PIP_SCAN PIPScan

Modes


Key Description
KEY_VCR_MODE VCRMode
KEY_CATV_MODE CATVMode
KEY_DSS_MODE DSSMode
KEY_TV_MODE TVMode
KEY_DVD_MODE DVDMode
KEY_STB_MODE STBMode
KEY_PCMODE PCMode

Color Keys


Key Description
KEY_GREEN Green
KEY_YELLOW Yellow
KEY_CYAN Cyan
KEY_RED Red

Teletext


Key Description
KEY_TTX_MIX TeletextMix
KEY_TTX_SUBFACE TeletextSubface

AspectRatio


Key Description
KEY_ASPECT AspectRatio
KEY_PICTURE_SIZE PictureSize
KEY_4_3 AspectRatio4:3
KEY_16_9 AspectRatio16:9
KEY_EXT14 AspectRatio3:4(Alt)
KEY_EXT15 AspectRatio16:9(Alt)

Picture Mode


Key Description
KEY_PMODE PictureMode
KEY_PANORAMA PictureModePanorama
KEY_DYNAMIC PictureModeDynamic
KEY_STANDARD PictureModeStandard
KEY_MOVIE1 PictureModeMovie
KEY_GAME PictureModeGame
KEY_CUSTOM PictureModeCustom
KEY_EXT9 PictureModeMovie(Alt)
KEY_EXT10 PictureModeStandard(Alt)

Menus


Key Description
KEY_MENU Menu
KEY_TOPMENU TopMenu
KEY_TOOLS Tools
KEY_HOME Home
KEY_CONTENTS Contents
KEY_GUIDE Guide
KEY_DISC_MENU DiscMenu
KEY_DVR_MENU DVRMenu
KEY_HELP Help

OSD


Key Description
KEY_INFO Info
KEY_CAPTION Caption
KEY_CLOCK_DISPLAY ClockDisplay
KEY_SETUP_CLOCK_TIMER SetupClock
KEY_SUB_TITLE Subtitle

Zoom


Key Description
KEY_ZOOM_MOVE ZoomMove
KEY_ZOOM_IN ZoomIn
KEY_ZOOM_OUT ZoomOut
KEY_ZOOM1 Zoom1
KEY_ZOOM2 Zoom2

Other Keys


Key Description
KEY_WHEEL_LEFT WheelLeft
KEY_WHEEL_RIGHT WheelRight
KEY_ADDDEL Add/Del
KEY_PLUS100 Plus100
KEY_AD AD
KEY_LINK Link
KEY_TURBO Turbo
KEY_CONVERGENCE Convergence
KEY_DEVICE_CONNECT DeviceConnect
KEY_11 Key11
KEY_12 Key12
KEY_FACTORY KeyFactory
KEY_3SPEED Key3SPEED
KEY_RSURF KeyRSURF
KEY_FF_ FF_
KEY_REWIND_ REWIND_
KEY_ANGLE Angle
KEY_RESERVED1 Reserved1
KEY_PROGRAM Program
KEY_BOOKMARK Bookmark
KEY_PRINT Print
KEY_CLEAR Clear
KEY_VCHIP VChip
KEY_REPEAT Repeat
KEY_DOOR Door
KEY_OPEN Open
KEY_DMA DMA
KEY_MTS MTS
KEY_DNIe DNIe
KEY_SRS SRS
KEY_CONVERT_AUDIO_MAINSUB ConvertAudioMain/Sub
KEY_MDC MDC
KEY_SEFFECT SoundEffect
KEY_PERPECT_FOCUS PERPECTFocus
KEY_CALLER_ID CallerID
KEY_SCALE Scale
KEY_MAGIC_BRIGHT MagicBright
KEY_W_LINK WLink
KEY_DTV_LINK DTVLink
KEY_APP_LIST ApplicationList
KEY_BACK_MHP BackMHP
KEY_ALT_MHP AlternateMHP
KEY_DNSe DNSe
KEY_RSS RSS
KEY_ENTERTAINMENT Entertainment
KEY_ID_INPUT IDInput
KEY_ID_SETUP IDSetup
KEY_ANYVIEW AnyView
KEY_MS MS
KEY_MORE
KEY_MIC
KEY_NINE_SEPERATE
KEY_AUTO_FORMAT AutoFormat
KEY_DNET DNET

Auto Arc Keys


Key Description
KEY_AUTO_ARC_C_FORCE_AGING
KEY_AUTO_ARC_CAPTION_ENG
KEY_AUTO_ARC_USBJACK_INSPECT
KEY_AUTO_ARC_RESET
KEY_AUTO_ARC_LNA_ON
KEY_AUTO_ARC_LNA_OFF
KEY_AUTO_ARC_ANYNET_MODE_OK
KEY_AUTO_ARC_ANYNET_AUTO_START
KEY_AUTO_ARC_CAPTION_ON
KEY_AUTO_ARC_CAPTION_OFF
KEY_AUTO_ARC_PIP_DOUBLE
KEY_AUTO_ARC_PIP_LARGE
KEY_AUTO_ARC_PIP_LEFT_TOP
KEY_AUTO_ARC_PIP_RIGHT_TOP
KEY_AUTO_ARC_PIP_LEFT_BOTTOM
KEY_AUTO_ARC_PIP_CH_CHANGE
KEY_AUTO_ARC_AUTOCOLOR_SUCCESS
KEY_AUTO_ARC_AUTOCOLOR_FAIL
KEY_AUTO_ARC_JACK_IDENT
KEY_AUTO_ARC_CAPTION_KOR
KEY_AUTO_ARC_ANTENNA_AIR
KEY_AUTO_ARC_ANTENNA_CABLE
KEY_AUTO_ARC_ANTENNA_SATELLITE

Panel Keys


Key Description
KEY_PANNEL_POWER
KEY_PANNEL_CHUP
KEY_PANNEL_VOLUP
KEY_PANNEL_VOLDOW
KEY_PANNEL_ENTER
KEY_PANNEL_MENU
KEY_PANNEL_SOURCE
KEY_PANNEL_ENTER



Extended Keys


Key Description
KEY_EXT1
KEY_EXT2
KEY_EXT3
KEY_EXT4
KEY_EXT5
KEY_EXT6
KEY_EXT7
KEY_EXT8
KEY_EXT11
KEY_EXT12
KEY_EXT13
KEY_EXT16
KEY_EXT17
KEY_EXT18
KEY_EXT19
KEY_EXT20
KEY_EXT21
KEY_EXT22
KEY_EXT23
KEY_EXT24
KEY_EXT25
KEY_EXT26
KEY_EXT27
KEY_EXT28
KEY_EXT29
KEY_EXT30
KEY_EXT31
KEY_EXT32
KEY_EXT33
KEY_EXT34
KEY_EXT35
KEY_EXT36
KEY_EXT37
KEY_EXT38
KEY_EXT39
KEY_EXT40
KEY_EXT41

Please note that some codes are different on the 2016+ TVs. For example, KEY_POWEROFF is KEY_POWER on the newer TVs.

References

The code list has been extracted from: https://github.com/kdschlosser/samsungctl

About

πŸ“Ί HomeAssistant - SamsungTV Tizen Component with SmartThings API Support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%