Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kevinthecity/cc309516399936e39f7ee996dd22f044 to your computer and use it in GitHub Desktop.
Save kevinthecity/cc309516399936e39f7ee996dd22f044 to your computer and use it in GitHub Desktop.
More docs - https://sonos.svrooij.io/services/rendering-control#setrelativevolume
Get IP Address from your Sonos App - Settings -> General Settings -> About you system
// Set Relative Volume
curl -X POST "http://192.168.XXX.XXX:1400/MediaRenderer/RenderingControl/Control" \
-H "SOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#SetRelativeVolume\"" \
-H "Content-Type: text/xml; charset=utf-8" \
--data '<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:SetRelativeVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
<InstanceID>0</InstanceID>
<Channel>Master</Channel>
<Adjustment>2</Adjustment> <!-- Increase volume by 2 -->
</u:SetRelativeVolume>
</s:Body>
</s:Envelope>'
// Set Volume
curl -X POST "http://192.168.XXX.XXX:1400/MediaRenderer/RenderingControl/Control" \
-H "SOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#SetVolume\"" \
-H "Content-Type: text/xml; charset=utf-8" \
--data '<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:SetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
<InstanceID>0</InstanceID>
<Channel>Master</Channel>
<DesiredVolume>50</DesiredVolume>
</u:SetVolume>
</s:Body>
</s:Envelope>'
// Get Volume
curl -X POST "http://192.168.XXX.XXX:1400/MediaRenderer/RenderingControl/Control" \
-H "SOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"" \
-H "Content-Type: text/xml; charset=utf-8" \
--data '<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
<InstanceID>0</InstanceID>
<Channel>Master</Channel>
</u:GetVolume>
</s:Body>
</s:Envelope>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment