This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Sony Bravia Authentication
#3
Hi, 

Why do you try Http post command to a tcp socket??

Try this, i have it working on Sony 2019 tv with no auth required as such (apart from the Xauth-psk as defined in the tv settings) also the protocol is well documented here
https://pro-bravia.sony.net/develop/inte...index.html
i just started learning lua so im sure there are some improvements to make to this script.

Change ip adress below to match tv and update ["X-Auth-PSK"] = "123456789", with your pre shared key from the tv


Code:
local http = require("socket.http") local ltn12 = require("ltn12") require('json') local path_system = "http://192.168.1.21/sony/system" local path_avContent = 'http://192.168.1.21/sony/avContent'   local payl = {     Pwr_on = [[ {"method": "setPowerStatus","id": 55,"params": [{"status": true}],"version": "1.0"} ]], --/system     Pwr_off = [[ {"method": "setPowerStatus","id": 55,"params": [{"status": false}],"version": "1.0"} ]], --/system     Pwr_req = [[ {"method": "getPowerStatus","id": 50,"params": [],"version": "1.0"} ]], --/system     Pwr_Get_system =  [[{"method": "getSystemInformation","id": 33,"params": [],"version": "1.0"}]],         Set_input_hdmi3 = [[ {"method": "setPlayContent","id": 101,"params": [{"uri": "extInput:hdmi?port=3"}],"version": "1.0"} ]], --/avContent     Set_req = [[ {"method": "getPlayingContentInfo","id": 103,"params": [],"version": "1.0"} ]],   --/avContent       vol_set = [[ {"method": "setAudioVolume","id": 98,"params": [{"volume": "5","ui": "on","target": "speaker"}],"version": "1.2"} ]], -- /audio     vol_req = [[ {"method": "getVolumeInformation", "id": 33, "params": [], "version": "1.0"} ]], -- /audio         reboot = [[ {"method": "requestReboot","id": 10,"params": [],"version": "1.0"} ]]  --/system   } --********///////////// Main Command ////////////********--  function sony_do_cmd(sony_cmd) -- 'Pwr_on' , 'Pwr_off'  for power on call function,  sony_do_cmd('Pwr_on')     -- is pwr command set url   pwr = string.match(sony_cmd, "Pwr_")   set = string.match(sony_cmd, "Set_")     if pwr then     path =  path_system     payload = payl[sony_cmd]   end     if set then     path =  path_avContent     payload = payl[sony_cmd]   end     local response_body = { }   local res, code, response_headers, status = http.request   {     url = path,     method = "POST",     headers =     {       ["Accept"] = "*/*",       ["Content-Type"] = "application/x-www-form-urlencoded",       ["X-Auth-PSK"] = "123456789",       ["Content-Length"] = payload:len()     },         source = ltn12.source.string(payload),           sink = ltn12.sink.table(response_body)   }       log(json.decode(response_body))      end  
Reply


Messages In This Thread
Sony Bravia Authentication - by arnocl - 17.02.2020, 09:58
RE: Sony Bravia Authentication - by admin - 17.02.2020, 10:14
RE: Sony Bravia Authentication - by benanderson_475 - 17.02.2020, 19:13
RE: Sony Bravia Authentication - by arnocl - 21.02.2020, 21:08
RE: Sony Bravia Authentication - by arnocl - 22.02.2020, 09:29
RE: Sony Bravia Authentication - by Daniel - 24.07.2025, 09:10

Forum Jump: