Sony Bravia TV Integration - Discussion

Neither 50001, 80, or 3335 seem to work. Connection refused on 50001 and 3335, a 404 error on port 80

Edit: This is with a Bravia X850C set.

Shoot I meant 33335. But not a good sign if 8080 is closed

That link dint work for me either. Here the other link I found on the web : https://raw.githubusercontent.com/breunigs/bravia-auth-and-remote/master/commands

The content at OpenRemote is the best starting point for information, but you need to be aware that there are several different generations of sets with slightly different web service APIs and most people aren’t being particularly clear as to what set they’re testing with. The IP API seems more consistent across models but that’s not going to work without an external helper app which is a non-starter for me.

Hoping to see if we can get this working, I tried the link that @Kristopher asked us to try but it didn’t work. Then I saw the post from @hcgonzalezpr and tried the same link with port 52323 and it worked but I got a blank page with a 404 for the file

I have a x850c as well. Maybe we can see if there’s something we can do with Android? Doubtful ADB would be of use here but who knows lol.

Wading through the examples people posted on the OpenRemote page (and I know it’s confusing because it’s a hodgepodge of different things for different models), I was able to do all the basic things from curl and Postman, so I think the information is actually all there. I could get the x850c to pop up the remote app configuration screen with the code to use for getting the cookie and I was able to send a bunch of different commands. I think it would definitely be possible to create a nice driver for the current crop of 2015 Sony TVs (i.e. the Android-based X850c, X810c, X830c, X900c, etc.) but it does seem like if you try to create something general purpose that works across several years and models, you’ve got a lot of edge cases to support.

1 Like

Would you mind posting your CURL commands that worked for you? I’d like to take them and create a device handler once my TV arrives this Friday.

I’ll go through them again this weekend and copy the ones that work into a Pastebin. It was just trial and error and I was mostly just seeing if it was possible. Half the stuff on the OpenRemote page isn’t recognized and of the half that can be recognized, half of that won’t really work until you get the authentication flow done right and that part seems to be very different from model to model (although I suspect all the 2015 models are the same). Once you’ve authed and are sending the right headers, then you can just start seeing which ones work and which don’t.

1 Like

Okay, sounds good. Looking forward to being able to put together something useful. Once I’ve got the TV and such I can also probe the API and see what you may have missed.

Thanks for doing a lot of the leg work on this.

The TV model I got its a pre-android W600b. I don’t own a Android version one. I check one of the Android versions at best-buy and saw they provide serial access for enterprise control. There are multiple protocols on each generation of these TV. I have created a list so we can keep better track of it.

https://docs.google.com/spreadsheets/d/1kV5lYGAvMJVOYkomk_17Ng_XtK5y7KhGZzdG2X1yQD4/edit?usp=sharing

hi,

This thread is very interesting and i would love to get this to work!

Where would i find: HelperIP, HelperPort, HelperURL, TvIP?

I have managed to control the TV through simple rest client through following the link at http://www.openremote.org/pages/viewpage.action?pageId=22887143&focusedCommentId=23605578#comment-23605578

Any help would be appreciated.

Hi All,
Based on the link dthomp13 posted and the code from hcgonzalezpr I was finally able to get a smartthings SOAP call to work. Not sure if this will help any of you but I figured I would post it just in case. My TV ix an x850c. Before this can work be sure to set the TV for a Pre-Shared Key (details in the link from dthomp13 ).

Note to set up the x850c for a pre-shared key go to the following in the TV menus

Settings->Network->home network->IP Control->Authentication->Set to Normal and Pre-Shared Key

Settings->Network->home network->IP Control->Authentication->Pre-Shared Key-> Set to a Key to use for controls (in the example from the link above the key is 1111).

Finally the code that worked for me is:

//so this sends the correct SOAP code to the TV.  The code below is a Wake On Lan code.
def on() {
def rawcmd = "AAAAAQAAAAEAAAAuAw=="  //Wake On LAN
def ip = "192.168.1.202" //TV's IP
def port = "80"          //TV's Port
    setDeviceNetworkId(ip,port)
    log.debug( "Device IP:Port = ${ip}:${port}" )
    
    def sonycmd = 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}", 'X-Auth-PSK':"1111"]  //pre shared key (make sure TV is set up for Pre-shared Key!
    )
    sendHubCommand(sonycmd)

    log.debug( "hubAction = ${sonycmd}" )
    log.debug "Executing 'on'"
}
1 Like

Although I think this information has already been discussed, this blog post explains the code at the https://github.com/breunigs/bravia-auth-and-remote GitHub repo.

hi,

has anyone built a app yet for the code above?

thanks

Dale

I am wondering the exact same thing, I would love to have an app for this.

I’m really interested in getting this working, but I’m a bit stuck. I’m new to the SmartThings platform, but have a fairly good technical understanding (I work in IT and have previously been a developer). I understand the principles involved, but at the moment I seem to have too many confounding factors to understand why I can’ make this work.

What I’ve done so far:

  1. Created a Device Handler using the code from @CRubio above. I’m not sure if this code is supposed be used in this way. I have the device configured as a switch with commands which send the On (rawcmd = “AAAAAQAAAAEAAAAuAw==”)/ Off (rawcmd = “AAAAAQAAAAEAAAAvAw==”) messages.

  2. Enabled Simple IP control on my Sony X8309C (pre-shared key to 1111) and confirmed that it’s using port 5353 by looking at the network traffic from the Sony Remote app using Wireshark.

Questions:

  1. Can anyone point me in the direction of a tutorial for creating device handlers which control devices using IP control? I’ve searched but can’t find anything.
  2. Does running the code I’ve created for the device handler through the IDE in simulator code actually send the messages via the network? When I use the ‘On’ and ‘Off’ buttons under Tools I get the debug messages but can’t see the network traffic using Wireshark.
  3. Why don’t I see a Switch tile in the simulator using my code?

I’ve added my code here:

So I had a lot of trouble with the simulator and getting the tiles to work easily in it (I gave up and started to use my phone instead). Ultimately I came up with the following (see below - momentary button copied from another thread not my own), but it was admittedly half assed. The more I looked at the code the more I realized that I would have to come up with a device handler for each control function (or function pairs like on/off). So I just decided to create momentary buttons in the device handlers. This way at least I could create something akin to the actual TV remote control
but I would have to create a device handler and then a device for each function. Not very extensible.

I finally ended up using the Alexa Helper app to help making control more extensible, but that app for now just does local IP control using the HubAction and not the HubSoapAction. Wish I could be more helpful but wanted to reply with something more than just dead air


Hopefully you can work through the issues you are seeing


/**
 *  Momentary Button Tile
 *
 *  Author: SmartThings
 *
 *  Date: 2013-05-01
 */
metadata {
	// Automatically generated. Make future change here.
	definition (name: "Bravia_On", namespace: "CRSounds", author: "Carlton Rubio") {
		capability "Actuator"
		capability "Switch"
		capability "Momentary"
		capability "Sensor"
	}

	// simulator metadata
	simulator {
	}

	// UI tile definitions
	tiles {
		standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "off", label: 'Push', action: "momentary.push", backgroundColor: "#ffffff", nextState: "on"
			state "on", label: 'Push', action: "momentary.push", backgroundColor: "#53a7c0"
		}
		main "switch"
		details "switch"
	}
}

def parse(String description) {
}

def push() {
	sendEvent(name: "switch", value: "on", isStateChange: true, display: false)
	sendEvent(name: "switch", value: "off", isStateChange: true, display: false)
	sendEvent(name: "momentary", value: "pushed", isStateChange: true)
    def rawcmd = "AAAAAQAAAAEAAAAuAw=="  //Wake On LAN
    def ip = "192.168.1.202"
    def port = "80"
	setDeviceNetworkId(ip,port)
    log.debug( "Device IP:Port = ${ip}:${port}" )
	
    def sonycmd = 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}", 'X-Auth-PSK':"1111"]  //pre shared key (make sure TV is set up for Pre-shared Key!
    )
    sendHubCommand(sonycmd)

    log.debug( "hubAction = ${sonycmd}" )

    log.debug "Executing 'push'"
}

def on() {
	push()
    log.debug "Executing 'on push'"
}
def off() {
	push()
    log.debug "Executing 'off push'"
}

It’s looking like it may make more sense to use the JSON-RPC API rather than the SOAP API. The reason is because if you want to create a single switch to turn on and off the TV, you’ll need to use polling to get the TV power status, which is made through a getPowerStatus JSON-RPC call. I took a stab at creating a version of @jamieyates79’s example but using the JSON-RPC API and having it poll for the TV state. Here’s the code: https://gist.github.com/edanuff/3d8656db80580fea16e2d409ac8f5ccb

Note: It’s very important that the device network ID is set correctly or polling won’t work. The next step of making this work would be to create a SmartApp that properly sets up the device handler with the correct device network ID.

Edit: It may be possible to check on the state of the TV via subscribing to UPnP events which would be better than polling.

cool. this is working for me. I’m going to look into UPnP as I’d like to know when the TV status when it is manually turned on.