Samsung TV integration Question -- Driver info starting post 127

OK, I'm closer, now I'm stuck on where to find the values to set the Input Source and Set Volume. What's strange is that for volume it says it has to be numeric from 0-100 but when I enter 0, it doesn't seem to want it. For the input source, since we generally are turning the TV on first to watching TV, I tried to set the source as HDMI 2, and it won't take that. (tried without spaces, in quotes, brackets, I'm stuck). Where do I find those? I can't save the device without them.

You can find all the valid inputs on st ide on the device tv page.

On the Hubitat avr device try just a number like 1 or 2 if the st input selections don't work.

Interested in this.

I'm interested in controlling my tv and I also don't have a ST hub. What is the mac and Pi doing and what software do you have on those. That said, I don't have a mac only windows, linux and pi's.

Also, what did you install on the Hubitat?

Can you be a bit more specific, as I'd like to try this if I can!!!!

So far on the Hubitat I have the HubConnect Server for Hubitat and the HubConnect Remote Client. I also installed the Remote Server (if memory serves, I don't have the Pi booted up right now) on a secondary instance of Hubitat on the Pi. I added the TV as a Hubitat virtual device (HubConnect AVR) but that's where I'm stuck. I can't get the TV to respond. I don't know if I need to add something to the Device ID, or what. I'm not sure that it matters having Mac vs Windows since we're adding apps, etc in the cloud. The caution I'll share is that if you go to GitHub or some other location to pick up the app code and device code, when you copy and paste it into Hubitat, it will paste in with a space and you'll get an error or won't be able to save it. Scan through it til you find the space, back space it out and you should be fine.
Let me know if you have success. I tried one other thing this afternoon and I'll let you know if it works.

I have just tried to search for "Remote Server Raspberry pi Hubitat" and can't find anything.
Do you have links that will point me in the right direction for all the installs?

You'll want the Installation Instructions. When you click on them you can view them but you can't copy the code for the files. Download it and then you should be able to copy and paste the code. The info I can see says that while 2.0 is available, 1.6 is the stable release and 2.0 should only be used by developers with experience. Which I am NOT, so I went with 1.6.

POST 2016 Model possible Samsung Remote Driver:

All, I have continued my investigation on SamsungTV remote and tried some code using the ideas and information from "samsungctl/samsungctl at master · Ape/samsungctl · GitHub".

Since my TV is pre-2016, I get the following expected results:

  • Connect is successful
  • The command returns an illegal method with the sent method "ms.remote.control"

But, I think the code will work with 2016 and later TVs. Any testers??

Below is the code and the explicit test keys for testing. You will have to enter the IP in preferences. If it works, I can point you to GitHub key codes (a lot of them in one list) to choose to control the device.

My Hubitat tested code:

Test code for post 2016 Samsung TV Control
test keys:  
import groovy.json.JsonOutput  
metadata {
	definition (name: "Samsung Remote WS Test",
				namespace: "davegut",
				author: "David Gutheinz",
				importUrl: ""
		command "test", ["string"]
	preferences {
		input ("deviceIp", "text",
			   title: "Device Ip")
def installed() {}
def updated() {}

def test(String keyPress) {
	log.trace "test: $keyPress"
	def command = [
		method: "ms.remote.control",
		params: [
			Cmd: "Click",
			DataOfCmd: keyPress,
			Option: "false",
			TypeOfRemote: "SendRemoteKey"
	command = JsonOutput.toJson(command)

private sendCmd(command) {
	log.trace "sendCmd: $command, $deviceIp"
	def url = "ws://${deviceIp}:8001/api/v2/channels/samsung.remote.control"
	runIn(5, close)

def webSocketConnect(String url, options = []) { interfaces.webSocket.connect(url) }
def sendMessage(String message) { interfaces.webSocket.sendMessage(message) }
def close() { interfaces.webSocket.close() }
def webSocketStatus(message) { log.debug "webSocketStatus: $message" }
def parse(message) { "parse: $message" }

Thanks for trying to get this to work!

I'm trying this on a 2019 Samsung TV, but it is errors out with the below:

Cal, thanks for the assist. The message indicates that the code is working (it returns an error event from the method. This may be due to the TV mode (i.e., you use volume while using the soundbar).

Which key code did you try this with? It looks like code that translated to code 1005 which is reserved. Did you try others? Particularly KEY_TOOLS, KEY_SOURCE, or KEY_SOURCE that work regardless of external source or sound sink.


Results w a 2014(?) Samsung TV
dev:21312020-10-11 09:15:06.748 am debugwebSocketStatus: status: closing

dev:21312020-10-11 09:15:01.695 am infoparse: {"event":"ms.error","data":{"message":"unrecognized method value : ms.remote.control"}}

dev:21312020-10-11 09:15:01.360 am infoparse: {"event":"","data":{"id":"bf7cd270-2327-11b2-9f26-31ddfd4a529d","clients":[{"id":"bf7cd270-2327-11b2-9f26-31ddfd4a529d","connectTime":586551576,"attributes":{},"isHost":false}]}}

dev:21312020-10-11 09:15:01.345 am debugwebSocketStatus: status: open

dev:21312020-10-11 09:15:01.048 am tracesendCmd: {"method":"ms.remote.control","params":{"Cmd":"Click","DataOfCmd":"KEY_MUTE","Option":"false","TypeOfRemote":"SendRemoteKey"}},

dev:21312020-10-11 09:15:01.044 am tracetest: KEY_MUTE

Here's are logs from when trying all the other keys, like KEY_TOOLS and KEY_SOURCE. Tried this with the TV already on with source of HDMI

Thanks. I failed. sigh.

Here are a couple of commands, that worked well to open some apps on the TV:
(Open Netflix)
curl -X POST -i 'http://IP:8001/api/v2/applications/11101200001'
(Open Prime Video)
curl -X POST -i 'http://IP:8001/api/v2/applications/3201512006785'

I was doing some reading on some other forums, and it seems like you can connect over websocket, but first you have to obtain the Name of the TV convert to Base64, connect and obtain the token for future connection. This is far as I could get.

Get TV Name from:

Convert TV Name to Base64

Connect using:


Maybe the code is on the wrong port for your TV. Try changing the line:

def url = "ws://${deviceIp}:8001/api/v2/channels/samsung.remote.control"

to read (changing the port to 8002:

def url = "ws://${deviceIp}:8002/api/v2/channels/samsung.remote.control"

Tried changing the URL, but that didn't work. However, some progress...

I figured out how to get these newer TV's that require encryption to connect. Apparently Remote.Control requires the secure connection.

  1. Installed NPM & wscat on a computer order to investigate websocket connection and responses
  2. TV should be turned on
  3. Open a web browser to http://TVIPADDRESS:8001/api/v2/
  4. A pop up may appear on the TV, you have to click Allow
  5. Web browser will output the TV information, copy the 'TV Name'
  6. The name has to be encoded to Base64, I used this site then copy the string (
  7. Next, open a command prompt on the machine you have wscat installed on
  8. wscat -n -c https://TVIPADDRESS:8002/api/v2/channels/samsung.remote.control?name=TVNameStringYouReceivedFromBase64Encode
  9. "Token":"12345678" <-8 Character Token will be displayed in the output
  10. Now, you can connect to the TV securely using the Token by going to: wscat -n -c https://TVIPADDRESS:8002/api/v2/channels/samsung.remote.control?token=<8 digit token> and issue commands. By using the token in the URL, the TV will no longer prompt you to accept the remote device connection each time you send a command.

All of the remote control commands can be now sent, and they all work on the TV if they are in the format below

{"params": {"Cmd": "Click", "Option": "false", "TypeOfRemote": "SendRemoteKey", "DataOfCmd": "KEY_VOLUP"}, "method": "ms.remote.control"}

This site I ran across was a huge help in figuring this out, Samsung TV info is mid way down (S. Andrews)

Based on this info, is it possible to bring it into the App?

  1. Connect to TV's IP, to receive the TV name
  2. Base64Encode TV's name
  3. Connect to TV using Base64 name to receive the Token
  4. Remember Token and URL and use that for connectivity on all future access
1 Like

Several things.
Control you is how I control my Samsung Wifi Speakers. Quite simple, so can do.
Your Step 3: We will have to capture name and uri. Yours uses 8002 as the final port, mine 8001.
Step 6: Base 64: name.encodeAsBase64().toString()
Step 9: Just a parameter to catch
Step 10: Easy

So, yes. What you want should be able to be done. Let me update my test driver some to capture the various data.

I created a test driver (no polish, not final version). Tested all but getting token and sending key (but coded those functions.
Step 1: GetData (gets the name of the TV
Step 2: Get token
Step 3: Send Key with key name entry.
I am very interested in what the output for a Send Key is. That should be an event and I want to know if it reports volume for KEY_VOLDOWN.

If this works, I will code further with agreed keys; including the Samsung recommended minimum keys.

link to code:

Thanks! Here's the output:

Port set to 8001:


Port set to 8002:

Updated code at same site to fix one error found this am. Also, now working on port 8002 only. Added commands for key (no longer need to enter) and updated logging.

  • Close device
  • Replace code
  • Open device
  • Get Data
  • Get Token
  • Menu

At some point, you may need to allow the device on your TV. I have seen this on my UPnP efforts where I can control volume, mute, source, play, pause and etc. I actually plan to include these on the final update (particularly calling the explicit source and volume).