How to use the @svrooij/sonos.SonosManager function in @svrooij/sonos

To help you get started, we’ve selected a few @svrooij/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 svrooij / sonos2mqtt / src / bridge.js View on Github external
log.error('mqtt', err.toString())
  })

  mqttClient.on('offline', () => {
    log.error('mqtt offline')
  })

  mqttClient.on('reconnect', () => {
    log.info('mqtt reconnect')
  })

  // Start searching for devices
  log.debug('Current config %o', config)
  if (config.device) log.info('Start from device %s', config.device)
  else log.info('Start searching for devices')
  const sonosManager = new SonosManager()
  // Pick the right initialization function.
  const initialize = config.device ? sonosManager.InitializeFromDevice(config.device) : sonosManager.InitializeWithDiscovery(10)
  initialize
    .then(success => {
      if (success) {
        sonosManager.Devices.forEach(d => addDevice(d))
        publishConnectionStatus()
      } else {
        log.info('No devices found')
      }
    })
    .catch(err => {
      log.error('Error in device discovery %o', err)
      process.exit(300)
    })