Skip to main content

Sonos Command-Line Tools

Project description

Sonos command-line interface

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

Build Status

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sonos-cli-0.3.6.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sonos_cli-0.3.6-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file sonos-cli-0.3.6.tar.gz.

File metadata

  • Download URL: sonos-cli-0.3.6.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using 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.0 CPython/3.8.5

File hashes

Hashes for sonos-cli-0.3.6.tar.gz
Algorithm Hash digest
SHA256 eb2beb7c2fbdc99aa882aae502d867a547c911aa81823f612b72e8ac46ae1e6e
MD5 670959935029683027a424f817e14baf
BLAKE2b-256 c766594aeee56306cf66b898993a54fe43bc2da29dd3f6e7c3b0a651df0598ea

See more details on using hashes here.

File details

Details for the file sonos_cli-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: sonos_cli-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using 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.0 CPython/3.8.5

File hashes

Hashes for sonos_cli-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f3a8db0eccd1b3776d0864b1d00de99426b76c4e4f13927be1d1580c5225d5
MD5 ee41f23e27004c41b8bc8a34f9c4342d
BLAKE2b-256 dfd129d9346afdddac250a2e410df57a609070cff3c261eb09f28c5dce74b47b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page