Jump to content

Polyglot SonyAVR Nodeserver


Goose66

Recommended Posts

A new version (v1.0.4) of the SonyAVR Polyglot NodeServer  is available in the NodeServer Store that allows the ISY to locally control Sony AVRs and other devices that support the Sony Audio Control API. See https://developer.sony.com/develop/audio-control-api/ for more information.

Here are the changes in v1.0.4:
- added Load Profile and Set Logging Level commands to nodeserver node
- updates for consistency with other nodeservers for inclusion in NodeServer Store

Below are the installation instructions (also available in the README.md file in the GitHub repository):

1. Install the SonyAVR nodeserver from the Polyglot Nodeserver Store, or do a Git from the repository to the folder ~!/.polyglot/nodeservers/SonyAVR in your Polyglot v2 installation.

2. Log into the Polyglot Version 2 Dashboard (https://:3000)

3. Add the SonyAVR nodeserver as a Local (Co-Resident with Polyglot) nodeserver type.

4. Add the following optional Custom Configuration Parameters:

    "shortPoll" = polling interval for status from receiver(s) - defaults to 20 (longPoll is not used)

5. Once the SonyAVR NodeServer node appears in ISY994i Adminstative Console, click "Discover Devices" to dicover devices on your LAN compatible with the Sony Audio Control API. Make sure the devices are on or in "Network Standby" before you click "Discover Devices."

Notes:

1. If a zone doesn't have an associated amp, like HDMI Zone, then "Mute," "Unmute," and "Toggle Mute" commands and setting the volume throw an error which is ignored. The values for these states will not update and do not really reflect a valid state anyway.

2. In order for a Sony device to be added in device discovery, it must not only support the Sony Audio Control API, but must support all of the "system," "audio," and "avContent" services of the API.

Previous releases:

v0.2:
- initial release

A screenshot:

image.png.517cc36665273251f8c429f407675023.png

Link to comment
Share on other sites

Thanks @Goose66

Just fyi, it also picked up my 4 Sony TVs and my Bluray player, but just the main node for each.  There is no functionality for these others.  I guess this is because they don't support the Sony Audio Control API.  I really have no idea if this is the case, just my assumption.

Link to comment
Share on other sites

19 hours ago, carealtor said:

Just fyi, it also picked up my 4 Sony TVs and my Bluray player, but just the main node for each.  There is no functionality for these others.  I guess this is because they don't support the Sony Audio Control API.  I really have no idea if this is the case, just my assumption.

That's interesting. In discovery, I only poll in SSDP for devices that respond to the "urn:schemas-sony-com:service:ScalarWebAPI:1" search target, which is what the API docs say to use. Perhaps these devices support some functionality through the API, but just not individual zones with power/source/volume/mute functionality. The API also has commands for transport (play/pause/etc.) and track selection. 

I am assuming even a low-end speaker or AVR would have at least one main zone, but who knows. Without a device to test with, there's not much I can do here, other than test each device that responds to discovery for zones, and not create a node for it if it doesn't support zones. Maybe I can send you some private code through PM for you to test before I put a new version on GitHub.

Link to comment
Share on other sites

I think it safe to say the TVs and Bluray player do not have zones.  The TVs certainly have power/volume/mute functionality.

I'd be happy to test anything you want to send over.  I'm not terribly savvy with all this stuff, but if it's just a matter of replacing files in the SonyAVR folder, I can do that.

Link to comment
Share on other sites

I saw on the Sony developers forum "Older models supports older versions of the API (almost all devices with network connection are supporting some version of this API), some functions are the same as the current (documented) functions others are using older versions that that take slightly different parameters. Unfortunately I don't have a list of the devices and what functions they support that I can share."   I requested, but ???? There is a phone / local network app that works

...Barry

Link to comment
Share on other sites

I don’t think Im using any of the APIs that aren’t at least in 1.1. It may be the Zone thing. There is a lot of other functionality in there, like transport (play, pause, fforward, etc.) that may be supported in other devices. The nodeserver would need new nodetypes to support some different devices.

Unfortunately I don’t have any devices to test with to query the API and see what is supported by what.

Do you know how to use Curl or Network Resources on the ISY?

Link to comment
Share on other sites

this is the reply I received

I don't have any information about the STR-DN2010, the only way to find out is to querry the device (https://developer.sony.com/develop/audio-control-api/hardware-overview/discovery-process using ST: ssdp:all) and see if it supports the ScalarWebAPI.
There are som UPnP tools for iPhone and Android that you can use to do this.

If it does support this API it will probably be one of the earliest versions of the API.

Ia there a NR you can suggest to do this ??

...Barry

 

Link to comment
Share on other sites

i tried a upnp tool on my phone and it didnt respond to "sspd:discover" , but i dont think it included the all.  I found another internet tidbit...

 Re: Controlling a Sony STR-DN2010 receiver?

I did a little packet sniffing while my iPhone was communicating with the receiver and have found it uses a schema called Mediarenderer uPnP. It seems there has to be a relatively easy way to make use of this info to create a plugin,
Link to comment
Share on other sites

@bgrubb1 think mediarenderer is a standard Microsoft interface. I have never used it and don't really know what it's about.

If you turn debug on for your Polyglot and perform a "Discover Devices" again from the Nodeserver node, do you get anything in the log like "Unexpected error occurred retrieving device info: ..." or "Device found in discover - ID:...." If you didn't get either of these in the log, then the devices are not responding to the SSDP broadcast for the URN "schemas-sony-com:service:ScalarWebAPI:1", so we are out of luck as far as Audio Control API.

Link to comment
Share on other sites

1 hour ago, bgrubb1 said:

do you know how to turn on debug on Polisy ?

I'm afraid not. I haven't had the chance to work with Polisy. In a regular Polyglot installation on an RPi, there is a ~/.polyglot folder with a .env file that allows the Polyglot environment to be altered. Adding the line "NODE_ENV=development" in the ~/.polyglot/.env file turns it on. Do you have access to the shell on the Polisy? 

Link to comment
Share on other sites

with debug on


 
2020-01-17 11:34:10,075 [NodeServer] [INFO ] Started SonyAVR NodeServer... 2020-01-17 11:34:10,077 [NodeServer] [INFO ] Updating Driver controller - ST: 1, uom: 2 2020-01-17 11:35:57,975 [Controller] [DEBUG] Discovering devices in cmd_discover()...
2020-01-17 11:36:02,986 [Controller] [WARNING] /var/polyglot/nodeservers/SonyAVR-polyglot2/sonyapi.py:262: ResourceWarning: unclosed <socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=17, laddr=('0.0.0.0', 42932)>
2020-01-17 11:36:02,988 [Controller] [DEBUG] SSDP discovery returned 0 devices.
2020-01-17 11:36:02,989 [Controller] [INFO ] Sending addnotice to Polyglot: {'key': 'no_devices_notice', 'value': 'No Sony Audio devices found. Make sure devices to be discovered are On or in Network Standby.'}
2020-01-17 11:38:30,074 [Controller] [DEBUG] Discovering devices in cmd_discover()...
2020-01-17 11:38:35,078 [Controller] [WARNING] /var/polyglot/nodeservers/SonyAVR-polyglot2/sonyapi.py:262: ResourceWarning: unclosed <socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=17, laddr=('0.0.0.0', 61060)>
Link to comment
Share on other sites

latest Sony

  •  
     

    Yes, there are a lot of features that don't exist in older version of the API, or uses different parameters. So it will not be an easy task to figure out how to use the API even if it is supported.


  •  

    @david so the older ones used an earlier form of the API? I had presumed they used a different less-open method of communicating.

    So in theory, one should be able to try to query the receiver with some of the getXxxxx commands, e.g. getMethodTypes and experiment with parameters including the version parameter to try get a response. It might also pay to run a port scan against the receiver to see what services are available.

Link to comment
Share on other sites

It's all REST calls, specifically POST to http://<ip address>:10000/sony/<libspec>. You could do the testing from ISY Admin Console through Network Resources.

The data for the calls is:

{
    "id": 50,
    "method": <method>,
    "params": [],
    "version": <version>
}

For example, one of the commands (methods) he spoke of was getInterfaceInformation with a libspec of "system" and no parameters. The data would be:

{
    "id":50,
    "method":"getInterfaceInformation",
    "params":[],
    "version":"1.0"
}

The other method I would try initially is getPowerStatus (version "1.1", libspec "system"). I am not aware of a getMethodTypes method - it's not in the API spec.

Link to comment
Share on other sites

Goose66, Thank you for the direction

I couldn't get a response out of the STR DN2010 via POST commands

I ran a port trace against it.

I suspect the below means it's a stack from Mediabolic which I don't believe is an open architecture

If I try to hit it @ http://192.168.1.159:8888 I get "Error - page not found

Any other idea ??

...Barry

 

 

image.png.94e5cab7d290a47d73aa11c76810917c.png

Link to comment
Share on other sites

That's all part of the uPnP stuff you talked about earlier (MediaServer, MediaRenderer, etc.). Doesn't deal with Sony Audio Control API.

The primary reason I wrote a nodeserver for Sony Audio Control API is that I wanted to control the Zones on my STR DN1070, specifically power, volume, and source, independently. Existing generic control mechanisms, like MediaRenderer and such, didn't provide that, and those that deal with remote control (such as the Harmony Hub nodeserver) generally only allow functionality to the extent provided on the remote. The Sony Audio Control API was the only interface I found that replicates the control you can get through their mobile apps when it came to zone support on the receivers.

After thinking of ways to possibly implement support for devices with limited API support, those responding to the discovery that don't have zones, those that don't respond to the SSDP discovery at all, etc., I think my decision is to limit this nodeserver to discover and control Sony soundbars, speakers, and receivers that support at least v1.0 of the API. I will try to provide power, source, and volume control for either a device, or individual zones of a multi-zone device.  I think there are other generic options for controlling media playback (media selection, play, pause, ff, rwd, etc.) across a variety of devices.

Obviously, I will only be able to support the SNR-DN1070 and 1080 receivers in the first official version (because that's all I can test with), but it will provide a framework for others to add additional devices in these categories if they find compatibility. 

Link to comment
Share on other sites

7 hours ago, bgrubb1 said:

Goose66, Thank you for the direction

I couldn't get a response out of the STR DN2010 via POST commands

One last try: go to http://<your AVR ip address>:52323/dmr.xml in a browser window. Does the resulting XML (if any) show any support for "ScalarWebAPI"? If so, what are the  <av:X_ScalarWebAPI_BaseURL> and <av:X_ScalarWebAPI_Version> element values? This points you to the endpoint for the POST commands (and the version of the API supported).

Link to comment
Share on other sites

hmmmm

0000   54 42 49 b5 01 6a 94 c6 91 a3 b6 90 08 00 45 00   TBI..j........E.

0010   01 6f 53 1c 40 00 80 06 00 00 c0 a8 01 14 c0 a8   .oS.@...........

0020   01 9f 5b 5f 22 b8 38 16 a6 23 3d 0b dc df 50 18   ..[_".8..#=...P.

0030   fa f0 85 65 00 00 3c 3f 78 6d 6c 20 76 65 72 73   ...e..<?xml vers

0040   69 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64 69   ion="1.0" encodi

0050   6e 67 3d 22 75 74 66 2d 38 22 20 73 74 61 6e 64   ng="utf-8" stand

0060   61 6c 6f 6e 65 3d 22 79 65 73 22 3f 3e 3c 73 3a   alone="yes"?><s:

0070   45 6e 76 65 6c 6f 70 65 20 73 3a 65 6e 63 6f 64   Envelope s:encod

0080   69 6e 67 53 74 79 6c 65 3d 22 68 74 74 70 3a 2f   ingStyle="http:/

0090   2f 73 63 68 65 6d 61 73 2e 78 6d 6c 73 6f 61 70   /schemas.xmlsoap

00a0   2e 6f 72 67 2f 73 6f 61 70 2f 65 6e 63 6f 64 69   .org/soap/encodi

00b0   6e 67 2f 22 20 78 6d 6c 6e 73 3a 73 3d 22 68 74   ng/" xmlns:s="ht

00c0   74 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 6d 6c   tp://schemas.xml

00d0   73 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 2f 65 6e   soap.org/soap/en

00e0   76 65 6c 6f 70 65 2f 22 3e 3c 73 3a 42 6f 64 79   velope/"><s:Body

00f0   3e 3c 75 3a 47 65 74 50 6f 73 69 74 69 6f 6e 49   ><u:GetPositionI

0100   6e 66 6f 20 78 6d 6c 6e 73 3a 75 3d 22 75 72 6e   nfo xmlns:u="urn

0110   3a 73 63 68 65 6d 61 73 2d 75 70 6e 70 2d 6f 72   :schemas-upnp-or

0120   67 3a 73 65 72 76 69 63 65 3a 41 56 54 72 61 6e   g:service:AVTran

0130   73 70 6f 72 74 3a 31 22 3e 3c 49 6e 73 74 61 6e   sport:1"><Instan

0140   63 65 49 44 3e 30 3c 2f 49 6e 73 74 61 6e 63 65   ceID>0</Instance

0150   49 44 3e 3c 2f 75 3a 47 65 74 50 6f 73 69 74 69   ID></u:GetPositi

0160   6f 6e 49 6e 66 6f 3e 3c 2f 73 3a 42 6f 64 79 3e   onInfo></s:Body>

0170   3c 2f 73 3a 45 6e 76 65 6c 6f 70 65 3e            </s:Envelope>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...