How to use the @svrooij/sonos.SonosEvents 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
#!/usr/bin/env node

const pkg = require('../package.json')
const log = require('yalm')
const config = require('./config.js')
const mqtt = require('mqtt')
const SonosManager = require('@svrooij/sonos').SonosManager
const SonosEvents = require('@svrooij/sonos').SonosEvents

let mqttClient
const devices = []

function start () {
  log.setLevel(config.verbosity)
  log.info(pkg.name + ' ' + pkg.version + ' starting')

  // MQTT Stuff
  log.info('Parsing url %s', config.mqtt)
  const url = new URL(config.mqtt)

  // Define the will message (is send on disconnect).
  const mqttOptions = {
    will: {
      topic: config.name + '/connected',