GithubHelp home page GithubHelp logo

erik-beus / node-sonos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bencevans/node-sonos

0.0 1.0 0.0 1.33 MB

๐Ÿ”ˆ Sonos Media Player Interface/Client

Home Page: https://www.npmjs.com/package/sonos

License: MIT License

JavaScript 100.00%

node-sonos's Introduction


node-sonos logo

node-sonos

Control your Sonos devices with JavaScript (node.js)

Travis Build NPM Version NPM Downloads Standard Codestyle

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 (reccomended)

$ npm install sonos

From the repo, living on the edge

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

Quick Start

Discovering Devices

const { DeviceDiscovery } = require('sonos')

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

  // mute every device...
  device.setMuted(true)
    .then(`${device.host} now muted`)
})

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

  // get topology
  device.getTopology()
    .then(console.log)
})

Controlling Known Devices

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: Sonos(host, [port])
    • currentTrack()
    • deviceDescription()
    • flush()
    • getCurrentState()
    • getLEDState()
    • getMusicLibrary(search, options)
    • getMuted()
    • getTopology()
    • 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()
    • 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

  • AirSonos - Apple AirPlay (iOS, OS X) support to all Sonos devices on a network.
  • sonos-cli - Command Line Interface for Sonos
  • sonos2mqtt - Bridge between Sonos and an MQTT server
  • homebridge-zp - Homebridge plugin for Sonos ZonePlayer
  • ZenMusic - Control Sonos thru #Slack!
  • gladys-sonos - Control Sonos with Gladys a Raspberry Pi Home Assistant

Writeups

Maintainers

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

And a big thanks to all you other contributors! Pull-requests are beautiful things.

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

Do you have a question about this library, we are glad to help you Ask Question. You can see all questions here

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

Sonos v0.x

At 30 jan 2018 we released an promisified version of node-sonos. The old version can be found in the v0.x branch. It won't get any new features, but it might get security updates.

Licence

MIT ยฉ Ben Evans

node-sonos's People

Contributors

bencevans avatar clarketm avatar curry684 avatar cw124 avatar driskell avatar ds82 avatar ebaauw avatar esteluk avatar greenkeeper[bot] avatar greenkeeperio-bot avatar gupsho avatar htilly avatar iansu avatar mikidi avatar mistatt avatar monsur avatar mrose17 avatar renovate-bot avatar renovate[bot] avatar rno avatar sammygriffiths avatar sdaitzman avatar sseiber avatar stephen avatar svrooij avatar thebenji avatar tobhult avatar vinkla avatar vonrehberg avatar wafflegolfing avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.