How to use the homebridge-lib.UpnpClient function in homebridge-lib

To help you get started, we’ve selected a few homebridge-lib 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 ebaauw / homebridge-hue / lib / HueDiscovery.js View on Github external
return new Promise((resolve, reject) => {
      const upnpClient = new homebridgeLib.UpnpClient({
        filter: (message) => {
          return /^[0-9A-F]{16}$/.test(message['hue-bridgeid'])
        },
        timeout: this._options.timeout
      })
      upnpClient.on('deviceFound', (address, obj, message) => {
        const id = obj['hue-bridgeid']
        const location = obj.location
        let host
        const a = location.split('/')
        if (a.length > 3 && a[2] != null) {
          host = a[2]
          const b = host.split(':')
          const port = parseInt(b[1])
          if (port === 80) {
            host = b[0]