Does SmartThings control a Samsung Smart TV?

I’m getting a lot of back-n-fourth on Google, and even these forums. It leads, quite often, to mentioning Extend.

I’m trying to decide to buy SmartThings, or the newest Vera. The reason I’m leading towards SmartThings is to be able to control my TV (JS9000), but I’m confused. (I also have 2 other Samsung Smart TVs I’d like to add to it)

Will I be able to add them as a ‘device’ and include them on themes/whatever the term is, and get ‘current state’, or no?

Im also new to SmartThings, but as far as I know, there is no way to control J series (2015) TVs. I was able to modify a device handler I found in forum to get my J series TV current state to show in SmartThings and turn lights on/off based on its state (that’s all I need). It basically pings the TV and changes switch to on/off based on if TV is on.

There are some device handlers for older TV’s (these don’t work with J and K series) but I have not tested these yet on my H series.

There are two device handlers for J and K series in developer tools, so it appears Samsung or SmartThings is working on it, but these don’t work yet. No idea if or when these will work. I believe I read somewhere in this forum that these require hub firmware update to work.

Hey @poisike - Thanks for the reply.

Do you happen to remember the handler you saw? I’m going to go get a ST Hub to play with tomorrow to see. Honestly just getting it’s state is enough to do what I want. I’m mostly just getting a Z-Wave ‘hub’ set up and almost nothing can ACTUALLY get the state of my TV - My Entertainment console isn’t smart so I can’t base it off of it (They’re CEC’d, so if one is on, they’re both on).

Now that you mention it, my TV hasn’t updated in forever. Which is a shame considering the ‘smart box’ and how ‘upgrade-tastic’ it would make them.

Appreciate if you could link the handler!

I modified this device handler > https://github.com/KristopherKubicki/device-type.http-ping
I needed to change line 136 to make it work on SmartThings Hub V2.
I also changed it from contact sensor to switch. And modified it look more modern (as SmartThings developer docs recommend).

This is what I’m using:

[code]/**

  • HTTP Ping
  • Copyright 2014 Kristopher Kubicki (Modified by poisike)
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

*/

preferences {
input(“dest_ip”, “text”, title: “IP”, description: “The device IP you wish to ping”)
input(“dest_port”, “number”, title: “Port”, description: “The port you wish to connect to to emulate a ping”)
}

metadata {
definition (name: “Ping Switch”, namespace: “poisike”, author: “poisike”) {
capability "Polling"
capability "switch"
capability “Refresh”

    attribute "ttl", "string"
    attribute "last_request", "number"
    attribute "last_live", "number"
}

simulator {
	// TODO: define status and reply messages here
}

tiles (scale: 2) {
	standardTile("switch", "device.switch", width: 6, height: 4, canChangeIcon: true) {
        state "on", label: 'ON', backgroundColor: "#79b821", icon:"st.Electronics.electronics15"
        state "off", label: 'OFF', backgroundColor: "#ffffff", icon:"st.Electronics.electronics15"
    }
    standardTile("refresh", "device.ttl", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
        state "default", action:"polling.poll", icon:"st.secondary.refresh"
    }
    standardTile("ttl", "device.ttl", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
        state "ttl", label:'${currentValue}'
    }
	main "switch"
    	details(["switch", "refresh", "ttl"])
	}
	// TODO: define your main and details tiles here
}

def parse(String description) {
log.debug "Parsing ‘${description}’"
def map = stringToMap(description)

// def headerString = new String(map.headers.decodeBase64())
// def bodyString = new String(map.body.decodeBase64())
// log.debug “Parsing ‘${headerString}’”
// log.debug “Parsing ‘${bodyString}’”

def c = new GregorianCalendar()
sendEvent(name: 'switch', value: "on")
sendEvent(name: 'last_live', value: c.time.time)
def ping = ttl()
sendEvent(name: 'ttl', value: ping)

log.debug “Pinging ${device.deviceNetworkId}: ${ping}”

}

private ttl() {
def last_request = device.latestValue(“last_request”)
if(!last_request) {
last_request = 0
}
def last_alive = device.latestValue(“last_live”)
if(!last_alive) {
last_alive = 0
}
def last_status = device.latestValue(“status”)

def c = new GregorianCalendar()
def ttl = c.time.time - last_request
if(ttl > 10000 || last_status == "Down") { 
	ttl = c.time.time - last_alive
}

def units = "ms"
if(ttl > 10*52*7*24*60*60*1000) { 
	return "Never"
}
else if(ttl > 52*7*24*60*60*1000) { 
    ttl = ttl / (52*7*24*60*60*1000)
    units = "y"
}
else if(ttl > 7*24*60*60*1000) { 
    ttl = ttl / (7*24*60*60*1000)
    units = "w"
}
else if(ttl > 24*60*60*1000) { 
    ttl = ttl / (24*60*60*1000)
    units = "d"
}
else if(ttl > 60*60*1000) { 
    ttl = ttl / (60*60*1000)
    units = "h"
}
else if(ttl > 60*1000) { 
    ttl = ttl / (60*1000)
    units = "m"
}
else if(ttl > 1000) { 
    ttl = ttl / 1000
    units = "s"
}  
def ttl_int = ttl.intValue()

"${ttl_int} ${units}"

}

// handle commands
def poll() {

def hosthex = convertIPToHex(dest_ip)
def porthex = Long.toHexString(dest_port)
if (porthex.length() < 4) { porthex = "00" + porthex }
device.deviceNetworkId = "$hosthex:$porthex" 

// log.debug “The DNI configured is $device.deviceNetworkId”

def hubAction = new physicalgraph.device.HubAction(
	method: "GET",
	path: "/"
)        


def last_request = device.latestValue("last_request")
def last_live = device.latestValue("last_live")
if(!last_request) {
	last_request = 0
}
if(!last_live) {
	last_live = 0
}

def c = new GregorianCalendar()

if(last_live < last_request) { 
	sendEvent(name: 'switch', value: "off")  
    sendEvent(name: 'ttl', value: ttl())
}
sendEvent(name: 'last_request', value: c.time.time)

// log.debug hubAction

hubAction

}

private Long convertIntToLong(ipAddress) {
long result = 0
def parts = ipAddress.split("\.")
for (int i = 3; i >= 0; i–) {
result |= (Long.parseLong(parts[3 - i]) << (i * 8));
}

return result & 0xFFFFFFFF;

}

private String convertIPToHex(ipAddress) {
return Long.toHexString(convertIntToLong(ipAddress));
}[/code]

In Ping switch settings enter Your TV IP and for J series TV, enter port 8000. You can also edit the device name to Samsung TV or what ever You like.
You also need to install Pollster Smartapp, set it to poll the Ping switch device and set the desired poll time there. "Pollster" - A SmartThings Polling Daemon

This works for me, but like I already wrote, I’m new to SmartThings and Groovy, so I don’t take any responsibility if the device handler causes any problems. All credit goes to the original developer.
Hope this helps.

1 Like

@poisike

Thanks a lot for this. I have no idea what happens once I ‘install’ this to smartThings. Greatly appreciate your updated script, and explanation. I’m going to Best Buy to buy a ‘temporary’ one - I’ll let you know.

Hopefully this can provide functionality closer to what I want. I bought a Harmony Hub but ended up returning it since I’d need multiple hubs for my effect. It was a nice way to make ‘dumb things’ smart.

(I’ve started grouping my JS9000 with the dumb things because it’s web service is a PITA to use)

The situation is bizarre. I’ve been waiting almost a year to buy a Samsung TV for my kitchen/diner because I always think that full compatibility is just around the corner. In that year, I’ve seen great DHs written for other big makes and budget brands of TV.

ST is not helping to sell Samsung TVs!

I dont think its a good idea to buy a TV based on ST integration or Samsung promises. I have been burned too many times by Samsung promises.
Buy a TV that has good picture and based on the features it currently has, not promised to have soon. Soon is a strange timeframe for tech companies, it can mean from tomorrow to never.

1 Like

I recommend a Harmony remote for controlling you TV.
-Tom

I personally don’t like Harmony, the remote is too big and has too many buttons that I never use.
I’m waiting for Neeo… It has z-wave built in, so in theory it could have much better integration (as far as I understand).

At this point, I would not buy any component that lacks network control… or lacks availability of the protocol for my use. I own the unit; why should I be denied the means to control it? So I have no qualms about hunting down resources that provide those codes, regardless of whether they are ‘published’ or not. And if I can’t find a source, I won’t purchase the product.

Btw, there is an alternative to the Harmony: an android phone/tablet with an IR blaster. I have one, and of course you can use Tasker to send intents to software that accesses the blaster. But if I need to do that, there’s little point in investing in a new TV.