https://github.com/bencevans/node-sonos

πŸ”ˆ Sonos Media Player Interface/Client

https://github.com/bencevans/node-sonos

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • β—‹
    CITATION.cff file
  • βœ“
    codemeta.json file
    Found codemeta.json file
  • β—‹
    .zenodo.json file
  • β—‹
    DOI references
  • β—‹
    Academic publication links
  • β—‹
    Committers with academic emails
  • β—‹
    Institutional organization owner
  • β—‹
    JOSS paper metadata
  • β—‹
    Scientific vocabulary similarity
    Low similarity (11.4%) to scientific vocabulary

Keywords

home-automation javascript music nodejs sonos

Keywords from Contributors

community charting transformers projection productivity zsh-plugin archival generic exports interactive
Last synced: 6 months ago · JSON representation

Repository

πŸ”ˆ Sonos Media Player Interface/Client

Basic Info
Statistics
  • Stars: 710
  • Watchers: 30
  • Forks: 148
  • Open Issues: 20
  • Releases: 53
Topics
home-automation javascript music nodejs sonos
Created about 13 years ago · Last pushed 12 months ago
Metadata Files
Readme Changelog Contributing

README.md


node-sonos logo

node-sonos

Control your Sonos devices with JavaScript (node.js)

GitHub Actions Build NPM Version NPM Downloads Standard Codestyle Discord badge

node-sonos gives you the power to control all your Sonos devices from your own apps in JavaScript. Automatically discover your devices on the network and control the playback and queue with instant events announcing change.

Features

  • Device Discovery
  • Queue Control
  • Volume Control
  • Spotify Support
  • Radio
  • Change Events

Install

Published versions (recommended)

$ npm install sonos

From the repo, living on the edge

$ npm install git://github.com/bencevans/node-sonos.git

Quick Start

Discovering Devices

```js const { DeviceDiscovery } = require('sonos')

// event on all found... DeviceDiscovery((device) => { console.log('found device at ' + device.host)

// mute every device... device.setMuted(true) .then(d => console.log(${d.host} now muted)) })

// find one device DeviceDiscovery().once('DeviceAvailable', (device) => { console.log('found device at ' + device.host)

// get all groups device.getAllGroups().then(groups => { groups.forEach(group => { console.log(group.Name); }) }) }) ```

Discovering devices async

js const DeviceDiscovery = require('sonos').AsyncDeviceDiscovery let discovery = new DeviceDiscovery() discovery.discover().then((device, model) => { // Do stuff, see examples/devicediscovery.js })

Controlling Known Devices

```js const { Sonos } = require('sonos')

const device = new Sonos('192.168.1.56');

device.play() .then(() => console.log('now playing'))

device.getVolume() .then((volume) => console.log(current volume = ${volume})) ```

API

  • DeviceDiscovery([options], [deviceAvailableListener])
  • Class: DeviceDiscovery([options])
    • Event: 'DeviceAvailable'
    • destroy()
  • Class: 'AsyncDeviceDiscovery'
    • discover([options])
    • discoverMultiple([options])
  • Class: Sonos(host, [port])
    • currentTrack()
    • deviceDescription()
    • flush()
    • getCurrentState()
    • getLEDState()
    • getMusicLibrary(search, options)
    • getMuted()
    • ~~getTopology()~~ Doesn't work if you upgraded to Sonos v9.1. Check-out getAllGroups() for some replacement.
    • getVolume()
    • getZoneAttrs()
    • getZoneInfo()
    • getQueue()
    • next()
    • parseDIDL(didl)
    • pause()
    • play(uri)
    • togglePlayback()
    • previous()
    • queue(uri, positionInQueue)
    • queueNext(uri)
    • request(endpoint, action, body, responseTag)
    • seek(seconds)
    • setLEDState(desiredState)
    • setMuted(muted)
    • setName(name)
    • getPlayMode()
    • setPlayMode(mode)
    • setVolume(volume)
    • stop()
    • setSpotifyRegion(region)
    • alarmClockService()
    • ListAlarms()
    • PatchAlarm(id,options)
    • SetAlarm(id,enabled)
    • joinGroup(otherDeviceName)
    • leaveGroup()
    • getAllGroups()
    • startListening(options)
    • stopListening()
    • Event: 'CurrentTrack'
    • Event: 'NextTrack'
    • Event: 'PlayState' and 'PlaybackStopped'
    • Event: 'AVTransport'
    • Event: 'Volume'
    • Event: 'Muted'
    • Event: 'RenderingControl'

Documentation

We tried to add jsdoc info to all functions, and generate documentation from it. /docs

Examples

Additional examples can be found in the /examples directory within the repository.

In The Wild

node-sonos in use across the interwebs. Missing yours? Add it and send us a pull request!

Apps

Writeups

Maintainers

  • Ben Evans (@bencevans)
  • Stephen Wan (@stephen)
  • Marshall T. Rose (@mrose17)
  • Stephan van Rooij (@svrooij)

Contributors ✨

All Contributors <!-- ALL-CONTRIBUTORS-BADGE:END -->

Thanks goes to these wonderful people (emoji key):


Ben Evans

πŸ’» πŸ“– πŸ€” 🚧

Stephan van Rooij

πŸ’» πŸ“– πŸ‘€ 🚧

Scott Seiber

πŸ’» ⚠️

Marshall T. Rose

πŸ’» 🚧

Stephen Wan

πŸ’» 🚧

Pascal Opitz

πŸ’»

Shobhit Gupta

πŸ’»

Martin Giger

πŸ’» πŸ›

Matthias BrΓΌnning

πŸ’»

Erik Baauw

πŸ’» πŸ›

Thomas Mirlacher

πŸ’»

Tobias Hultman

πŸ’»

Monsur Hossain

πŸ’»

Ben A.

πŸ’»

Manuel Heim

πŸ’»

Alan Layng

πŸ’» πŸ›

Niels Keurentjes

πŸ’»

Arnaud Vallat

πŸ’»

Chris Wiggins

πŸ’»

Dennis

πŸ’»

Henrik Tilly

πŸ’» πŸ›

Ian Sutherland

πŸ’»

Jason Woods

πŸ’»

Marko Harjula

πŸ’»

MichaΓ«l Dierick

πŸ’»

Travis Clarke

πŸ’»

Vincent Klaiber

πŸ’»

VonRehberg

πŸ’»

Adam Varga

πŸ’»

Arjen van der Ende

πŸ’»

Craig Lonsdale

πŸ’»

Craig Simpson

πŸ’»

Denys Vitali

πŸ’»

Erik Beuschau

πŸ’»

H. Klages

πŸ’» πŸ›

Keith McKnight

πŸ’»

Kenneth Geisshirt

πŸ’»

Kirmani

πŸ’»

Marc Easen

πŸ’»

Michael Stegeman

πŸ’»

Morten Scheel

πŸ’»

Nathan Wong

πŸ’»

Sam Daitzman

πŸ’»

Sammy Griffiths

πŸ’»

Trevor Sullivan

πŸ’»

mistaTT

πŸ’»

wafflegolfing

πŸ’»

BjΓΆrn HΓ€ggquist

πŸ’»

wwwizzarrdry

πŸ›

Magnus Lundberg

πŸ›

Nick Dandakis

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome! You can get added by mentioning the @all-contributors bot in a pr or issue.

If we missed you, just go to your (closed) issue or pr and mention the bot to get added.

Issues

If you got discovered an issue with this library, please check the issue-tracker. And create an issue if your problem isn't discovered by someone else. If you want to contribute something check out these 'help-wanted' issues.

Questions

Join us on Discord

The best place to ask your questions is in Discord, we are there to help you. Join us on Discord.

Unsupported sonos features

There is a great other library to control Sonos with Python, they also have a great list of all possible soap actions here. So if you have anything that you cannot do with node-sonos but that you can with the official app. You could have a look in the above list, or use wireshark to investigate the protocol.

NPM publish

We try to react to all pull-requests, but if you think we don't respond in time, please don't create a 'sonos-by-xyz' or a 'node-sonos-by-xyz' package on NPM. This might lead to people installing the wrong version.

If you want to publish your own version, please do it as a user-scoped eg. @svrooij/sonos package.

  1. Change the top of the readme to state your specific changes.
  2. Change the name of the project to @npm_username/sonos
  3. Publish it to npm npm publish --access=public

Development

If you want to make this library better, you can follow these steps.

  1. Create a fork
  2. Make changes
  3. (optional) Create tests for the feature or the bug, see sonos.test.js.
  4. Run SONOS_HOST=192.168.x.x npm run test to test your code (against an actual sonos device, change the ip)
  5. Check-in your code in a single commit. Make sure your commit starts with fix: for a bugfix or feat: for a new feature followed by a short description. You can also follow with an empty line followed by a more details description.
  6. Send a pull-request
  7. Hold-on, we will be checking them.

If you already had a fork, make sure it is updated with the latest master so things don't get complicated when we want to merge the PR.

bash git remote add upstream https://github.com/bencevans/node-sonos.git git fetch upstream git checkout master git rebase upstream/master git push origin

Licence

MIT Β© Ben Evans

Owner

  • Name: Ben Evans
  • Login: bencevans
  • Kind: user
  • Location: London, UK
  • Company: Institute of Zoology, ZSL

GitHub Events

Total
  • Watch event: 7
  • Push event: 1
  • Pull request review event: 1
  • Pull request event: 4
  • Fork event: 5
  • Create event: 1
Last Year
  • Watch event: 7
  • Push event: 1
  • Pull request review event: 1
  • Pull request event: 4
  • Fork event: 5
  • Create event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 619
  • Total Committers: 68
  • Avg Commits per committer: 9.103
  • Development Distribution Score (DDS): 0.779
Past Year
  • Commits: 4
  • Committers: 2
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.25
Top Committers
Name Email Commits
Ben Evans b****n@b****k 137
Stephan van Rooij g****b@s****l 127
Renovate Bot b****t@r****m 84
dependabot[bot] 4****] 32
scotts@microsoft.com s****s@m****m 25
Stephan van Rooij 1****j 18
Marshall Rose m****7@g****m 15
greenkeeperio-bot s****t@g****o 15
Pascal Opitz c****t@p****m 14
Stephen Wan s****n@s****t 14
Stephan van Rooij s****j@f****l 13
Nicholas Villarreal n****l@g****m 11
renovate[bot] r****] 9
Shobhit Gupta s****t@g****m 6
Matthias Brünning m****g@m****m 5
Anthony Brown a****n@j****k 5
Martin Giger m****n@h****e 5
ebaauw e****w@x****l 4
Monsur Hossain m****r@g****m 4
Thomas Mirlacher t****s@m****t 4
Alan Layng a****n@r****m 3
Niels Keurentjes n****s@k****l 3
greenkeeper[bot] g****] 3
Tobias Hultman t****n@g****m 3
Manuel Heim m****7@g****m 3
Ben b****9@y****e 3
Wayne Lee w****e@s****m 3
MikiDi M****i 2
Marko Harjula m****a@g****m 2
Jason Woods d****l@j****k 2
and 38 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 49
  • Total pull requests: 69
  • Average time to close issues: 2 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 36
  • Total pull request authors: 15
  • Average comments per issue: 3.78
  • Average comments per pull request: 1.45
  • Merged pull requests: 53
  • Bot issues: 0
  • Bot pull requests: 33
Past Year
  • Issues: 0
  • Pull requests: 6
  • Average time to close issues: N/A
  • Average time to close pull requests: 21 days
  • Issue authors: 0
  • Pull request authors: 3
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 3
Top Authors
Issue Authors
  • svrooij (6)
  • hklages (6)
  • tboudri (2)
  • GerritKuilder (2)
  • realwakils (2)
  • irdeto-hackwestern (1)
  • raylway (1)
  • htilly (1)
  • gillescastel (1)
  • AUTplayed (1)
  • jordansissel (1)
  • printerboi (1)
  • Stanned (1)
  • tylermenezes (1)
  • pierrephi (1)
Pull Request Authors
  • dependabot[bot] (34)
  • pascalopitz (9)
  • svrooij (8)
  • stufisher (5)
  • bencevans (2)
  • recursivefunk (2)
  • qianc (2)
  • kcghost (2)
  • mmathys (1)
  • TKirmani (1)
  • reyes256 (1)
  • filahf (1)
  • blanck (1)
  • 2xAA (1)
  • yoogie27 (1)
Top Labels
Issue Labels
released (9) need-info (5) released on @alpha (5) question (3) bug (3) enhancement (2) feature (2) invalid (1) wontfix (1) help-wanted (1)
Pull Request Labels
dependencies (34) released (25) released on @alpha (25) hacktoberfest-accepted (1) bug (1)

Packages

  • Total packages: 3
  • Total downloads:
    • npm 1,492 last-month
  • Total docker downloads: 30
  • Total dependent packages: 42
    (may contain duplicates)
  • Total dependent repositories: 99
    (may contain duplicates)
  • Total versions: 96
  • Total maintainers: 4
npmjs.org: sonos

Node.js Sonos Interface

  • Versions: 85
  • Dependent Packages: 42
  • Dependent Repositories: 98
  • Downloads: 1,481 Last month
  • Docker Downloads: 30
Rankings
Dependent packages count: 0.7%
Dependent repos count: 1.5%
Docker downloads count: 1.5%
Average: 2.1%
Forks count: 2.6%
Stargazers count: 2.7%
Downloads: 3.8%
Maintainers (2)
Last synced: 6 months ago
npmjs.org: sonos-br-kyv

Node.js Sonos Interface

  • Versions: 10
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 8 Last month
Rankings
Forks count: 2.6%
Stargazers count: 2.7%
Dependent repos count: 10.5%
Average: 19.1%
Downloads: 27.3%
Dependent packages count: 52.5%
Maintainers (1)
Last synced: 6 months ago
npmjs.org: @qiancs/sonos

Node.js Sonos Interface

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 3 Last month
Rankings
Dependent repos count: 25.3%
Average: 31.0%
Dependent packages count: 36.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

package-lock.json npm
  • 324 dependencies
package.json npm
  • @bencevans/jsdox 0.4.11 development
  • mocha 6.2.0 development
  • nock 10.0.6 development
  • pre-commit 1.2.2 development
  • standard 13.1.0 development
  • axios ^0.21.1
  • debug ^4.3.1
  • ip ^1.1.5
  • xml2js ^0.4.23
.github/workflows/run-tests.yml actions
  • actions/checkout v1 composite
  • actions/setup-node v1 composite
  • cycjimmy/semantic-release-action v2 composite
  • svrooij/secret-gate-action v1 composite