How to use the sonos.Sonos function in sonos

To help you get started, we’ve selected a few sonos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakkra / SmartMirror / util / zigbee.js View on Github external
zigbeeConfig.devices.forEach(device => {
  let ieeeAddr = device.ieeeAddr;
  const deviceSetup = device;
  deviceSetup['toggleStateIsOn'] = false;

  switch (device.longPressFunctionality.type) {
    case 'sonos':
      deviceSetup['longPressAction'] = LongPressAction.SONOS;
      deviceSetup['sonosDevice'] = new Sonos(device.longPressFunctionality.sonosIp);
      break;
    case 'wledBrightness':
      deviceSetup['longPressAction'] = LongPressAction.WLED_BRIGHTNESS;
      deviceSetup['wledIp'] = device.longPressFunctionality.wledIp;
      break;
    default:
      console.log('Unknown device.longPressFunctionality.type ', device.longPressFunctionality);
  }

  buttons[ieeeAddr] = deviceSetup;
});
github tim-hellhake / sonos-adapter / adapter.js View on Github external
}).then((config) => {
            if (config && config.addresses) {
                for (const addr of config.addresses) {
                    const device = new Sonos(addr);
                    this.addDevice(device).catch(console.warn);
                }
            }

            db.close();
        }).catch((e) => {
            console.error('Failed to open database:', e);
github GPudgima / YT-SONOS / server / index.js View on Github external
app.get('/sonos/state', function(req, res){
    const sonos = new Sonos(devices[0]);
    sonos.getCurrentState().then(state => {
        console.log(state);
        res.json(state);
    });
})
github richardwillars / thinglator / drivers / homebox-driver-sonos.js View on Github external
return new Promise(function(resolve,reject) {
			var sonosDevice = new sonosInstance(device.specs.address,1400)
			sonosDevice.stop(function (err, result) {
				if(result) {
			  		resolve({stopped: true});
			  	}
			});
		});
	},
github robbi5 / add-to-sonos-queue / src / js / background.js View on Github external
}, function(items) {
      if (items.player_ip === '') {
        return reject(new Error("Please set your sonos ip in the settings"));
      }
      SONOS_DEVICE = new Sonos(items.player_ip);
      resolve(SONOS_DEVICE);
    });
  });
github richardwillars / thinglator / drivers / homebox-driver-sonos.js View on Github external
return new Promise(function(resolve,reject) {
			var sonosDevice = new sonosInstance(device.specs.address,1400)
			sonosDevice.currentTrack(function (err, result) {
			  	resolve({
					artist: result.artist,
					track: result.title,
					album: result.album,
					length: result.duration,
					currentPosition: result.position,
					artUrl: result.albumArtURL
				});
			});
		});
	},
github nfarina / homebridge-sonos / index.js View on Github external
accessory.log.debug("Target Zone Group Coordinator identified as: %s", JSON.stringify(coordinator));
                                                                                                        if (coordinator == undefined) {
                                                                                                                accessory.log.debug("Removing coordinator device from %s", JSON.stringify(accessory.device));
                                                                                                                accessory.device = coordinator;
                                                                                                        }
                                                                                                        else {
                                                                                                                var bUpdate = false;
                                                                                                                if (accessory.device != undefined) {
                                                                                                                        if (accessory.device.host != coordinator.ip) bUpdate = true;
                                                                                                                }
                                                                                                                else {
                                                                                                                        bUpdate = true;
                                                                                                                }
                                                                                                                if (bUpdate) {
                                                                                                                        accessory.log("Changing coordinator device from %s to %s (from sonos zone %s) for accessory '%s' in accessory room '%s'.", accessory.device.host, coordinator.ip, coordinator.CurrentZoneName, accessory.name, accessory.room);
                                                                                                                        accessory.device = new Sonos(coordinator.ip);
                                                                                                                }
                                                                                                                else {
                                                                                                                        accessory.log.debug("No coordinator device change required!");
                                                                                                                }
                                                                                                        }
                                                                                                });
                                                                                        }
github adnsio / airplay-sonos / index.js View on Github external
device.getZoneInfo((err, info) => {
      debug(`sonos found on ${ info.IPAddress } (${ attrs.CurrentZoneName })`)
      new Device(attrs.CurrentZoneName, new sonos.Sonos(info.IPAddress))
    })
  })
github richardwillars / thinglator / drivers / homebox-driver-sonos.js View on Github external
return new Promise(function(resolve,reject) {
			var sonosDevice = new sonosInstance(device.specs.address,1400)
			sonosDevice.play(function (err, result) {
				if(result) {
			  		resolve({playing: true});
			  	}
			});
		});
	},
github GPudgima / YT-SONOS / server / index.js View on Github external
app.get('/sonos/volume', function(req, res){ 
    const sonos = new Sonos(devices[0]);
    sonos.getVolume()
    .then((volume) => {
        res.json(volume);
    });
});