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.

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.

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

Project details


Download files

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

Files for sonos-cli, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size sonos_cli-0.3.1-py3-none-any.whl (13.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size sonos-cli-0.3.1.tar.gz (8.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page