Anyone Fancy a crack at Samsung Plugin?

Hi,

Ive been looking at trying to create a samsung plugin, without luck so far. It looks like the TVs work over websocket and the structure looks quite straightforward, although im not getting a connection at the moment. I saw a basic python ws script

import websocket
import json
import time

KEY_INTERVAL = 0.2

def send_key(key, repeat=1):
for n in range(repeat):
url = ‘ws://TV IP:TV PORT/api/v2/channels/samsung.remote.control’
connection = websocket.create_connection(url)
payload = json.dumps({
‘method’: ‘ms.remote.control’,
‘params’: {
‘Cmd’: ‘Click’,
‘DataOfCmd’: key,
‘Option’: ‘false’,
‘TypeOfRemote’: ‘SendRemoteKey’
}
})
connection.send(payload)
time.sleep(KEY_INTERVAL)

send_key(“KEY_MUTE”)

Can anyone think of a way of converting to the home remote?

John

Hi John,
have had a look here? Maybe it can help you.
I think Samsung does the things similar to LG.

Kalle

Hi,

Did you mean to post a link?

John

Closest thing I have found for my 2022 model Samsung is IP control via Node-Red, but not all functions work on it. The author says Samsung is pushing more and more control to their cloud based control and limits what users can do locally. I am using it to a degree for basic on, off, up, down, left, right functions, but what I would really like is to go directly to one of the streaming apps which it does not do.

Very interested in your plug in approach. Here is link to the node-red approach:

GitHub - Toxblh/node-red-contrib-samsung-tv-control: node-red plugin for samsung tv control

John,

After seeing your Kodi plugin, I don’t think there’s anything you can’t do. Have you tried a python to js converting tool? I’ve used them before to get the basic gist converted and then make tweaks. If it were me, I would start with the basics and just work on establishing the connection first using WebSocket | The Home Remote as a template. I don’t have a Samsung TV or else I would take a stab at it.

Sorry, forgotten the Link

This sounds also interesting - there are online converters available to convert the go code in python or Javascript:

Hi Greg,

Yeah the Kodi plugin was a strange labour of love, as omplicated as it got it really only used a limited number of js functions and kodi is entirlely JSON based so really easy to commincate with.

In terms of the samsung api, it seems very fragmented and poorly detailed. The authenticaed TVs (2015 or later) seem to need a differnet scheme and lots of people ask the same things. Ive found very few details on how to implement even with a number of hours of searching (the samsung api website is double duth to me and has broken links).

So far ive managed to connect to the TV via a webscoket but it looks like the new tvs cant communcate this way, at least without auth token etc. I can also prompt the TV to send a token request but ive got no idea what to do with it or to recive it back to THR. I think ive come to the end of the road until someone more acomplished than me facies a crack at it. Looks like its IR for the forseeable.

John