Samsung Smart TV

The Samsung Smart TV integration allows you to control a Samsung Smart TV.

配置

此集成可通过 UI 配置。前往 设置 > 设备与服务 添加。

  host:
    description: The IP address of the TV.
  name:
    description: The friendly name of the TV.

Data updates

The SamsungTV integration uses a local REST API with a WebSocket notification channel for immediate state information for media metadata, playback progress, volume etc.

Turn on action

If the integration knows the MAC address of the TV from discovery, it will attempt to wake it using wake on LAN when calling turn on. Wake on LAN must be enabled on the TV for this to work. If the TV is connected to a smart strip or requires a more complex turn-on process, a turn_on action can be provided that will take precedence over the built-in wake on LAN functionality.

You can create an automation from the user interface, from the device create a new automation and select the Device is requested to turn on automation. Automations can also be created using an automation action:

# Example configuration.yaml entry
wake_on_lan: # enables `wake_on_lan` integration

automation:
  - alias: "Turn On Living Room TV with WakeOnLan"
    triggers:
      - trigger: samsungtv.turn_on
        entity_id: media_player.samsung_smart_tv
    actions:
      - action: wake_on_lan.send_magic_packet
        data:
          mac: aa:bb:cc:dd:ee:ff

Any other actions to power on the device can be configured.

Usage

Changing channels

Changing channels can be done by calling the media_player.play_media action with the following payload:

entity_id: media_player.samsung_tv
media_content_id: 590
media_content_type: channel

Selecting a source

It's possible to switch between the 2 sources TV and HDMI. Some older models also expose the installed applications through the WebSocket, in which case the source list is adjusted accordingly.

Remote

The integration supports the remote platform. The remote allows you to send key commands to your TV with the remote.send_command action. The supported keys vary between TV models.

Full keycodes list

Power Keys

KeyDescription
KEY_POWEROFFPowerOFF
KEY_POWERONPowerOn
KEY_POWERPowerToggle

Input Keys

KeyDescription
KEY_SOURCESource
KEY_COMPONENT1Component1
KEY_COMPONENT2Component2
KEY_AV1AV1
KEY_AV2AV2
KEY_AV3AV3
KEY_SVIDEO1SVideo1
KEY_SVIDEO2SVideo2
KEY_SVIDEO3SVideo3
KEY_HDMIHDMI
KEY_FM_RADIOFMRadio
KEY_DVIDVI
KEY_DVRDVR
KEY_TVTV
KEY_ANTENAAnalogTV
KEY_DTVDigitalTV
KEY_AMBIENTAmbientMode

Number Keys

KeyDescription
KEY_1Key1
KEY_2Key2
KEY_3Key3
KEY_4Key4
KEY_5Key5
KEY_6Key6
KEY_7Key7
KEY_8Key8
KEY_9Key9
KEY_0Key0

Misc Keys

KeyDescription
KEY_PANNEL_CHDOWN3D
KEY_ANYNETAnyNet+
KEY_ESAVINGEnergySaving
KEY_SLEEPSleepTimer
KEY_DTV_SIGNALDTVSignal

Channel Keys

KeyDescription
KEY_CHUPChannelUp
KEY_CHDOWNChannelDown
KEY_PRECHPreviousChannel
KEY_FAVCHFavoriteChannels
KEY_CH_LISTChannelList
KEY_AUTO_PROGRAMAutoProgram
KEY_MAGIC_CHANNELMagicChannel

Volume Keys

KeyDescription
KEY_VOLUPVolumeUp
KEY_VOLDOWNVolumeDown
KEY_MUTEMute

Direction Keys

KeyDescription
KEY_UPNavigationUp
KEY_DOWNNavigationDown
KEY_LEFTNavigationLeft
KEY_RIGHTNavigationRight
KEY_RETURNNavigationReturn/Back
KEY_ENTERNavigationEnter
KEY_EXITNavigationExit

Media Keys

KeyDescription
KEY_REWINDRewind
KEY_STOPStop
KEY_PLAYPlay
KEY_FFFastForward
KEY_RECRecord
KEY_PAUSEPause
KEY_LIVELive
KEY_QUICK_REPLAYfnKEY_QUICK_REPLAY
KEY_STILL_PICTUREfnKEY_STILL_PICTURE
KEY_INSTANT_REPLAYfnKEY_INSTANT_REPLAY

Picture in Picture

KeyDescription
KEY_PIP_ONOFFPIPOn/Off
KEY_PIP_SWAPPIPSwap
KEY_PIP_SIZEPIPSize
KEY_PIP_CHUPPIPChannelUp
KEY_PIP_CHDOWNPIPChannelDown
KEY_AUTO_ARC_PIP_SMALLPIPSmall
KEY_AUTO_ARC_PIP_WIDEPIPWide
KEY_AUTO_ARC_PIP_RIGHT_BOTTOMPIPBottomRight
KEY_AUTO_ARC_PIP_SOURCE_CHANGEPIPSourceChange
KEY_PIP_SCANPIPScan

Modes

KeyDescription
KEY_VCR_MODEVCRMode
KEY_CATV_MODECATVMode
KEY_DSS_MODEDSSMode
KEY_TV_MODETVMode
KEY_DVD_MODEDVDMode
KEY_STB_MODESTBMode
KEY_PCMODEPCMode

Color Keys

KeyDescription
KEY_GREENGreen
KEY_YELLOWYellow
KEY_CYANCyan
KEY_REDRed

Teletext

KeyDescription
KEY_TTX_MIXTeletextMix
KEY_TTX_SUBFACETeletextSubface

AspectRatio

KeyDescription
KEY_ASPECTAspectRatio
KEY_PICTURE_SIZEPictureSize
KEY_4_3AspectRatio4:3
KEY_16_9AspectRatio16:9
KEY_EXT14AspectRatio3:4(Alt)
KEY_EXT15AspectRatio16:9(Alt)

Picture Mode

KeyDescription
KEY_PMODEPictureMode
KEY_PANORAMAPictureModePanorama
KEY_DYNAMICPictureModeDynamic
KEY_STANDARDPictureModeStandard
KEY_MOVIE1PictureModeMovie
KEY_GAMEPictureModeGame
KEY_CUSTOMPictureModeCustom
KEY_EXT9PictureModeMovie(Alt)
KEY_EXT10PictureModeStandard(Alt)

KeyDescription
KEY_MENUMenu
KEY_TOPMENUTopMenu
KEY_TOOLSTools
KEY_HOMEHome
KEY_CONTENTSContents
KEY_GUIDEGuide
KEY_DISC_MENUDiscMenu
KEY_DVR_MENUDVRMenu
KEY_HELPHelp

OSD

KeyDescription
KEY_INFOInfo
KEY_CAPTIONCaption
KEY_CLOCK_DISPLAYClockDisplay
KEY_SETUP_CLOCK_TIMERSetupClock
KEY_SUB_TITLESubtitle

Zoom

KeyDescription
KEY_ZOOM_MOVEZoomMove
KEY_ZOOM_INZoomIn
KEY_ZOOM_OUTZoomOut
KEY_ZOOM1Zoom1
KEY_ZOOM2Zoom2

Other Keys

KeyDescription
KEY_WHEEL_LEFTWheelLeft
KEY_WHEEL_RIGHTWheelRight
KEY_ADDDELAdd/Del
KEY_PLUS100Plus100
KEY_ADAD
KEY_LINKLink
KEY_TURBOTurbo
KEY_CONVERGENCEConvergence
KEY_DEVICE_CONNECTDeviceConnect
KEY_11Key11
KEY_12Key12
KEY_FACTORYKeyFactory
KEY_3SPEEDKey3SPEED
KEY_RSURFKeyRSURF
KEY_FF_FF_
KEY_REWIND_REWIND_
KEY_ANGLEAngle
KEY_RESERVED1Reserved1
KEY_PROGRAMProgram
KEY_BOOKMARKBookmark
KEY_PRINTPrint
KEY_CLEARClear
KEY_VCHIPVChip
KEY_REPEATRepeat
KEY_DOORDoor
KEY_OPENOpen
KEY_DMADMA
KEY_MTSMTS
KEY_DNIeDNIe
KEY_SRSSRS
KEY_CONVERT_AUDIO_MAINSUBConvertAudioMain/Sub
KEY_MDCMDC
KEY_SEFFECTSoundEffect
KEY_PERPECT_FOCUSPERPECTFocus
KEY_CALLER_IDCallerID
KEY_SCALEScale
KEY_MAGIC_BRIGHTMagicBright
KEY_W_LINKWLink
KEY_DTV_LINKDTVLink
KEY_APP_LISTApplicationList
KEY_BACK_MHPBackMHP
KEY_ALT_MHPAlternateMHP
KEY_DNSeDNSe
KEY_RSSRSS
KEY_ENTERTAINMENTEntertainment
KEY_ID_INPUTIDInput
KEY_ID_SETUPIDSetup
KEY_ANYVIEWAnyView
KEY_MSMS
KEY_MORE
KEY_MIC
KEY_NINE_SEPERATE
KEY_AUTO_FORMATAutoFormat
KEY_DNETDNET
KEY_MINUSMinus

Auto Arc Keys

KeyDescription
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

KeyDescription
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

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

The code list has been extracted from: https://github.com/kdschlosser/samsungctl and https://github.com/jaruba/ha-samsungtv-tizen/blob/master/Key_codes.md

Example to send sequence of commands:

action: remote.send_command
target:
  device_id: 72953f9b4c9863e28ddd52c87dcebe05
data:
  command:
    - KEY_MENU
    - KEY_RIGHT
    - KEY_UP
    - KEY_UP
    - KEY_ENTER

Known issues and restrictions

Subnet/VLAN

Samsung SmartTV does not allow WebSocket connections across different subnets or VLANs. If your TV is not on the same subnet as Home Assistant this will fail. It may be possible to bypass this issue by using IP masquerading or a proxy.

H and J models

Some televisions from the H and J series use an encrypted protocol and require manual pairing with the TV. This should be detected automatically when attempting to send commands using the WebSocket connection, and trigger the corresponding authentication flow.

Samsung TV keeps asking for permission

The default setting on newer televisions is to ask for permission on every connection attempt. To avoid this behavior, please ensure that you adjust this to First time only in the Device connection manager > Access notification settings of your television. It is also recommended to cleanup the previous attempts in Device connection manager > Device list

Removing the integration

This integration follows standard integration removal. No extra steps are required.

To remove an integration instance from Home Assistant

  1. Go to Settings > Devices & services and select the integration card.
  2. From the list of devices, select the integration instance you want to remove.
  3. Next to the entry, select the three-dot menu. Then, select Delete.