Sony Bravia TV Integration - Discussion

Hey everyone,

I am seeing more TV integration discussions, but it seems Sony’s TV has not come up. I personally have one of the 2015 Series 4k TV’s, and see it has a lot of power behind it. Powered by Android, and from what I found on OpenRemote, it seems that it does have REST HTTP/POST functionality. OpenRemote Commands

Ultimately, I am looking for key things. Turn on/off TV, switch input, maybe run Netflix. As everyone can imagine, this is to eventually get lazier. Walk in room, turns lights on dim, turns TV on, switches input to TV (my PC), etc.

I am currently reviewing other peoples solutions TV integration, but wanted to start an open discussion to see if anyone has interest in this, or perhaps in assisting in development of it. Seems OpenRemote’s forums go into how to configure the 2015’s WOL to be enabled, etc. Seems there is an “authorization” process to do on the TV to authorize a device to WOL.

Still doing discovery, but anyone have thoughts on this? Sure a bunch of people have these (nice) TV’s.

Thanks guys!

2 Likes

I have one arriving tomorrow… :smile:

if it has REST support then you should be able to create a devicetype for it which will pass the appropriate HTTP GET/POST commands using the hubAction command.

Yep, that is what I intend to pursue. I have hacked together a small device type for my irrigation before (etherRain), I figure this is worth a quick attempt.

Let me know if you need a tester when you have something. I’ll have an X830C model as of tomorrow.

It will be a while. I am playing with it, but my schedule doesn’t allow aggressively attacking this, as I am hacking along my understanding of groovy at the same time.

Upon evaluation, seems hubAction will be perfect for this, but generating a query from the sample I have to work with is not a simple to figure out as I had hoped.

This is what I was given as a sample:

Query:
{“id”:13,“method”:“actRegister”,“version”:“1.0”,“params”:[{“clientid”:“iRule:1”,“nickname”:“iRule”},[{“clientid”:“iRule:1”,“value”:“yes”,“nickname”:“iRule”,“function”:“WOL”}]]}

Anyone have thoughts on how this might be able to be broken down into a query the hub can process?

the easiest way to figure out what to pass into the hubaction command is to figure out what URL to use from a web browser to get the TV to respond. It would be something like: http://user:pass@IP:PORT/Command

I’m already trying to work on this, I got the tv to turn on and off, still learning how to program the app.

private String sonyIpAction(cmd) {
log.debug "Executing IP command : " + cmd

def port = "20060"
def portx = convertPortToHex(port)

def ip = "YOUR.TV.IP"
def ipx = convertIPtoHex(ip)

device.deviceNetworkId = "$ipx:$portx" 

def rawcmd
def text

switch (cmd) {
case “power_on”:
rawcmd = “*SCPOWR0000000000000001"
text = “Power On"
break
default:
rawcmd = “”
}
def action = new physicalgraph.device.HubAction(””"$rawcmd\nHOST: $ip:$port\r\n\r\n""", physicalgraph.device.Protocol.LAN, “${ipx}:${portx}”)
sendHubCommand(action)
log.debug "command sent"
sendEvent(name:“Command”, value: text, displayed: true)

}

private String sonySoapIRCCAction(cmd) {
log.debug "Executing SOAP command : " + cmd

def port = "80"
def portx = convertPortToHex(port)

def ip = "YOUR.TV.IP"
def ipx = convertIPtoHex(ip)

device.deviceNetworkId = "$ipx:$portx" 

def rawcmd
def text

switch (cmd) {
case “power_on”:
rawcmd = "*SCPOWR0000000000000001"
text = "Power On"
sendEvent(name:“switch”, value:“on”)
break
case “power_off”:
rawcmd = "AAAAAQAAAAEAAAAvAw=="
text = "Power Off"
sendEvent(name:“switch”, value:“off”)
break
case “enter”:
rawcmd = "*SCIRCC0000000000000037"
text = "Enter"
break
case “up”:
rawcmd = "*SCIRCC0000000000000009"
text = "Up"
break
case “down”:
rawcmd = "*SCIRCC0000000000000010"
text = "Down"
break
case “right”:
rawcmd = "*SCIRCC0000000000000011"
text = "Right"
break
case “left”:
rawcmd = "*SCIRCC0000000000000012"
text = "Left"
break
case “getInput”:
rawcmd = "*SEINPT################"
text = "Get Input"
break

default:
    rawcmd = ""

}

def action = new physicalgraph.device.HubSoapAction(
    path:    '/sony/IRCC',
    urn:     "urn:schemas-sony-com:service:IRCC:1",
    action:  "X_SendIRCC",
    body:    ["IRCCCode":rawcmd],
    headers: [Host:"${ip}:${port}", CONNECTION: "close",'Cookie':"auth=PLACECOOKIE HERE"]
)   
sendHubCommand(action)

log.debug  "command sent"
sendEvent(name:"Command", value: text, displayed: true) 

}

2 Likes

Wow, yeah you have taken it further then I was intending, as I was just going for the basics. How long did it take you to get this far?

I have been working on this for about a week but only 2 hours per day.

But its mostly trying to learn how to code the code correctly for the Smarthub.

Right now i’m stuck trying to get the Smarthub to know if the TV was turn on/off by the IR remote control.

Ah yes, that I can understand entirely. Let me know if there is anything I can do to assist. If you sent me (pm) the code, I would be more than happy to review / assist in any way possible. I use to be a programmer, still learning groovy… but strategy or testing, I am more than available to assist.

With network based devices you will have to ‘poll’ or ‘refresh’ the device in order to get its status. Because it is not directly linked to SmartThings (ST hub pushes to the TV, the TV doesn’t push to ST) you won’t get any feedback from the TV unless you directly call for it.

@blebson thats the route im trying to take, Im querying the device power status via soap, but i’m not sure how to make the ST poll every 30sec, or if I can use Upnp callback to get information, but not sure how that works, im looking at how the Sonos does it.

Found someone that tried to pull informaiton in python, but not sure how helpful would it be.
( https://github.com/bunk3r/braviapy/blob/master/bravia.py )

I think the polling app pollster may function for that… Familiar with it?

I saw a couple mentions of it, haven’t look at it, I’ll have a look at it and try to incorporate how that one works to the app i’m making for this device.

Get a chance to check this out yet? :smile:

I gave up on using the soap protocol, and instead used the TCP/IP protocol for my tv. ( The soap code is still commented. )

Since the Hub still does not support reply from TCP, im using a php script as proxy for the commands I want to read response. It still a work in progress a lot of it is broken, but it turns off and on. Coding this as hobby, so its not documented at all. I’ll try to keep updating the code and eventually write some useful documentation.

*The php code just need to be run local server.

Can those of you with Sony devices write what device you have, and post the contents of this?

http://:50001$ip/cers/ActionList.xml

Supposedly there is a CGI gateway on many Sony devices (Bravia TV, AV Receiver, Blu-ray) that can add more information for us. The service might be on port 80 or 3335 as well

Thanks!

Yeah I will asap.

20chars