Ape/samsungctl

Launch app on tv

Mcgurk125 opened this issue Β· 141 comments

Apologies, if this is not worth creating a new issue for... its more of a question.

The Samsung Smart View application - Link - has the ability to launch apps on the TV (Netflix, Plex etc.) - I was wondering if it was possible to replicate these calls?

Ape commented

Not currently supported, but I am accepting patches if you are able to reverse engineer the protocol.

So after a day of hacking up some controls for our tvs (we have a wall of them)

{"method":"ms.remote.control","params":{"Cmd":"Move","Position":{"x":-1000,"y":1000,"Time":"1518675746190"},"TypeOfRemote":"ProcessMouseDevice"}}

Send in rapid succession after getting a json blob on the websocket saying that mouse mode is enabled (don't have the actual message handy, sorry)

{"method":"ms.channel.emit","params":{"event": "ed.apps.launch", "to":"host", "data":{"appId": "org.tizen.browser", "action_type": "NATIVE_LAUNCH"}}}

Launch an app, nfi how to change parameters or give it a url, we just set our home page to various dashboards (actually I wrote a tool that redirects the tv to the dashboard based on ip because typing on these tvs suck)

There's .a DEEP_LINK action type, but that seems to be for webapps, which has slightly different arguments.

{"method":"ms.channel.emit","params":{"event": "ed.installedApp.get", "to":"host"}}

List installed apps.

the last two are probably only supported on tvs that have
"EDEN_available":"true" in their isSupport list

Awesome work, do you http post this to web service, do you know which port?

Just sent up the same websocket the button presses are sent

Quick question, I tried this last night replacing the key with json you gave, however it just sends an array of commands rather than a block. Any chance you can share your tool or just bash cmd used? Many thanks

My code is written in Go, but here's a sample in javascript that should start the browser.

NB, the tv will prompt for permission so you'll need to grant that and run the code twice

ws = new WebSocket('ws://10.10.1.21:8001/api/v2/channels/samsung.remote.control');
ws.onopen = function() {ws.send('{"method":"ms.channel.emit","params":{"event": "ed.apps.launch", "to":"host", "data":{"appId": "org.tizen.browser", "action_type": "NATIVE_LAUNCH"}}}')};
ws.onmessage = function(e) {console.log(e)}

Much appreciated!

and launching a url...

{"method":"ms.channel.emit","params":{"event": "ed.apps.launch", "to":"host", "data":{"appId":"org.tizen.browser","action_type":"NATIVE_LAUNCH","metaTag":"http:\/\/hackaday.com"}}}

If you need to send text, base64 encode your string

{"method":"ms.remote.control","params":{"Cmd":"$BASE64ENCODEDSTRING$","TypeOfRemote":"SendInputString","DataOfCmd":"base64"}}

You must connect via wss on port 8002 if you want to send passwords, otherwise you have to post to a https url

edit: Here's some code

https://gist.github.com/freman/8d98742de09d476c4d3d9e5d55f9db63

It is possible to obtain the channel list ?

@freman This is awesome! Quick question, any chance you figured out how to determine which app is currently open?

@freman

Thanks for this awesome find. I've tried executing the javascript you posted but sadly it's not doing anything. I'm getting a response though but the browser is not opening on my tv. Is the app-id for the browser generic on all tv models? Also how would i go about retrieving a list of installed apps, i want to open netflix for example.

I'm having some trouble launching Netflix. When I list all apps a big JSON list is returned among which:
{'appId': '11101200001', 'app_type': 2, 'icon': '/opt/share/webappservice/apps_icon/FirstScreen/11101200001/250x250.png', 'is_lock': 0, 'name': 'Netflix'}

But when I send the following JSON over the websocket:

payload = json.dumps({
    "method": "ms.channel.emit",
    "params": {
            "event": "ed.apps.launch",
            "to": "host",
            "data": {
                "appId": "11101200001",
                "action_type": "NATIVE_LAUNCH"
                }
        }
    })

I get an error: ERROR:websocket:close status: 31522, but with org.tizen.browser as appId it works.
Would really appreciate it if someone can help me with this.

@maartenpeels For netflix and pretty much everything i've tried that wasn't the browser, you should use "action_type": "DEEP_LINK" instead of "action_type": "NATIVE_LAUNCH". Though a quick way to check that, anything with "app_type": 2 uses DEEP_LINK and I believe "app_type": 4 is NATIVE_LAUNCH.

@marius1968 sorry not that I've looked for.

@kristenmills not that I've found, i'd also like to figure out how to see the current open tab in the browser, if you always assume the browser is empty it'll start a new tab (overloading our graphing service), if you always assume it'll work eventually it'll start up and open the 'featured' screen not the 'home' screen despite telling the damn thing to always go to the 'home' screen several times.

@nickyromeijn {"method":"ms.channel.emit","params":{"event": "ed.installedApp.get", "to":"host"}}

@maartenpeels it appears @kristenmills is correct, we only use it to open a web app and see our charts... somewhat unreliably but still easier than doing it by hand every day.

@maartenpeels, @nickyromeijn, @kristenmills
It's easier to use the dial protocol for the applications listed in dial registry (include Netflix, Youtube).

So, to identify if a particular application is installed you can use the call :
curl -X GET -i 'yourIP:8001/ws/apps/Netflix'
and and you will receive the answer : Netflixrunning6.0.003 OR Netflixstopped6.0.003

To launch the desired application you can use : curl -X POST -i 'http://yourIP:8001/ws/apps/Netflix' with response http://yourIP:8001/ws/apps/Netflix/run

@freman
How on earth did you managed to identify this logs?
The Samsung API documentation does not exist and I'm trying for 3 months (without success) for Samsung Tizen to get channel list and subscription to a channel/volume change event.
Can you can give us a hint in this direction?

@marius1968 because I couldn't even get the app to work, mostly decompiling their app. Once I did manage to get the app working, tcpdump

@freman you have no idea the brilliance of this. I have been researching this for over two months right now. Even got into some thread that the guys are trying to reverse engineering the encryption DLL as that was the, thinking as to why no one knows how to communicate with the TV. I have been testing some the codes and this works really well.

Got the Ws app taking to the TV accepted it as a authorised app, can navigate call apps, open browser etc.

Question: once accepting the connection on the TV, and you disconnect for example. When you reconnect my TV is far so didn't see the next time I connected if it asked again for allow? Once you allow the app do I have to. Do this again or will the same ws://ip:8001....app=basecode64 always work?

Another Q anyone figure out where "/opt/share/webappservice/apps_icon/FirstScreen/11101200001/250x250.png" or any of the icons actually reside? Would be awesome in an app to show these.

Anyone has able to get if some non-standard app is running?

I can get running status with http://X:8080/ws/apps/Netflix but I can't get if Deezer (3201608010191) or Spotify (3201606009684) is running.

Maybe there is a way using ws?

@xalexslx
only applications listed in Dial Registry ... for Spotify try com.spotify.Spotify

@marius1968 - Plex is listed in the DIAL registry as Plex - But i cant get it to load on my TV using the WS method above. YouTube works as does Netflix... Just not Plex unfortunately.

@marius1968 @pegatron89 Same as you. Tried both (Plex, Spotify, Deezer, Twitch) and it didn't worked, just Netflix and YouTube.

If there is a way to get app status via ws it will be good because we can just pass the AppId.

@xalexslx a quick google and the App ID for plex is: 111199000681

https://forums.plex.tv/t/home-automation-start-plex-whats-your-appid/38276

Do you know how to pass the appID? I tried 192.168.0.62:8001/ws/apps/111199000681 on the off chance but this did not work.

Hello!
At first thanks for this great possibility. For my understanding i have a question:
What do you mean with DIAL Registry?

I tried to start Amazon with a curl Post. Netflix and youtube work great but Amazon doesnt. I got the Applicationname "Amazon Video" . It seems thtat curl cannot handle Applicationnames with a whitespace in it. I have to use the ApplicationID, but with ApplicationID i cant launch Amazon Video.

Any suggestions?

Best regards

@DerGute
Try one of the following instead of amazon video;
com.amazon.mp3
Amazon
primeLive
com.amazon

There are more within the registry (see website below) I am at work at the moment so cant confirm if these work.

http://www.dial-multiscreen.org/dial-registry/namespace-database

I have tried several ids from DIAL Registry with installed apps on my Samsung TV. None of them worked except for YouTube and Netflix. It seems that Samsung doesn't follow the rules?

Also, I got all app ids using the following command from the websocket

{"method":"ms.channel.emit","params":{"event": "ed.installedApp.get", "to":"host"}}

And I can launch them with

{"method":"ms.channel.emit","params":{"event": "ed.apps.launch", "to":"host", "data":{"appId":"org.tizen.browser","action_type":"NATIVE_LAUNCH","metaTag":"http:\/\/hackaday.com"}}}

But I cant get current status of any running app except for YouTube and Netflix.

Hi,

I downloaded the whole DIAL registry and ran against my Samsung TV using Postman runner. Unfortunately only Netflix, YouTube and Pandora was found using the DIAL ids.

Here are the list of my TV currently installed apps:

  • YouTube (Found)
  • Hulu
  • Plex
  • HBO NOW
  • Netflix (Found)
  • Web Browser
  • TV Plus
  • YouTube TV
  • e-Manual
  • Spotify
  • Asphalt 8: Airborne
  • Google Play Movies οΌ† TV
  • Amazon Video
  • TuneIn
  • SHOWTIME
  • NBC
  • NBC Sports
  • NFL SUNDAY TICKET
  • STARZ
  • FandangoNOW
  • Red Bull TV
  • Dramafever
  • CNBC Real-Time
  • Bloomberg TV
  • AccuWeather - Weather for Life
  • Pluto TV: TV for the Internet
  • CinemaNow
  • ENCORE Play
  • Pandora (Found)
  • Vimeo
  • YuppTV
  • The Weather Network
  • BBC News
  • TED
  • VUDU
  • NBA
  • UFC.TV
  • MLB.TV
  • iHeartRadio
  • Facebook
  • Deezer
  • HGTV
  • Food Network
  • Travel Channel
  • STARZ
  • CNNgo
  • Sotheby's
  • Steam Link
  • Pantaya
  • Sling TV
  • Amazon Music
  • Freeform
  • CBS All Access
  • CBS News: Live Breaking News
  • HBO GO
  • Emby
  • TwitchTV

Here is, raw, a bunch of (3rd party) app_tizen_id's (to be completed if I find anymore). If some are not explicit enough, don't ask me which app they are: I don't know!

Ahw07WXIjx.Dailymotion
tisT7SVUug.tunein
cexr1qp97S.Deezer
xqqJ00GGlC.okidoki
4ovn894vo9.Facebook
vbUQClczfR.Wuakitv
QizQxC7CUf.PlayMovies
QBA3qXl8rv.Kick
DJ8grEH6Hu.arte
JtPoChZbf4.Vimeo
hIWwRyZjcD.GameFlyStreaming
sHi2hDJGmf.nolim
guMmq95nKK.CanalPlusLauncher
RN1MCdNq8t.Netflix / org.tizen.netflix-app
evKhCgZelL.AmazonIgnitionLauncher2 / org.tizen.ignition
9Ur5IzDKqV.TizenYouTube
gDhibXvFya.HBOGO
EmCpcvhukH.ElevenSports
ASUvdWVqRb.FilmBoxLive
rJeHak5zRg.Spotify
ABor2M9vjb.acc   (AccuWeather)
EkzyZtmneG.My5
yFo6bAK50v.Dennexpres
gdEZI5lLXr.Europa2FHD
bm9PqdAwjv.TvSme
dH3Ztod7bU.IDNES
wsFJCxteqc.OnetVodEden
rZyaXW5csM.TubaFM
4bjaTLNMia.curzon
RVvpJ8SIU6.ocs
bstjKvX6LM.molotov
RffagId0eC.SfrSport
phm0eEdRZ4.ExtraTweetIM2
VAarU8iUtx.samsungTizen   (Vevo)
g0ScrkpO1l.SmartIPTV
kIciSQlYEM.plex
...

None of them worked with dial api.

I get this to work by using DEEP_LINK to start the application

example
ws.onopen = function() {ws.send('{"method":"ms.channel.emit","params":{"event": "ed.apps.launch", "to":"host", "data":{"appId":"bstjKvX6LM.molotov","action_type":"DEEP_LINK"}}}')};
to start molotov

I have on my TV Plex and MyCanal I would like to start but I do not know how to get the app_tizen_id's as @zoelechat described in his mail !

None of them worked with dial api.

They're precisely not meant to be launched through dial API but natively. DEEP_LINK? I personnally use NATIVE_LAUNCH.

I do not know how to get the app_tizen_id's

If it was so easy I wouldn't see any interest in publishing a list ;)
MyCanal is in list (CanalPlusLauncher). Plex, well I can check, have to install it, will add...

@zoelechat
That is what is weird ... canalplus is not working, may be this is because it is canalplusVOD .....

On the 2016 TV, there is now a native application installed named MyCanal used to connect to their programs. that is what I'm trying to get !

@zoelechat
I rebooted the TV and now canal is working ! So all good , I will try to implement this in my Jeedom domotic now !

On the 2016 TV, there is now a native application installed named MyCanal used to connect to their programs. that is what I'm trying to get !

mmmh that CanalPlusLauncher icon says MyCanal indeed, I've got 2016 TV too but can't find anything else related in store... OK saw you latest post :)
Here's Plex: kIciSQlYEM.plex

Plex is also working ! thanks

anybody knows how to send these commands via PHP ?

Hi all!
There is another way to launch/install/close app on Samsung TV - by using SmartView api:

# launch youtube
curl -X POST http://TV_IP:8001/api/v2/applications/111299001912

# get status
curl -X GET http://TV_IP:8001/api/v2/applications/111299001912

# close
curl -X DELETE http://TV_IP:8001/api/v2/applications/111299001912

# open installation page in Samsung store
curl -X PUT http://TV_IP:8001/api/v2/applications/111299001912

For dealing with another app just change the id 111299001912.

and launching a url...

btw @freman how did you managed to find metaTag field in #75 (comment)?
I don't see it even in native samsung android app..

@vitalets did you find any way to list the installed apps using the api/v2 interface?

@vitalets

Awesome, they followed RESTful principles on the v2 API. I'll test when I get home.

@WolfganP
Have you tried curl -X GET http://TV_IP:8001/api/v2/applications ? Maybe it will work.

@xalexslx No, curl -X GET http://TV_IP:8001/api/v2/applications doesn't work

{
  "status": 404,
  "message": "Not Found",
  "code": 404
}

I got how to start the web browser with google url using the REST API. However I cannot use it with other urls for some reason...

curl -X POST \
  http://X:8001/api/v2/webapplication/ \
  -H 'Content-Type: application/json' \
  -d '{"url": "http://www.google.com"}'

@Mcgurk125 facebook, yahoo, etc, nothing weird.

@vitalets did you find any way to list the installed apps using the api/v2 interface?

AFAIK it is impossible via api/v2. You can check all endpoints on the server side in Tizen sources.
The only way I know to get installed apps is using WebSocket to samsung.remote.control channel with message ed.installedApp.get mentioned here.
But combination of these two methods should be enough for everything.

I got how to start the web browser with google url using the REST API. However I cannot use it with other urls for some reason...
curl -X POST
http://X:8001/api/v2/webapplication/
-H 'Content-Type: application/json'
-d '{"url": "http://www.google.com"}'

This endpoint is for launching Samsung Cloud apps. The url must be approved by Samsung team to get opened this way. google.com is approved. Have a look on the docs about this feature.

@vitalets
It's possible to get the program list using api/v2 ?
Thx

@vitalets
It's possible to get the program list using api/v2 ?
Thx

If you mean channels list - no. Api/v2 is designed for managing your own tv app, nothing more.

But you can retrieve channel list inside tv app (tizen.tvchannel.getChannelList) and communicate with your app via api/v2.

@vitalets
Thanks, I knew that.
But I'm looking for a way to get access without installing an application on Smart TV. Do you think that's possible?

But I'm looking for a way to get access without installing an application on Smart TV. Do you think that's possible?

I never see that in any docs/forums, so I think it is not possible.
Even if you find such way, consider that any undocumented feature can be removed at some moment.

I have up trying to drive the tv, I wrote an app that is basically an iframe that opens a websocket to a server in the office for remote control. From there we make it load whatever we want.

Didn't even know API 2 existed, I wonder if I can use that to ditch the websockets

@freman

I wonder if I can use that to ditch the websockets

WebSockets also allow to launch/close/get-state of tv app, e.g:

// launch app
ws.send(JSON.stringify({
    method: 'ms.application.start',
    id: Date.now(),
    params: {
        id: '11101200001',
    }
}));

The method can be:

  • ms.application.start
  • ms.application.get
  • ms.application.stop
  • ms.application.install
  • ms.channel.emit (for custom messaging with app)

They all are also from Tizen sources.

Btw @freman how did you managed to find metaTag field in #75 (comment)? I don't see it in Tizen sources anywhere =)

Not those websockets, the ones our app uses it connects to a websocket server on the network giving us full direct control over the app, bypassing the tv os entirely.

No never did figure out that metadata

not an app but can the source of the tv be changed using the above methods? eg: HDMI1 ?

not an app but can the source of the tv be changed using the above methods? eg: HDMI1 ?

I think it is only possible to show "select source" panel.

Just wanted to say how useful this info was. I use homeassistant and the Samsungctl component isn’t working (NU7100). I instead setup switches to trigger the http commands, which in turn I can use in automations and routines invoked by Alexa (via haaska).

@mattmickeyj Can you please point me to your switches/automations for HA? I am also trying to do the same....thanks!

@arsaboo this is my switches to turn on Netflix etc.

switch:
  platform: command_line
  scan_interval: 1
  switches:
    utubeon:
      command_on: curl -X POST http://192.168.0.62:8001/api/v2/applications/111299001912
      command_off: curl -X POST http://192.168.0.62:8001/api/v2/applications/111299001912
      friendly_name: "Turn on Youtube"
      command_state: off
    netflixon:
      command_on: curl -X POST http://192.168.0.62:8001/ws/apps/Netflix
      command_off: curl -X POST http://192.168.0.62:8001/api/v2/applications/RN1MCdNq8t
      command_state: off
      friendly_name: "Turn on Netflix"
    plexon:
      command_on: curl -X POST http://192.168.0.62:8001/api/v2/applications/kIciSQlYEM.plex
      command_off: curl -X POST http://192.168.0.62:8001
      command_state: off 
      friendly_name: "Turn on Plex"

The spacing is out sorry. You don't need the scan interval or command state. I had it there to try and get my lights to dim when Plex started playing / paused but there was a delay 10 second in getting the status back and updating the state etc etc.

@pegatron89 That works perfectly...thanks!!

How did you obtain the app ids (e.g., 111299001912)?

@arsaboo No bother atal!

Just from this thread / google

The below comment has most of the correct app ids (Use the app id the same way as i have used it under plexon)

#75 (comment)

Hi everyone!
I'm searching for the document about this command
{"method":"ms.remote.control","params":{"Cmd":"Move","Position":{"x":-1000,"y":1000,"Time":"1518675746190"},"TypeOfRemote":"ProcessMouseDevice"}}

Could you please share this document to me
I can not find this document, 2 days searching, no result
Please help
Thanks

Hi @phanlam I'm afraid I have no documentation about this function, I got it sort of working by capturing debug logs, network traffic and decompiling the APK. I know it works as relative updates so you have to send it at least 2 copies of the commands to get it moving

Hi @freman
Thank you for your rely.
I'm looking for the "scroll up/down" (mouse) method.
Could you please help me?
Thanks!

This has been very helpful. On my 2018 Samsung frame, I am unable to connect due to authorization failure, but am able to launch apps a suggested above (curl post...). Any suggestions on how to turn on Art Mode on the frame. I suspect it is an app, but given my authentication problem I am unable to list all apps to then try running the art one. Any ideas?

Hi @vitalets ,
this works very well for me! Thank you very much!!!
Because for my TV (QE55Q6FNA) samsungctl seems not working, do you know a method to change channels and poweroff the TV?
Thanks in advance...

Hi @vitalets ,
this works very well for me! Thank you very much!!!
Because for my TV (QE55Q6FNA) samsungctl seems not working, do you know a method to change channels and poweroff the TV?
Thanks in advance...

You may setup websocket connection to ws://${tvIP}:8001/api/v2/channels/samsung.remote.control and send remote keys:

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

Hi @vitalets
Sorry, but I'm new to samsungctl and websockect.
I wrote this simple test.js following your indication, but I'm not sure to be right :

const WebSocket = require('ws');
ws = new WebSocket('ws://192.168.2.100:8001/api/v2/channels/samsung.remote.control');
ws.onopen = function() {ws.send('{"method":"ms.remote.control","params":{"TypeOfRemote": "SendRemoteKey", "Cmd":"Click", "Option":"false", "DataOfCmd": "KEY_CHUP"}}')};
ws.onmessage = function(e) {console.log(e)}

But the command node test.js returns:

MessageEvent {
target:
WebSocket {
domain: null,
_events: { open: [Object], message: [Object] },
_eventsCount: 2,
_maxListeners: undefined,
readyState: 1,
protocol: '',
_binaryType: 'nodebuffer',
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_closeCode: 1006,
_extensions: {},
_isServer: false,
_receiver:
Receiver {
_writableState: [Object],
writable: true,
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
_binaryType: 'nodebuffer',
_extensions: {},
_maxPayload: 104857600,
_bufferedBytes: 0,
_buffers: [],
_compressed: false,
_payloadLength: 36,
_mask: undefined,
_fragmented: 0,
_masked: false,
_fin: true,
_opcode: 1,
_totalPayloadLength: 0,
_messageLength: 0,
_fragments: [],
_state: 4,
_loop: true,
[Symbol(websocket)]: [Circular] },
_sender:
Sender {
_extensions: {},
_socket: [Object],
_firstFragment: true,
_compress: false,
_bufferedBytes: 0,
_deflating: false,
_queue: [] },
_socket:
Socket {
connecting: false,
_hadError: false,
_handle: [Object],
_parent: null,
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
_bytesDispatched: 404,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
parser: null,
_httpMessage: null,
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1,
[Symbol(asyncId)]: 6,
[Symbol(bytesRead)]: 0,
[Symbol(websocket)]: [Circular] },
url: 'ws://192.168.2.100:8001/api/v2/channels/samsung.remote.control',
_req: null },
type: 'message',
data: '{"event":"ms.channel.unauthorized"}\n' }
events.js:183
throw er; // Unhandled 'error' event
^

RangeError: Invalid WebSocket frame: invalid status code 1005
at Receiver.controlMessage (/root/node_modules/ws/lib/receiver.js:441:18)
at Receiver.getData (/root/node_modules/ws/lib/receiver.js:329:42)
at Receiver.startLoop (/root/node_modules/ws/lib/receiver.js:133:22)
at Receiver._write (/root/node_modules/ws/lib/receiver.js:69:10)
at doWrite (_stream_writable.js:396:12)
at writeOrBuffer (_stream_writable.js:382:5)
at Receiver.Writable.write (_stream_writable.js:290:11)
at Socket.socketOnData (/root/node_modules/ws/lib/websocket.js:794:35)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)

Any idea?
Thanks in advance

@shakabra

  1. You should wait for ms.channel.connect response before sending command
  2. I see ms.channel.unauthorized in the response. Maybe you should allow access on the TV: there can appear panel with buttons allow|deny.

Here is the full working code:

const WebSocket = require('ws');

const tvIP = '192.168.2.100';
const ws = new WebSocket(`ws://${tvIP}:8001/api/v2/channels/samsung.remote.control`);

ws.onopen = () => console.log('opened.');
ws.onclose = () => console.log('closed.');
ws.onmessage = message => {
  console.log('<--', message.data);
  const data = JSON.parse(message.data);
  if (data.event === 'ms.channel.connect') {
    ws.send(JSON.stringify({
      method: 'ms.remote.control',
      params: {
        TypeOfRemote: 'SendRemoteKey',
        Cmd: 'Click',
        Option: 'false',
        DataOfCmd: 'KEY_MUTE',
      }
    }));
    setTimeout(() => ws.close(), 1000);
  }
};

@vitalets
Thank you very much for your reply! You are very patient.
My device is correctly authorized because the first time that I issued the command:
curl -X POST http://192.168.2.100:8001/api/v2/applications/111299001912
it asked me for the authorization and I confirmed. Now the curl command works very well without asking me some other confirmation.
Unfortunately the problem persist and it drives me crazy...

node test.js

opened.
<-- {"event":"ms.channel.unauthorized"}

events.js:183
throw er; // Unhandled 'error' event
^

RangeError: Invalid WebSocket frame: invalid status code 1005
at Receiver.controlMessage (/root/node_modules/ws/lib/receiver.js:441:18)
at Receiver.getData (/root/node_modules/ws/lib/receiver.js:329:42)
at Receiver.startLoop (/root/node_modules/ws/lib/receiver.js:133:22)
at Receiver._write (/root/node_modules/ws/lib/receiver.js:69:10)
at doWrite (_stream_writable.js:396:12)
at writeOrBuffer (_stream_writable.js:382:5)
at Receiver.Writable.write (_stream_writable.js:290:11)
at Socket.socketOnData (/root/node_modules/ws/lib/websocket.js:794:35)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)

For some reason you are unauthorized. Try to remove your device from authorized (it's somewhere in menu) and try re-run script.

samsungctl does not work with 2018 models (like the QE55Q6FNA you referenced). In early August, Samsung changed something in a firmware update and now all third-party integrations are broken due to that authorization error. Have not found a workaround yet.

@cyphers @vitalets
Thanks for the reply, infact, it does not work neither if I remove my device from authorized...
The strange thing is that rather if I send this command:

curl -X POST http://192.168.2.100:8001/api/v2/applications/111299001912
it work correctly asking the authorization and executing youtobe...
At this point for me it's a mystery, because the authentication should be the same... or I'm missing something...

@cyphers thank you for that info. Much appreciated. Another thing of note is that the smart view app doesn't work with new 2018 models (at least not my 2018 frame), instead the new smart things app is the only one that recognizes the the TV and works with it.

For now, I have switched to Ex-link/USB via RasPi for control. Even Ex-Link over IP (port 1515) does not work.

Hi @alirazabutt
what model of 2018 do you have? Because I am not able to find the ex-link connection on my model QE55Q6FNA, if there is, it's well-hidden.

@shakabra I have UN43LS03NA, its 43" Samsung Frame, which comes with a one-connect box (single optical wire connection to TV). The physical Ex-link is like a stereo jack on the corner of the one-connect box. If you have one connect box look on the back or on the side (near optical audio connection), otherwise it should be on the back. It may be labeled service port.

Another thing of note is that the smart view app doesn't work with new 2018 models (at least not my 2018 frame), instead the new smart things app is the only one that recognizes the the TV and works with it.

@alirazabutt thanks for the info! It would be great if somebody with TV of 2018 catch the requests.

@alirazabutt
I think that in 2018 model of QE55Q6FNA they removed the ex-link and the one-connect box that was present in 2017 model...
I know how is made the ex-link because I'm using it on my 2013 samsung TV that I power on with it because it haven't WOL function.

@shakabra
Could you post the result of curl http://TV_IP:8001/api/v2/ of your 2018 TV?
And the user agent of browser - to know the exact version of Tizen. The simplest way I know is to open https://whatsmyua.info in TV browser.
Thanks in advance!

@vitalets
Thanks for the reply!
This is the result of http://TV_IP:8001/api/v2/:

   
device  
FrameTVSupport "false"
GamePadSupport "true"
ImeSyncedSupport "true"
OS "Tizen"
TokenAuthSupport "true"
VoiceSupport "true"
countryCode "IT"
description "Samsung DTV RCR"
developerIP "192.168.2.180"
developerMode "1"
duid "uuid:df830908-990a-4710-b2c0-5d18c1522f4e"
firmwareVersion "Unknown"
id "uuid:df830908-990a-4710-b2c0-5d18c1522f4e"
ip "192.168.2.100"
model "18_KANTM2_QTV"
modelName "QE55Q6FNA"
name "[TV] Samsung Q6 Series (55)"
networkType "wired"
resolution "3840x2160"
smartHubAgreement "true"
type "Samsung SmartTV"
udn "uuid:df830908-990a-4710-b2c0-5d18c1522f4e"
wifiMac "70:2a:d5:8f:5a:0d"
id "uuid:df830908-990a-4710-b2c0-5d18c1522f4e"
isSupport "{"DMP_DRM_PLAYREADY":"false","DMP_DRM_WIDEVINE":"false","DMP_available":"true","EDEN_available":"true","FrameTVSupport":"false","ImeSyncedSupport":"true","TokenAuthSupport":"true","remote_available":"true","remote_fourDirections":"true","remote_touchPad":"true","remote_voiceControl":"true"}\n"
name "[TV] Samsung Q6 Series (55)"
remote "1.0"
type "Samsung SmartTV"
uri "http://192.168.2.100:8001/api/v2/"
version "2.0.25"

Useragent reports:
major: 2
minor: 1
patch: 0
Thanks!

can you create a alexa skill for this code and lamba aws intance for hosting please!!!
or command can i use with home assistant

Is there a "full" "documentation" about the WS/HTTP API ?
Has anyone get some more advanced commands?, like:

  • get TV channel list
  • change TV settings (Video, Sound, Network, etc)
  • install/delete apps

Any documentation is welcome.

@mStirner all the documentation I know of is in this thread.

Not sure if you can get a full channel list, probably can if the samsung app can
AFIK the only way to change settings is to navigate like a pleb
Only app I've ever installed is our hand crafted upgrade on the build in web browser and that was via Developer mode

anyone willing to try sending this down their websocket connection

{
    "method": "ms.channel.emit",
    "params": {
        "event": "ed.appStateRequest.get",
        "to":"host"
    }
}

anyone willing to try sending this down their websocket connection

{
    "method": "ms.channel.emit",
    "params": {
        "event": "ed.appStateRequest.get",
        "to":"host"
    }
}

On Tizen 2.4:

--> {"method":"ms.channel.emit","params":{"event":"ed.appStateRequest.get","to":"host"}}
<-- {"event":"ed.appStateRequest.get","from":"host"}

I will say this folks. I got my hands on the Tizen source code. so with that I should be able to really expand the websocket functionality.

I located these methods thus far. I do not know if they wiill work or not. I do not know that params just yet. but I am getting there,

I am sure that these will need a param AppID or AppId something along those lines.

"method": "ms.application.get
"method": "ms.application.stop
"method": "ms.application.install
"method": "ms.application.start
"method": "ms.webapplication.get
"method": "ms.webapplication.stop
"method": "ms.webapplication.start

I did find the TypeOfRemote param but I have to follow the code path to see what can be used there.

here are over 23K files to the OS so trying to follow the code path is not that easy. especially when trying to work backwards. but all I have are specific things to look for which is at the end of the chain. then I have to search for object calls through all of the files. it's a lot of work.

I have not managed to locate ms.channel.emit or any piece of it. There has to be something for it.

I did discover this out tho. the same OS is used on the TV's the soundbars the wearables almost everything Samsung that is made now uses this OS. and if it doesn't then it probably will because there are subsets for each of the various devices that Samsung makes.

@kdschlosser I'm not going to lie, I'm a little bit turned on right now.

Just going to show off a project I'm hoping to open source soon (basically the reason I started down this path)

We have quite a few of these samsung tv's in the building, but those remotes suck.

image

image

The image icon launches our custom grafana app.

@freman

here is a link to a slack chat I created for samsungctl.
https://join.slack.com/t/samsungtvcontrol/shared_invite/enQtNTA0Nzc2MjY4MTgxLWNjNWI5ZjQwYTMzNzYxNjlkYTI5NTk1ZmJmMDU5ZjRmMDRhYTg4NGIzYWVjMzU3YzlmMzM5NWNjNWQ5MzU3NjA
you seem to have a really good grasp of how the websocket portion of this works. as well as discovering new functionality. I want to share the Tizen source code with ya. It is to much for a single person to dig through to find the websocket commands. they are all over the place. The source is written in C and Java mostly. not sure if you are familiar with, but you will know what to look for anyway. the source is for Tizen versions 1.0 to 5.0 and includes subsets for TV's, wearables, phones and many other Samsung products. if you are interested join that slack chat and send me a message. My alias is drschlosser on the slack chat.

hey all... so from reading through this, it shows examples of how to launch an app. Unfortunately I am not a real developer and didn't fully understand everything I've read. I am familiar with python, so would someone be willing to point me toward some examples using python to launch vudu on a samsung smart TV?

I do not know if this repository is being maintained anymore. I have set up a fork and have been adding to the library. I have added an easy way to launch apps (depending on the year your TV was made)

https://github.com/kdschlosser/samsungctl

What’s the easy way? I didn’t really see reference in the readme

you have to look at the combination branch. there is information in there about how to launch applications.

So, to identify if a particular application is installed you can use the call :
curl -X GET -i 'yourIP:8001/ws/apps/Netflix'
and and you will receive the answer : Netflixrunning6.0.003 OR Netflixstopped6.0.003

Hello,
I need to get the "PLAY", "PAUSE" and "STOP" status from videoplayer apps like Netflix to change lights and blinds of the room accordingly.
I've tried the above call as well as http://yourIP:8001/api/v2/applications/11101200001 but I can only get the "running" and "visible" state that are independent from the player status.
Do you have any hint on how to get such information?

I have not come across anything that will inform us of the "playing" state. I do not know if possibly that state will show in the DLNA information that is available via UPNP. I am currently working on adding thee UPNP components now. so we will be able to answer that question soon enough.

Tested with upnprenderer: DLNA information seems to be related to DLNA player only.

well that really stinks! I do want you to try something tho. If you send a UPNP stop command to the DNLA player.. does it stop playing? How crooked would that be if it did LOL.

I hope I got what you're asking
Tested with:

  • [TV] Samsung 7 Series (55) model UE55KS7500
  • Qnap TS212P NAS
  • OpenHab2 upnprenderer binding, connected to TV player
    Test:
  • I can send keys with samsungctl
  • I can get app status with e.g. http://IP:8001/ws/apps/Netflix
  • I can launch app on TV with e.g. wget -x POST http://IP:8001/api/v2/applications/111299001912
  • If I play a video from qnap to Tv via DLNA, I can get the "play" status on openhab as well as "stop-pause" (both detected as "pause")
  • I can play, stop, pause, resume the DLNA player from openhab.
  • If I play other content, like Netflix video on the TV nothing is detected by openhab
  • If I issue STOP command from openhab, Netflix player is not affected
  • If I issue START command from openhab, the DLNA content is resumed over Netflix

OK so now we have an answer to that. stop from UPNP will not stop the Netflix playback.

on another note II did manage to get the unittests functioning properly. and that helped me iron out all of the bugs in the application portion of samsungctl. so now that is working. I will push the code as soon as I am done.