Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Info for invokes #3

Closed
muldy opened this issue May 22, 2017 · 74 comments
Closed

Info for invokes #3

muldy opened this issue May 22, 2017 · 74 comments

Comments

@muldy
Copy link

muldy commented May 22, 2017

Hi! (this is not a issue)
I'm doing a express webapp to use the bravia module provided by you, I'm wondering how you know the syntax for the method calls:
bravia.audio.invoke('setAudioVolume', '1.0', { target: 'speaker', volume: 50 });
Particularly the { target: 'speaker', volume: 50 } part.
Is there any source for this information?
I'm particularly interested in the syntax for the audio getSpeakerSettings method.

I'm planning to publish my app on github when I clean up the code.

Thanks in advance.

@waynehaffenden
Copy link
Owner

This was the same issue I had when writing this module and there just seems to be a lack of documentation from Sony about this.

However, the TV's actually have an API that returns all the available methods, versions, parameters and return values. You can invoke this information yourself, by calling for example bravia.audio.getMethodTypes() which will return a JSON response containing all the audio methods available for all the different versions of the API. You can also pass in a version string to the method if you just want to query the methods available for a particular API.

I found that most of the parameters and return values are fairly self explanatory but unfortunately there are some that I don't really have a clue what they mean.

There are a bunch of other "service protocols" available, that can be accessed as bravia.system.getMethodTypes() etc. The ones that are available are:

accessControl
appControl
audio
avContent
browser
cec
encryption
guide
recording
system
videoScreen

I should update the README to include this information as to be fair it isn't obvious if you've not got much experience with the Bravia API.

I hope this helps.

Wayne

@muldy
Copy link
Author

muldy commented May 23, 2017

Thanks,

Yes, I've been listing the protocols and the geMethodTypes like system:
[{"version":"1.0","methods":[["getCurrentTime",[],["string"],"1.0"],["getDeviceMode",["{\"value\":\"string\"}"],["{\"isOn\":\"bool\"}"],"1.0"],["getInterfaceInformation",[],["{\"productCategory\":\"string\", \"productName\":\"string\", \"modelName\":\"string\", \"serverName\":\"string\", \"interfaceVersion\":\"string\"}"],"1.0"],["getLEDIndicatorStatus",[],["{\"mode\":\"string\", \"status\":\"string\"}"],"1.0"],["getNetworkSettings",["{\"netif\":\"string\"}"],["{\"netif\":\"string\", \"hwAddr\":\"string\", \"ipAddrV4\":\"string\", \"ipAddrV6\":\"string\", \"netmask\":\"string\", \"gateway\":\"string\", \"dns\":\"string*\"}*"],"1.0"],["getPowerSavingMode",[],["{\"mode\":\"string\"}"],"1.0"],["getPowerStatus",[],["{\"status\":\"string\"}"],"1.0"],["getRemoteControllerInfo",[],["{\"bundled\":\"bool\", \"type\":\"string\"}","{\"name\":\"string\", \"value\":\"string\"}*"],"1.0"],["getRemoteDeviceSettings",["{\"target\":\"string\"}"],["{\"target\":\"string\", \"currentValue\":\"string\", \"deviceUIInfo\":\"string\", \"title\":\"string\", \"titleTextID\":\"string\", \"type\":\"string\", \"isAvailable\":\"Boolean\", \"candidate\":\"GeneralSettingsCandidate[]\"}*"],"1.0"],["getSystemInformation",[],["{\"product\":\"string\", \"region\":\"string\", \"language\":\"string\", \"model\":\"string\", \"serial\":\"string\", \"macAddr\":\"string\", \"name\":\"string\", \"generation\":\"string\", \"area\":\"string\", \"cid\":\"string\"}"],"1.0"],["getSystemSupportedFunction",[],["{\"option\":\"string\", \"value\":\"string\"}*"],"1.0"],["getWolMode",[],["{\"enabled\":\"bool\"}"],"1.0"],["requestReboot",[],[],"1.0"],["setDeviceMode",["{\"value\":\"string\", \"isOn\":\"bool\"}"],[],"1.0"],["setLanguage",["{\"language\":\"string\"}"],[],"1.0"],["setPowerSavingMode",["{\"mode\":\"string\"}"],[],"1.0"],["setPowerStatus",["{\"status\":\"bool\"}"],[],"1.0"],["setWolMode",["{\"enabled\":\"bool\"}"],[],"1.0"],["getMethodTypes",["string"],["string","string*","string*","string"],"1.0"],["getVersions",[],["string*"],"1.0"]]},{"version":"1.1","methods":[["getCurrentTime",[],["{\"dateTime\":\"string\", \"timeZoneOffsetMinute\":\"int\", \"dstOffsetMinute\":\"int\"}"],"1.1"],["setLEDIndicatorStatus",["{\"mode\":\"string\", \"status\":\"string\"}"],[],"1.1"]]}]

Ok, so for the actual method parameters is just a best guess :)

@waynehaffenden
Copy link
Owner

Yeah sadly, if you manage to find some documentation then please come back and let me know :)

@ilessiivi
Copy link

You're both on the right tracks - the documentation is there in the getMethodTypes queries. If you look at the setAudioVolume method definition in the audio.getMethodTypes() response:

["setAudioVolume", [{
	"target": "string",
	"volume": "string"
}], ["int"], "1.0"]

The volume needs to be given as a string and not as an integer. Int is what the setAudioVolume query would return (it returns a 0 for me, even when the query succeeds instead of anything meaningful...). Here's a pull request to fix the demo in readme: #4

How does the getSpeakerSettings method work then? Checking the getMethodTypes, a target string is needed:

["getSpeakerSettings", [{
	"target": "string"
}], [{
	"target": "string",
	"currentValue": "string",
	"deviceUIInfo": "string",
	...
}*], "1.0"]

First I tried speaker and headphone as the target but those return an "Illegal Argument" error. By trial and error I figured out that querying it with an empty object {} as the params gets us the possible targets:

bravia.audio.invoke("getSpeakerSettings", "1.0", {}).then(function(info) {
	console.log("speaker settings", info);
}).catch(function(err) {
	console.error("speaker settings err", err);
});
[{
	"target": "tvPosition",
	"currentValue": "tableTop"
}, {
	"target": "subwooferLevel",
	"currentValue": "17"
}, {
	"target": "subwooferFreq",
	"currentValue": "8"
}, {
	"target": "subwooferPhase",
	"currentValue": "normal"
}, {
	"target": "subwooferPower",
	"currentValue": "on"
}]

I wish there was an actual documentation for this stuff but I guess Github comments will have to do 😄

@waynehaffenden
Copy link
Owner

Awesome, thank you for experimenting and fixing the documentation. Maybe, we can start a wiki on this and try and complete as much documentation on the API as we can, thoughts?

P.S. I don't have access to a Bravia TV as originally wrote this library for a friend, can get the odd access but won't make this very easy for me to do on my own but with you guys contributions I think it's certainly possible!

@AmigaZoid
Copy link

Just wanted to let you know, the help file on NPM still says volume: 50 instead of '50'.

One question: When I try to getMethodTypes(), I end up with this instead of actual types.

[ { version: '1.0',
methods:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ] },
{ version: '1.1', methods: [ [Object], [Object] ] } ]

I'm still fairly new to node js, any direction you can give me to get the actual list would be great.
Everything else is working great. Thanks for your work.

@waynehaffenden
Copy link
Owner

I'm just testing another update to the code so once this is done I'll push the latest changes to NPM.

You'll need to use util.inspect(). See util.inspect()

@AmigaZoid
Copy link

I don't know if having a sony subwoofer and soundbar hooked up changes anything but this is what I've figured out. Everything works for me except changing the volume. I have everything else voice controlled by an amazon echo. I can change volume level to 'speaker' and when I get the value, it is where I set it. The TV does not actually change volume on hdmi1 but I did notice that it IS changing the volume on the home screen.

@muldy
Copy link
Author

muldy commented Jun 6, 2017

I was hoping that the setSpeakerSettings would be corresponding to the operation pressing:
Action Menu -> Speakers -> Tv Speakers/Audio System.
I would like to automate this...

@AmigaZoid
Copy link

Confirmed. After turning off the sound bar, changing the sound works perfectly. I just need to figure out how to change the connected audio which we normally control with the normal tv remote.

@waynehaffenden
Copy link
Owner

waynehaffenden commented Jun 6, 2017

What does the following return as @ilessiivi wrote above:

bravia.audio.invoke("getSpeakerSettings", "1.0", {}).then(function(info) {
	console.log("speaker settings", info);
}).catch(function(err) {
	console.error("speaker settings err", err);
});

@muldy
Copy link
Author

muldy commented Jun 6, 2017

This:
speaker settings [ { target: 'tvPosition', currentValue: 'wallMount' }, { target: 'subwooferLevel', currentValue: '17' }, { target: 'subwooferFreq', currentValue: '8' }, { target: 'subwooferPhase', currentValue: 'normal' }, { target: 'subwooferPower', currentValue: 'on' } ]

@waynehaffenden
Copy link
Owner

You've probably already tried it but just interested to know that if you invoke the setAudioVolume method using one of the targets you got back i.e. 'subwooferLevel' if that changes the volume level for it or not?

@muldy
Copy link
Author

muldy commented Jun 6, 2017

I think somewhere in the TV settings there is a option to connect a subwoofer to the headphones jack ...
So the subwoofer levels must be for that option?
I think I've tried reading these values, when I change from Tv speakers to Audio system and see no change in them...

@muldy
Copy link
Author

muldy commented Jun 6, 2017

Maybe some target parameter gets the Audio System levels...

@AmigaZoid
Copy link

The whole issue for me is HDMI-CEC. Is it possible to send a command that talks to the Sony HDMI/ARC?
I get almost identical results from getspeakersettings as muldy. The soundbar volume can be controlled by it's own remote or by the bravia remote which makes me wonder if there is a way to send the volume command to CEC. I've tried changing subwoofer and also the headphone settings which don't have any results.

@JamesScammell
Copy link

JamesScammell commented Jun 6, 2017

Hi, It was myself and Wayne that started investigating this some months ago, we are currently testing again, unfortunately I am unable to fully test the audio setup you guys have as I am currently using a sound bar connected via Optical so no ARC.

I think the best way to try and move this on will be to install the TV & Video sidesview app (official Sony app) on an IOS or Android device and try changing the volume and see if that adjusts it, if it does we can look into packet capturing.

Also worth checking the home theatre control settings, I have no idea what options there are as It obviously doesn't detect arc but this may have some useful settings

@muldy
Copy link
Author

muldy commented Jun 6, 2017

I'm using a Yamaha 5.1(Without ARC) system through optical cable too. For normal Tv usage I don't turn on the Yamaha amplifier, but when I see movies, I turn the Amp on, switch to HDM1... and I have to set the speakers settings to Audio system... and when I'm done I have to put it back to the TV speakers (YAWWN).
This is because With Kodi on android I can't get DTS audio out of the Optical, so I use a raspberry pi...

@waynehaffenden
Copy link
Owner

@muldy Me and James are playing around with his TV as we speak to see if we can help crack it for you. Interestingly enough calling the API method: audio.getSoundSettings method which is on version 1.1 seems to give back whether it's on speaker or audioSystem, although, for us seems to be back to front. Can you try on yours and see what you get back.

@waynehaffenden
Copy link
Owner

waynehaffenden commented Jun 6, 2017

@muldy It seems that changing the speaker mode between TV and Audio System is most likely possible using the audio.setSoundSettings method, however, sadly we cannot work out what is meant by GeneralSettings[], can only assume the parameter would look something like:

{ "settings": [
  { ... } // <-- Unknown what goes in this "GeneralSettings" object.
] }

We've tried a bunch of these but everything gives back an illegal argument error and surprise, surprise not once ounce of documentation anywhere available on it...

@waynehaffenden
Copy link
Owner

@AmigaZoid What happens if you invoke:

bravia.audio.invoke("getVolumeInformation", "1.0", {}).then(function(info) {
	console.log(info);
}).catch(function(err) {
	console.error(err);
});

I'm interested to know whether you have more than just speaker and headphone as targets.

@JamesScammell
Copy link

I have emailed Sony support to see if they will give us API documentation, will update when I have one.

@AmigaZoid
Copy link

Please let me know if you figure it out. I'm in the process of a OS reinstall so will try the command above once I have Node reinstalled.

@waynehaffenden
Copy link
Owner

@AmigaZoid I most certainly will do that will be really useful for me. When you have completed your project, would this be something you would be willing to share as I know my friend (who I originally wrote this module for) is looking to do exactly the same as you and he isn't a programmer and I don't have much time to help him. Also, when you have reinstalled your OS and have some time let us know what results you get back from the getVolumeInformation method as this may hold the answer.

I have now created a new issue for what all of us here are really after. You can find it here.

@AmigaZoid
Copy link

[ { target: 'speaker',
volume: 2,
mute: false,
maxVolume: 100,
minVolume: 0 },
{ target: 'headphone',
volume: 26,
mute: false,
maxVolume: 100,
minVolume: 0 } ]

Same info I had before for getspeakersettings

As for the alexa setup, sure I can share. It's really minimal code for the way I am achieving it. I have a normal Alexa app and lambda that is going through AWS.Iot. So I have a subscribe/publish setup through iot that simply post a word like TVPower or VolumeUP to the Node server. I simply use an if or a switch to send the bravia code through your script to the TV. I'm doing the same thing for Kodi except I'm sending a JSON with http to the kodi webserver. Planning on adding zwave lights also if I can get it running.

@JamesScammell
Copy link

Project 2 is lightening for us but Wayne will also use them so easier to test. Would be interested to know if u are running Kodi natively on theTv (I currently am) of using an external device.

@AmigaZoid
Copy link

Yes, running kodi on the TV without an external box.

@JamesScammell
Copy link

Good to know, Sony's response was basically that they don't provide technical spec to end users which was what we expected, doesn't hurt to ask just great you stumbled on that documentation which should help a lot, just about to look now.

@casenjo
Copy link

casenjo commented Aug 14, 2017

Hi! I'm working on a Kodi plugin to do various things with my Bravia TV and have been having trouble finding proper documentation as well. Would it be possible for someone to share that doc with me as well? It'd be much appreciated :)

@mschwartz
Copy link

This might help:

https://github.com/RoboDomo/bravia-microservice

@casenjo
Copy link

casenjo commented Aug 14, 2017 via email

@mschwartz
Copy link

There is no way to get status that I've found. There is some documentation of the low level protocol to be found online, some even within github repositories.

@kdschlosser
Copy link

I have been searching for docs on the api as well. and I happened across your conversation here so I thought I might share with you. Tho I have written this for python I believe I have the most complete means of controlling a Bravia TV written to date. so you are more then welcome to have a gander. There are a few stumbling blocks I am trying to work through. one of them being the SSDP discovery so at the current moment the IP has to be entered. But here is the link to my repo for it

https://github.com/kdschlosser/SonyAPI

@olemartinorg
Copy link

Hi all! I found this issue while researching a very similar API for my Sony AV Receiver (the STR-DN1080). I'm looking into how I can call the "setSoundSettings" method, but I fail to find out what's expected of GeneralSettings[].

Anyway, the link @AmigaZoid posted looked intriguing, but as we are now in the future the link now 404s - as I guess we could expect.. Does anyone have a copy of the contents?

@waynehaffenden
Copy link
Owner

@olemartinorg Please find a download to the documentation from that link here: https://ufile.io/9nj97 Hope this helps.

Repository owner deleted a comment from AmigaZoid Dec 16, 2017
Repository owner deleted a comment from AmigaZoid Dec 16, 2017
Repository owner deleted a comment from AmigaZoid Dec 16, 2017
@olemartinorg
Copy link

Woah, that's a nice find! That got me a good step forward, but I'm still getting error number 15 "unsupported operation" for some calls. Meh, I guess the API doesn't support everything it says it does. Thank you very much for that documentation, though!

@JamesScammell
Copy link

Hmmm if anyone has the newer 4K Android TV and a sound bar Sony now has native Alexa support (unfortunately) I don’t, but they could try out the intergartion see if that works and potentially sniff the packets to see what’s occurinf (assuming Sony actually have it working). We originally found a fair bit out about the TV using this method but with the slideshow app rather than Alexa before we stumbled upon the documentation.

@jtasse
Copy link

jtasse commented Jan 16, 2018

@JamesScammell It's funny you mention that-- I have been trying to find a way to increase or decrease the volume on my Sony XBR65X900E via an HTTP request; but I keep getting a '401 - Invalid Request' response.

I did just try using Wireshark and another app to sniff the packets going from my Echo to the TV (using the Sony Bravia skill) but I haven't been able to grab any yet. Any suggestions for how to do this properly?

I can get some commands to work using the http://[IP]/sony/audio route (e.g. - {"method": "setAudioVolume", "params": [{"target": "speaker", "volume": "90"}], "id": 1, "version": "1.0"}).

However, it seems the only semi-documented way of increasing or decreasing volume is to use the IRCC route. I have mainly focused building and sending requests via Postman. I would list them here, but it occurs to me that if I can just get a packet from my Echo then I'll have everything I need :)

I'll post here if I am able to find anything.

@JamesScammell
Copy link

JamesScammell commented Jan 16, 2018

@jtasse are u using the TV with a Sound bar that uses cec (bravia link)? that's where people seem to have experienced issues, mine has no control integration with the TV and connects via optical which has obviously prevented me testing that side.

I find the most reliable way with Wireshark was to use a cabled network connection and plug my laptop into the same switch, you should also enable port mirroring on the switch or router you are using and mirror the port your TV is plugged into to the port your laptop\pc is plugged into (both devices should be connected to the same router or switch) without doing this you may or may not receive anything useful, if you are not familiar with Wireshark the output can be pretty over whelming so feel free to save to pcap and share, I can then have a look.

@jtasse
Copy link

jtasse commented Jan 17, 2018

@JamesScammell did you mean Bravia sync? My sound bar (a Sony HT-XT1) actually works pretty well with my TV--turning the TV off will power off the sound bar; and changing the volume on the TV remote will pass through to the sound bar.

And thanks for the Wireshark tips. However I've been doing some digging and a couple sources would seem to suggest that requests from an Echo are encrypted via TLS.

I was able to capture a request that I sent to my TV from Postman, but unfortunately I don't think I'm going to be able to grab an unecrypted request from an Echo--unless you know of another way to intercept :)

A shame, really--but at least I know there does exist a request that will change the volume (even if I don't know the exact syntax yet).

@JamesScammell
Copy link

Great sound base, I have seen them on demo.

I hadn’t even considered they would be using ssl, I’d be more suprised to learn they were not to be honest just didn’t occur to me until now...

Just found the following online it’s not something I have previously stubled on, it’s pretty late here in the uk so haven’t had a proper look it may not be relivent as it does not specify its for Bravia TVs but might be worth some investigation given that it specifically refers to the set volume method.

https://developer.sony.com/develop/audio-control-api/hardware-overview/api-references/svs/setaudiovolume

@jtasse
Copy link

jtasse commented Jan 19, 2018

@JamesScammell: OK so I finally got it. Although I couldn't use the API you suggested (my device is not supported), it got me thinking that maybe there was an API or implementation I missed somewhere.

I came across this Bravia project on GitHub and decided to give it a try. I was definitely surprised when I configured the sample app, ran it, and saw the volume change almost immediately.

I captured the packet for posterity. It turns out the 'Cookie' header is really the key. Without that the TV will not execute the request.

HEADERS
Content-Type: text/xml
SOAPACTION: "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC"
Cookie: auth=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

BODY

<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>AAAAAQAAAAEAAAASAw==</IRCCCode>
    </u:X_SendIRCC>
  </s:Body>
</s:Envelope>

With this I can finally implement a workaround to increase/decrease volume the desired amount (since the sound bar integration causes issues with the Alexa skill I mentioned).

Anyway, thanks again for your suggestions!

@mschwartz
Copy link

@jtasse
Copy link

jtasse commented Jan 19, 2018

You know, I had actually cloned that repository and tried to get it set up, but couldn't get it working.

What's the advantage of that approach? In my case, I'm just looking to create an AWS Lambda script so that I can send these commands to my TV via my Echo.

@mschwartz
Copy link

MQTT is a more standardized way to integrate disparate kinds of devices. Nest Thermostat and TV, for example.

I linked to the code so you could examine it to see what you need to do for your purposes.

It's quite robust and does every function I think is available via API.

I found a manual online somewhere :)

@JamesScammell
Copy link

Thanks for the feedback guys, have u found that Mqtt creates irritating delays, granted in a lot of use cases you wouldn’t notice or care but in the instance of your tv extra delay would defiantly annoy me although this is an assumption it does not stating so.

@mschwartz
Copy link

mschwartz commented Jan 20, 2018

There can be some lag. I defeat that, to a large degree, by only subscribing to specific things and by caching the last known states in localStorage.

For some of my displays, I'm subscribing to quite a few topics - weather, pool temp (and devices status), TV status, smartthings devices/states, etc.

On those screens, the messages from MQTT come in a stream, single file style.

The real lag is all the cloud stuff. Nest thermostat data, smart things, and so on. That network traffic is internet speed, not LAN speed :)

As far as sending (to command the TV to do whatever), it's quite instant. Your MQTT message goes out immediately and is handled immediately by the microservice. The state of the buttons might lag, though. If you hit volume up 10 times, the volume goes up 10 times within a second or whatever.

The benefit is I can MQTT to do things like macros (turn off light, set thermostat to 72, turn on TV with one button tap). I can use mitt command line in cron jobs to do things, too.

I've gone a lot further than that, though. I check the weather data for sunrise/sunset and turn on the garden lights at sunset and off at sunrise.

My house has a craft room next to the den where I keep a few server type machines. I put a temperature sensor in there and when the temperature gets too warm, the ceiling fan turns on low. The fan gradually goes from low -> medium -> high as the temp goes up in the room (I live in the desert, so it can get really hot outside).

@mschwartz
Copy link

mschwartz commented Jan 20, 2018

This is how it looks these days"
image

You can see it's got weather data, nest data, pool and spa data, LG TV and Tivo data, plus a bunch of smartthings devices. And a handful of macros.

TV Break pauses TV and turns on the lights. Resume turns off the lights and resumes the TV :)

And the Bravia screen looks like this (I have 2 bravias - bedroom and office, an LG OLED in the family room):

image

@jtasse
Copy link

jtasse commented Jan 20, 2018

Haha, so you basically built a SolarWinds style interactive dashboard for your home? :) I'm not quite at that level yet, but MQTT does sound pretty cool!

@waynehaffenden
Copy link
Owner

Really interesting to see how everyone is using the library, any feedback or suggestions on it at this stage? Also, @mschwartz are you opening sourcing the code, something like that would be fantastic in my house also!

@mschwartz
Copy link

It's all open source.

Hack at will, PRs welcome.

https://github.com/RoboDomo

A repo for each micro service and the main one for the web client.

Have a look at macro-microservice to see how trivial it is to mix and match the various home automation features (like nest, smart things, and TV in one macro). MQTT.

@jtasse
Copy link

jtasse commented Jan 28, 2018

Hey @AmigaZoid : can you share any more details regarding your setup for "subscribing" to commands originating from an Echo and sending them to your TV? Although I got the commands to work on my local network, I hit the same wall as a lot of other folks (i.e. - *it doesn't seem to be possible to send requests on my local network directly from an Echo).

I have been trying to get an AWS MQTT sample up and running on my Raspberry Pi, but I'm a Linux newb so any references would be great.

*Side Note: I still don't understand how the Sony's Android TV Alexa skill can achieve this--is there something special that allows Sony to interact with the user's local network?

@napyk
Copy link

napyk commented Mar 20, 2018

Did anyone managed it to get information about the current opened app?
I tried it with the avConnect method but there is only info about the active tv channel, sends an error when an app is opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests