node-sonos-http-api icon indicating copy to clipboard operation
node-sonos-http-api copied to clipboard

Feature Request: Select SPDIF/Line in Source as action

Open NovaGL opened this issue 8 years ago • 15 comments

I can understand if you don't want to do this as it's possible via presets, but I would like the option.

The way I would go about it is:

Get Zone info from

POST /DeviceProperties/Control HTTP/1.1
HOST: SONOS-IP:1400
SOAPACTION: "urn:schemas-upnp-org:service:DeviceProperties:1#GetZoneInfo"
CONTENT-TYPE: text/xml; charset="utf-8"

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <u:GetZoneInfo xmlns:u="urn:schemas-upnp-org:service:DeviceProperties:1" />
   </s:Body>
</s:Envelope>

From the output get <MACAddress>XX:XX:XX:XX:XX:XX</MACAddress> remove all ":"

Then combine it with "x-sonos-htastream:RINCON_" + MACAddress + "01400:spdif"

    <s:Envelope
        xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
        s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <s:Body>
            <u:SetAVTransportURI
                xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
                <InstanceID>
                    0
                    </InstanceID>
                <CurrentURI>
                    x-sonos-htastream:RINCON_XXXXXXXXXXXX01400:spdif                    
                    </CurrentURI>
                <CurrentURIMetaData>
                    </CurrentURIMetaData>
                </u:SetAVTransportURI>
            </s:Body>
        </s:Envelope>

Thanks for reading.

NovaGL avatar Dec 21 '15 01:12 NovaGL

Well, there already is a "setavtransporturi" action available, which would look like this:

/RoomName/setavtransporturi/x-sonos-htastream:RINCON_XXXXXXXXXXXX01400:spdif

So you don't actually need to use the presets for this. But, it would be nice to simplify it, I'm thinking something like this:

/RoomName/linein (for local line-in if available) /RoomName/linein/SrcRoomName (for line-in from another player)

And also handle the difference between the PLAYBAR and regular players somehow.

jishi avatar Dec 21 '15 08:12 jishi

Thanks, writing presets/tv is easier than setavtransporturi/x-sonos-htastream:RINCON_XXXXXXXXXXXX01400:spdif

It's good to have options, I like your thinking and happy to test something like this in the future.

NovaGL avatar Dec 21 '15 09:12 NovaGL

Are you still thinking of implementing this?

NovaGL avatar Feb 09 '16 00:02 NovaGL

Yes, I just need to find a reliable way of identifying a playbar or equivalent device that uses the x-sonos-htastream scheme. If you have any suggestions (preferably, something that is evented), I'll gladly take suggestions.

jishi avatar Feb 09 '16 15:02 jishi

Could you parse the info from the XML?

sonos-ip:1400/xml/device_description.xml

It has the RICON under UDN and says model number

NovaGL avatar Feb 10 '16 04:02 NovaGL

I could, but I don't fetch that data today and if it would be evented, that would be "cleaner". I can probably always check some properties that I expect to be part of a PLAYBAR device.

Also, relying on model names might not function properly in the future if they release a second version of PLAYBAR or another device with a spdif line in.

Maybe there is service actions that actually triggers line-in that takes this into consideration, I should probably investigate that as well.

jishi avatar Feb 10 '16 12:02 jishi

Why use Model names? I would use model numbers much safer, you have a list of model numbers that support SPDIF. If I find an event that shows this information, I will post it.

NovaGL avatar Feb 10 '16 23:02 NovaGL

Model names, model numbers follow the same scheme, meaning that I can not infer what capabilities a certain device has, which makes it impossible to support new devices without actually adding support for them. That would be the dream scenario, but of course, if that is not possible, I can always use model number.

Any difference in properties that are evented between a playbar and a regular player are of interest.

jishi avatar Feb 11 '16 08:02 jishi

This might be of use to you.

If a device supports SPDIF it will be able to be evented using urn:upnp-org:serviceId:HTControl

Sonos PLAYBAR/urn:upnp-org:serviceId:HTControl TOSLinkConnected 0

If a device supports Line-In it can be evented using. urn:upnp-org:serviceId:AudioIn

Sonos CONNECT/urn:upnp-org:serviceId:AudioIn LineInConnected 0

NovaGL avatar Feb 11 '16 09:02 NovaGL

Yeah, that was super useful. The Sonos controller is aware if something is connected, and one should probably take that into account as well. With your discovery, it will both be possible to know that, and what type of device that is connected.

jishi avatar Feb 16 '16 15:02 jishi

I'm planning on taking a stab at this, but I would like the output from a PLAYBAR http://x.x.x.x:1400/xml/device_description.xml

If you could send that to me at [email protected] that would be great! I have already fixed this for regular line-in devices, but wanted to make it model agnostic.

jishi avatar Oct 22 '16 12:10 jishi

Emailed device_description.xml - hopefully this helps with a resolution

LqqkOut avatar Feb 22 '17 22:02 LqqkOut

Hi jish, Any news on the spdif feature? I noticed the command supports only linein for the moment?

martin072 avatar Jan 29 '19 22:01 martin072

https://github.com/jishi/node-sonos-http-api/pull/789

chrisns avatar Mar 09 '21 19:03 chrisns

I'm willing to help by providing any info or help debug to get this working for PLAYBAR. I'm currently using the workaround, but it would be nice if this just works out of the box.

I noticed that the <ZoneGroupMember> info has a HdmiCecAvailable="1" which is not as nice as using the Services, but probably easier to implement?

<ZoneGroupState><ZoneGroups><ZoneGroup Coordinator="RINCON_XXXXXXXXXXXX01400" ID="RINCON_XXXXXXXXXXXX01400:1875128050"><ZoneGroupMember UUID="RINCON_XXXXXXXXXXXX01400" Location="http://x.x.x.x:1400/xml/device_description.xml" ZoneName="MyZone" Icon="" Configuration="1" SoftwareVersion="62.1-86220" SWGen="2" MinCompatibleVersion="61.0-00000" LegacyCompatibleVersion="58.0-00000" BootSeq="8" TVConfigurationError="0" HdmiCecAvailable="1" WirelessMode="1" WirelessLeafOnly="0" HasConfiguredSSID="1" ChannelFreq="2437" BehindWifiExtender="0" WifiEnabled="1" Orientation="0" RoomCalibrationState="1" SecureRegState="3" VoiceConfigState="0" MicEnabled="0" AirPlayEnabled="1" IdleState="0" MoreInfo=""/></ZoneGroup></ZoneGroups><VanishedDevices></VanishedDevices></ZoneGroupState>

mvdwater avatar Apr 08 '21 14:04 mvdwater