Skip to main content

Sonos command-line interface

Control your Sonos players from command-line. Uses Sonos Control API to control Sonos groups.

Build Status Deploy Status PyPI

Installation

Using Homebrew on OSX:

brew tap bwilczynski/tap
brew install sonos-cli

Using pip (requires Python 3):

pip install sonos-cli

Usage

$ sonos [OPTIONS] COMMAND [ARGS]

Get Started

Setup integration with Sonos API and run sonos config to provide your application's Client ID and Client Secret.

Make sure that:

  • Redirect URI is set to: http://localhost:5000
  • YOUR_CLIENT_ID: set to your Key (and not key name)
  • YOUR_CLIENT_SECRET: set to your Secret

Sonos Integration

Alternatively set the following environment variables before running sonos:

export SONOS_CLIENT_ID={YOUR_CLIENT_ID}
export SONOS_CLIENT_SECRET={YOUR_CLIENT_SECRET}

Login to your Sonos service (opens a web browser sending user to Sonos login service):

$ sonos login

Set active household:

$ sonos set household

For usage and help content, pass in the --help parameter, for example:

$ sonos --help
$ sonos get --help

Available commands

Get information from your Sonos:

$ sonos get [groups | households | playlists | tracks]

Format displayed result using --output option:

$ sonos get groups --output table

coordinatorId             id                                   name              playbackState
------------------------  -----------------------------------  ----------------  ----------------------
RINCON_B8E937E6D36202100  RINCON_B8E937E6D36202100:23          Bedroom.          PLAYBACK_STATE_PAUSED
RINCON_B8E937E6D40E02100  RINCON_B8E937E6D40E02100:128         Bathroom          PLAYBACK_STATE_IDLE
RINCON_B8E937DA7E6802100  RINCON_B8E937DA7E6802100:17          Bathroom 2.       PLAYBACK_STATE_PAUSED
RINCON_347E5C90FA9502100  RINCON_347E5C90FA9502100:4142323492  Living Room       PLAYBACK_STATE_PLAYING
$ sonos get groups --output json

[
  {
    "coordinatorId": "RINCON_B8E937E6D36202100",
    "id": "RINCON_B8E937E6D36202100:23",
    "name": "Bedroom",
    "playbackState": "PLAYBACK_STATE_PAUSED",
    ...
  }
  ...
}

Control playback:

$ sonos play
$ sonos pause
$ sonos next
$ sonos prev

Set active group / household:

$ sonos set [group | household]

Get playback status:

$ sonos status

Control group volume

$ sonos volume
20
$ sonos volume 25

The volume can also be set relative to its current value by prefixing it with + or -. To avoid the parameter being treated as a flag when setting a negative value, using -- before.

$ sonos volume +5
$ sonos volume -- -5

Release files for sonos-cli 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sonos-cli 0.3.7
File Size Uploaded
sonos-cli-0.3.7.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sonos-cli 0.3.7
File Interpreter ABI Platform
sonos_cli-0.3.7-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / sonos-cli-0.3.7.tar.gz

Download URL sonos-cli-0.3.7.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c7b4438fbff7f0d17855d5d664c5dda0ea3b5f0861c53dbfa83601e8a66a4db2
BLAKE2b-256 checksum
How to use checksums
3637bc869c0513420024399b28cd0ed1c7b51be4b80de5be28bed9d432f4a131
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.8.5

Release files / sonos_cli-0.3.7-py3-none-any.whl

Download URL sonos_cli-0.3.7-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9845b5bcf94b7cfddcbae36164760ae63009e2c6e26f92403d296b302e7be66c
BLAKE2b-256 checksum
How to use checksums
f14f8dc09b21496a27e20f008a5c445e16af997c719dc1278d7f80a6189d7674
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.3.7 This release

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page