ebaauw / homebridge-zp

Homebridge plugin for Sonos ZonePlayer
Apache License 2.0
241 stars 20 forks source link

Possible to expose sub “Power On/Off” control to HomeKit? #157

Closed NateUT99 closed 3 years ago

NateUT99 commented 3 years ago

I recently added a Sonos sub to my system and noticed that it has a separate power on/off control exposed in the S2 app. I was curious to see if that could be exposed to HomeKit so I could add it to some of my evening automations and scenes, primarily so I could turn it off in the evening when my toddler goes to bed, and then turn it back on as part of my “Good Morning” scene. Do you know if making this a switch via this plugin is possible?

ebaauw commented 3 years ago

Setting the sub on or off is straightforward enough:

Transmission Control Protocol, Src Port: 50491, Dst Port: 1400, Seq: 1, Ack: 1, Len: 793
Hypertext Transfer Protocol
eXtensible Markup Language
    <s:Envelope
        xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
        s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <s:Body>
            <u:SetEQ
                xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
                <InstanceID>
                    0
                    </InstanceID>
                <EQType>
                    SubEnable
                    </EQType>
                <DesiredValue>
                    1
                    </DesiredValue>
                </u:SetEQ>
            </s:Body>
        </s:Envelope>

The master (in my case the PlayBar) seems to send notifications on changing it:

Transmission Control Protocol, Src Port: 45750, Dst Port: 3400, Seq: 1, Ack: 1, Len: 699
Hypertext Transfer Protocol
eXtensible Markup Language
    <e:propertyset
        xmlns:e="urn:schemas-upnp-org:event-1-0">
        <e:property>
            <LastChange>
                 &lt;Event xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/RCS/&quot;&gt;&lt;InstanceID val=&quot;0&quot;&gt;&lt;SpeakerSize val=&quot;6&quot;/&gt;&lt;SubGain val=&quot;0&quot;/&gt;&lt;SubCrossover val=&quot;0&quot;/&gt;&lt;SubPolarity val=&quot;0&quot;/&gt;&lt;SubEnabled val=&quot;1&quot;/&gt;&lt;/InstanceID&gt;&lt;/Event&gt;
            </LastChange>
        </e:property>
    </e:propertyset>

Best expose this as an extra characteristic on the Speaker service (like Treble, Bass, etc). You will have to use Eve, but once you create a scene in that app, you can recall it from Home (or Siri).

Note to self: don't forget to add support to zp as well.

ebaauw commented 3 years ago

Could you try beta v1.1.4-0? It seems to work for Sub connected to my PlayBar. Do you have the Sub connected to a home theatre setup, or to a regular stereo pair?

NateUT99 commented 3 years ago

Could you try beta v1.1.4-0? It seems to work for Sub connected to my PlayBar. Do you have the Sub connected to a home theatre setup, or to a regular stereo pair?

Will try and report back when I get home this evening. The sub is part of a home theater setup with a beam and two on SLs.

NateUT99 commented 3 years ago

I have been playing around with it for an hour or so now and everything appears to work as expected! Will continue testing and report back if any issues arise but at this moment it looks good.