Samsung Smart TV Control With Smartthings/Webcore

Is it possible to get more control over a Samsung tv using Smartthings? The app just lets me change channel and volume and turn the tv on or off. How am i supposed to switch source or use a tv app like Netflix? i still need the remote. This also makes automation very hard, i cannot even switch activity.

I did notice the option ‘setinputsource’ in webcore , but i cannot get it to work, nor can i find any info about it. For Netflix i use the built in tv app, So the setsource wont even work for netflix probably since its an app, not a source.

I have 4 different activities. Watch tv, watch Netflix, use pc and play internet Radio/ Spotify.
My goal is to have 4 different buttons on actiontiles/smartthings to activate the activities using webcore. Im also using a Denon receiver which i can control with smartthings and change source etc. Why with Denon it works easily with a custom DTH found on this community and i struggle with the Samsung tv which is officially supported.

Hopefully any of you already have this issue fixed. I would very much appreciate any help or tips!

I hear ya. I ended up going with harmony smart remote for smartthings integration :slight_smile: hopefully somebody else has a better solution. The harmony controls my tv, gaming consoles, dennon, led back lighting, and works with the google assistant natively as well as ST. Not bad for $60. Also sidenote, I recently discovered the DENNON GUI by going to it’s local IP address, how did I not know about that for so long!

Does Harmony and WebCore work well for you? I have had nothing but issues where WebCore doesn’t know which activity is on to preform actions. It’s frustrating and I ended up using room manager to run my pistons.

i haven’t used Harmony much with webcore, I’m assuming only the Harmony routines are exposed to webcore like ST but not the Harmony devices.

i have a similar issue where people turn on the TV with the Samsung remote and the tv randomly doesn’t report as switched on to ST, so Harmony doesn’t auto start the Watch tv activity. then voice commands like volume up don’t work since Harmony tells Google no activities are running . It’s pretty rare though. Usually the tv reports as on in ST.

Yes. Well you can expose devices with kukuharmony but I think the API isn’t working anymore. Haven’t looked in a while. But yeah ST/WebCore was never able to know if a activity is on, has been on or off. This was something I needed but never worked correctly.

The harmony api works just fine. You just have to re-enable mqtt in the Harmony app if you have updated your hub with the December 2018 security patch from Logitech. KuKu explained this to me here:

and I got my KuKu working again perfectly. The combination of Alexa and WebCore and KuKu means you have all the control you ever need of our smart TV these days.

Harmony is an option yes. It’s also how i currently control the tv. But for me it is just too slow and unreliable. Sometimes it reacts in 1 second. Most off the times it takes a minute. Tried many different things, but havent been able to fix it.

KuKuHarmony is cool but needs a server which i do not have. Plus it still needs the Harmony.
What i want is just a few commands in ST itself so i can stop using the Harmony at all.

How is it possible i can completely control my Denon receiver and other stuff with ST. But i cannot do the same with my tv? Its from the same company as ST… and just for this 1 thing im forced to use Harmony.
I feel like there should be a way to do this. I dont know how, but i cant be the only one who wants this. Theres many Samsung tvs around!

1 Like

@John010 I figured out how to control the apps and source inputs on my TV with SmartThings and WebCore. This also allows the use of Alexa to “turn on Netflix” and the TV will turn on and open the Netflix app. I have this working for: Netflix, Amazon Prime, Disney+. I can also control input sources by name. So my Apple TV is on an input and the PS3 is on another. Again, using Alexa (or the SmartThings app) I can turn on the TV and it’ll switch to those.

Are you still interested in knowing? It’ll take me time to write it up so I want to make sure there is still a need.

3 Likes

I will like to know.

Are you able to send discrete commands to devices outside of using the activities?

If so, I’d love to see it as well.

I’m writing it up now.

What kind of discrete commands are you looking to send?

There are two URL patterns to start an app on a 2019 Samsung Smart TV. If one pattern doesn’t work for an app, try the other one.

Pattern 1
http://TV_IP:8001/api/v2/applications/APP_ID
e.g. 192.168.1.202:8001/api/v2/applications/MCmYXNxgcu.DisneyPlus

Pattern 2
http://TV_IP:8001/ws/apps/APP_ID or APP_NAME
e.g. 192.168.1.202:8001/ws/apps/Netflix

Your URL should start with http://. I had to remove the http:// from the e.g. lines because new forum users can’t post more than two links.

Prerequisites

In the end, I couldn’t find all the app IDs I wanted (see: Disney+) and wrote a quick application I installed on the TV to have it dump the application IDs. If you need the application, I can post it. You’d need to be comfortable turning on developer mode on your TV and running a web app on it built from the Tizen IDE (you’ve always wanted to be a Tizen developer, right? :slight_smile:).

Some additional quick thoughts before the Meat and Potatoes How-To:

  • In the examples above, DisneyPlus didn’t work in pattern 2 but it worked with pattern 1. You’ll just need to experiment.
  • Some apps work as just the app name (it’s case sensitive), like Netflix, others require the app ID, MCmYXNxgcu.DisneyPlus.
  • A quick way to test (outside of SmartThings and WebCore),
    • Turn on the TV
    • Send this command (replace TV_IP and whichever URL pattern you’re testing) from a terminal on a computer on the same Wi-Fi network as your TV:
      curl -X POST http://TV_IP:8001/ws/apps/Netflix
      curl -X POST http://TV_IP:8001/api/v2/applications/Netflix
    • Netflix should open. If it does, now you know which url will work for Netflix and can be used inside WebCore. If either URL doesn’t trigger the app to open then your TV may not support these two patterns.

How-To Part 1!

Create virtual switch device

  1. You need virtual switches to toggle your apps ON. Go download the Samsung SmartApp named “Virtual Device Creator”. It’s in the More tab of the SmartApps download area in the SmartThings Classic app. If you can find it in the new app, it may also work in there. I used the classic app to set these up.
  2. Open Virtual Device Creator and create a new switch. My account has issues so I couldn’t use a momentary switch. If you can use that, then your setup can omit later steps where we switch off our switch once we execute a command.
  3. Name the switch “Netflix” and save.
  4. Go to the WebCore SmartApp and add the new virtual switch as a device that can be used by WebCore.

Create WebCore piston

  1. Create a new piston from the web dashboard on a desktop browser (so much easier to read than mobile).
  2. Name it “Netflix”
  3. In the settings (gear icon) for the piston, turn on “disable command optimizations” .
  4. In the If condition, choose your new switch named Netflix.
  5. Create the piston logic like so
  6. Note that if you created a momentary switch instead of a toggle switch (back in step 2 of virtual device creation), then you can omit the last five lines in the piston to turn off the switch again.
  7. Save the piston.
    *Note that there is a command on line 23 to turn the TV on. This is mandatory. It has to be on to switch apps :wink: .

At this point stop and test. With the TV off, go hit the Netflix button in SmartThings. If it turns on, then you can end here and go create more.

…more in next post…

1 Like

How-To Part 2!

Steps for changing TV inputs by name:

Create a named input on your TV.

  1. You’ll need to poke around the menus on your TV to figure this out. I have my Apple TV on HDMI 1 and the Playstation 3 on HDMI 2. I named my inputs “Apple TV” and “PS3”.

Create a virtual switch

  1. Same as above except name it the input name.
    If you plan on using these with Alexa: Inputs like PS3 need to be spelled out. E.g. my switch is named “PS Three”.

Create the WebCore piston.

  1. Same steps as above, except we need to create a WAIT timer to give the TV time to turn on before switching inputs.
  2. Note on the setInputSource value, it’s the name of the input that you gave it in the TV.
  3. Note that if you created a momentary switch instead of a toggle switch (back in step 2 of virtual device creation), then you can omit the last five lines in the piston to turn off the switch again.
  4. Save it.

Now test it same as above. If it doesn’t turn on and switch to the correct input, try increasing the WAIT timer by 1 second until it does. I found anything less than 5 seconds wasn’t picked up consistently by the TV. I got mixed results at 3 seconds.

Bonus

Alexa integration:

  1. With the SmartThings skill enabled in Alexa…
  2. Tell Alexa to discover new devices. Wait until it finishes.
  3. Say “Alexa, turn on Netflix”.
  4. Amaze your family with your wizardry!

Hope this was helpful. Let me know if you run into issues or if I need to clarify anything.

Happy integrating!

Sovenger,

Thanks for your insight.
I tried to implement your solution but for some reason webcore can send commands to my tv (like channelDown()) but it does not respond to the URL call.

If I execute curl -X ip it actually works from my computer (although I have to autorize on the TV)

Should I need to somehow autorize the webcore url call on the tv?

Thanks mate. This looks very promising!

Hi Sovenger,

Thats a very nice trick. I managed to got it working for the Netflix app. Press a button on action tiles and netflix opens on the tv. Perfect! The part 2 part i already had running pretty much the same way as you did it.
Just 1 problem with part 1 which i cant seem to find a solution for. When i start Netflix using ST obviousely ST knows about it. But when i start netflix using just the tv remote i cannot figure out how to let ST know that netflix is running. Did you manage to get this working? The trouble is that it does not use a source input like tv or pc. So im not sure how to do this.

Hey! Just saw your response. I thought i’d be notified when someone wrote back to the thread, sorry for the delay. I’m heading out of the house at the moment but i’ve set aside sometime when I get back to respond properly. WebCore shouldn’t need any extra authentication since it operates like the curl call - when a web request is made to the TV from a device that it hasn’t seen before, the TV should prompt you to allow or deny it. I’ll have to test on mine to see if webcore causes that popup to show.

Glad to hear its working! I’m just heading out of the house now. Let me put some thought to your question and i’ll get back to you.

update
Back now. As far as I can tell, communication with the TV is a one way path. We can send commands to it, but receiving events when things happen on that TV doesn’t seem possible. I believe the reason is because the TVs were moved from local control in 2016 to cloud control after that. I’m looking into ways we can receive events from the TV’s cloud device handler. Maybe registering for web socket events or something?

In the meantime, you could setup a WebCore piston that polls the TV at the /ws/apps/Netflix URL and parse the XML response, looking for the value in the <state> tag. Mine says “running” when the app is open.

<?xml version="1.0" encoding="UTF-8"?>
<service xmlns="urn:dial-multiscreen-org:schemas:dial" dialVer="2.1" xmlns:atom="http://www.w3.org/2005/Atom">
    <name>Netflix</name>
    <options allowStop="true"/>
    <state>running</state>
    <version>8.0.0</version>
    <link rel="run" href="run"/>
</service>

I’m back now. Can you send a screenshot of what your piston looks like when you’re trying the URL?

I was able to clear out the granted permissions on my TV and try the request again to turn on Netflix from WebCore. My TV asked me to allow or deny it.

I really have no idea how to implement what you are suggesting with the xml doc. I will have to look into that. But good to hear there might be a possibility to get the status of the netflix app and act on it. It is pretty much the last thing i have not figured out yet about the tv. If i understand correct the idea is this:
Get an xml response from location and add a webcore rule like below:
IF state of (Netflix tv app url) = ‘Running’, THEN (insert task)

You got it. I am investigating the implementation now. More soon.

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.