After reading a lot… and testing to, I was able to completely control my Sony Bravia tv from my Vera.
I’m sure everything is already documented elsewhere but I tough this might help.
(Note : I’m not technical, just playing around )
First, configure your TV to allow remote control :
-
Enable remote start on your TV: [Settings] → [Network] → [Home Network Setup] → [Remote Start] → [On]
-
Enable pre-shared key on your TV: [Settings] → [Network] → [Home Network Setup] → [IP Control] → [Authentication] → [Normal and Pre-Shared Key]
-
Set pre-shared key on your TV: [Settings] → [Network] → [Home Network Setup] → [IP Control] → [Pre-Shared Key] → [WhatEveryouWant]
-
Enable Remote device/Renderer: [Settings] → [Network] → [Home Network Setup] → [Remote device/Renderer] → [Remote device/Renderer] → [On]
-
Enable Remote device/Renderer: [Settings] → [Network] → [Home Network Setup] → [Remote device/Renderer] → [Remote access control] → [Auto access permission] → [on]
-
Get you TV a static IP for obvious reasons…
So, the Sony Bravia TVs can be remotely controlled multiple ways… IR, RS232, and IP.
I was more concerned about controlling it by IP.
So there is 2 way to control it by IP. (low level and high level protocol).
I first started with High level protocol that involve sending http post request to the device. (require pre shared key with the TV).
With high level protocol, request is sent to the tv using IRCC commands that mimic IR (see IRCC commands below). Here is a simple lua code for doing so: I had to add some sleep time between commands because the tv wasn’t catching everything:
function SendCommand(Command)
local socket = require 'socket'
local SONY_IP = "Your TV IP here"
local SONY_URL = "http://Your TV IP here/sony/IRCC"
local AUTH_CODE = "Your pre shared key here"
local http = require("socket.http")
local ltn12 = require("ltn12")
local respBody = {}
local REQUEST = "<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:X_SendIRCC xmlns:u=\"urn:schemas-sony-com:service:IRCC:1\"><IRCCCode>"..Command.."==</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"
rBody, rCode, rHeaders, rStatus = http.request(
{
method = "POST",
url = SONY_URL,
headers = {
["User-Agent"] = "curl/7.38.0",
["Host"] = SONY_IP,
["Accept"] = "*/*",
["X-Auth-PSK"] = AUTH_CODE,
["Content-Type"] = "text/xml; charset=UTF-8",
["Content-Length"] = tostring(#REQUEST),
["SOAPACTION"] = "\"urn:schemas-sony-com:service:IRCC:1#X_SendIRCC\""
},
source = ltn12.source.string(REQUEST),
sink = ltn12.sink.table(respBody),
redirect = false
}
)
luup.log("http response - code ["..(rCode or "NIL").."] html ["..(table.concat(respBody,"") or "NIL").."]")
end
--PowerOn the tv
SendCommand("AAAAAQAAAAEAAAAuAw")
socket.sleep(8)
--change to HDMI input
SendCommand("AAAAAgAAABoAAABaAw")
socket.sleep(8)
--set volume down
SendCommand("AAAAAQAAAAEAAAATAw")
This was working fine but since it mimics IR commands, setting the volume to a specific one was a bit of a pain.
Then I switched the Low level protocol to control the device.
Way easier to control… All the codes are here :
http://tmolberg.kpolberg.net/wp-content/uploads/2016/02/BRAVIA_B2B_SimpleIPControlProtocol_ForAndroidModels_v0.9.pdf
The tv respond to tcp port 20060.
Here is a simple lua request to power off the tv :
local socket = require("socket")
local host, port = "Your TV ip here", 20060
local tcp = assert(socket.tcp())
tcp:connect(host, port);
tcp:send("*SCPOWR0000000000000000\n");
I still need to find a way to catch the replies from the tv and update my Vera accordingly.
Let me know if that helps you and if I can help somehow
(IRCC commands)
'Analog': 'AAAAAgAAAHcAAAANAw==',
'Audio': 'AAAAAQAAAAEAAAAXAw==',
'Blue': 'AAAAAgAAAJcAAAAkAw==',
'ChannelDown': 'AAAAAQAAAAEAAAARAw==',
'ChannelUp': 'AAAAAQAAAAEAAAAQAw==',
'Confirm': 'AAAAAQAAAAEAAABlAw==',
'Display': 'AAAAAQAAAAEAAAA6Aw==',
'Down': 'AAAAAQAAAAEAAAB1Aw==',
'EPG': 'AAAAAgAAAKQAAABbAw==',
'Exit': 'AAAAAQAAAAEAAABjAw==',
'Forward': 'AAAAAgAAAJcAAAAcAw==',
'Green': 'AAAAAgAAAJcAAAAmAw==',
'Home': 'AAAAAQAAAAEAAABgAw==',
'Input': 'AAAAAQAAAAEAAAAlAw==',
'Left': 'AAAAAQAAAAEAAAA0Aw==',
'Mute': 'AAAAAQAAAAEAAAAUAw==',
'Next': 'AAAAAgAAAJcAAAA9Aw==',
'Num0': 'AAAAAQAAAAEAAAAJAw==',
'Num1': 'AAAAAQAAAAEAAAAAAw==',
'Num2': 'AAAAAQAAAAEAAAABAw==',
'Num3': 'AAAAAQAAAAEAAAADAw==',
'Num4': 'AAAAAQAAAAEAAAADAw==',
'Num5': 'AAAAAQAAAAEAAAAEAw==',
'Num6': 'AAAAAQAAAAEAAAAFAw==',
'Num7': 'AAAAAQAAAAEAAAAGAw==',
'Num8': 'AAAAAQAAAAEAAAAHAw==',
'Num9': 'AAAAAQAAAAEAAAAIAw==',
'Options': 'AAAAAgAAAJcAAAA2Aw==',
'PAP': 'AAAAAgAAAKQAAAB3Aw==',
'Pause': 'AAAAAgAAAJcAAAAZAw==',
'Play': 'AAAAAgAAAJcAAAAaAw==',
'Prev': 'AAAAAgAAAJcAAAA8Aw==',
'Red': 'AAAAAgAAAJcAAAAlAw==',
'Return': 'AAAAAgAAAJcAAAAjAw==',
'Rewind': 'AAAAAgAAAJcAAAAbAw==',
'Right': 'AAAAAQAAAAEAAAAzAw==',
'Stop': 'AAAAAgAAAJcAAAAYAw==',
'SubTitle': 'AAAAAgAAAJcAAAAoAw==',
'SyncMenu': 'AAAAAgAAABoAAABYAw==',
'Up': 'AAAAAQAAAAEAAAB0Aw==',
'VolumeDown': 'AAAAAQAAAAEAAAATAw==',
'VolumeUp': 'AAAAAQAAAAEAAAASAw==',
'Wide': 'AAAAAgAAAKQAAAA9Aw==',
'Yellow': 'AAAAAgAAAJcAAAAnAw==',
'HDMI1': 'AAAAAgAAABoAAABaAw==',
'HDMI2': 'AAAAAgAAABoAAABbAw==',
'HDMI3': 'AAAAAgAAABoAAABcAw==',
'HDMI4': 'AAAAAgAAABoAAABdAw==',
//not tested:
'Replay': 'AAAAAgAAAJcAAAB5Aw==',
'Advance': 'AAAAAgAAAJcAAAB4Aw==',
'TopMenu': 'AAAAAgAAABoAAABgAw==',
'PopUpMenu': 'AAAAAgAAABoAAABhAw==',
'Eject': 'AAAAAgAAAJcAAABIAw==',
'Rec': 'AAAAAgAAAJcAAAAgAw==',
'ClosedCaption': 'AAAAAgAAAKQAAAAQAw==',
'Teletext': 'AAAAAQAAAAEAAAA/Aw==',
'GGuide': 'AAAAAQAAAAEAAAAOAw==',
'DOT' : 'AAAAAgAAAJcAAAAdAw==',
'Digital': 'AAAAAgAAAJcAAAAyAw==',
'BS' : 'AAAAAgAAAJcAAAAsAw==',
'CS' : 'AAAAAgAAAJcAAAArAw==',
'BSCS': 'AAAAAgAAAJcAAAAQAw==',
'Ddata': 'AAAAAgAAAJcAAAAVAw==',
'InternetWidgets': 'AAAAAgAAABoAAAB6Aw==',
'InternetVideo': 'AAAAAgAAABoAAAB5Aw==',
'SceneSelect': 'AAAAAgAAABoAAAB4Aw==',
'Mode3D' : 'AAAAAgAAAHcAAABNAw==',
'iManual' : 'AAAAAgAAABoAAAB7Aw==',
'Jump' : 'AAAAAQAAAAEAAAA7Aw==',
'MyEPG': 'AAAAAgAAAHcAAABrAw==',
'ProgramDescription': 'AAAAAgAAAJcAAAAWAw==',
'WriteChapter': 'AAAAAgAAAHcAAABsAw==',
'TrackID' : 'AAAAAgAAABoAAAB+Aw==',
'TenKey': 'AAAAAgAAAJcAAAAMAw==',
'AppliCast': 'AAAAAgAAABoAAABvAw==',
'acTVila': 'AAAAAgAAABoAAAByAw==',
'DeleteVideo': 'AAAAAgAAAHcAAAAfAw==',
'EasyStartUp': 'AAAAAgAAAHcAAABqAw==',
'OneTouchTimeRec': 'AAAAAgAAABoAAABkAw==',
'OneTouchView' : 'AAAAAgAAABoAAABlAw==',
'OneTouchRec' : 'AAAAAgAAABoAAABiAw==',
'OneTouchRecStop' : 'AAAAAgAAABoAAABjAw==',