Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

> vi discover.js

Code Block
const { DeviceDiscovery }Sonos = require('sonos')
const {  
console.log('Searching for Sonos }devices for = require('sonos'5 seconds...')

//const eventdiscovery on= allnew found...
DeviceDiscoverySonos.AsyncDeviceDiscovery()

discovery.discover().then((device, model) => {
  console.log('foundFound one sonos device at%s getting all groups', + device.host)

  // mute everyreturn device...
  device.setMuted(true)getAllGroups().then((groups) => {
    console.thenlog(d => console.log(`${d.host} now muted`))
})

// find one device
DeviceDiscovery().once('DeviceAvailable', (device)'Groups %s', JSON.stringify(groups, null, 2))
  })
}).catch(e => {
  console.logwarn('found Error devicein atdiscovery %j', + device.host)

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

Run it

...

e)
})


Run it

> node discover.js


vi playSpotify.js

Code Block
"Name": "John's Room",
    "host": "192.168.1.24",

"Name": "Dining Room",
    "host": "192.168.1.26",






If you want to add it to npm, edit the package.json file

...