Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
})