How to use the homebridge-lib.RestClient 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
async _nupnp (options) {
    if (this._options.verbose) {
      this.bridgeMap[options.name] = {}
    }
    options.timeout = this._options.timeout
    const client = new homebridgeLib.RestClient(options)
    return client.get().then((response) => {
      if (Array.isArray(response)) {
        for (const bridge of response) {
          let host = bridge.internalipaddress
          if (bridge.internalport != null && bridge.internalport !== 80) {
            host += ':' + bridge.internalport
          }
          const id = bridge.id.toUpperCase()
          this._debug('%s: found %s at %s', options.name, id, host)
          if (this._options.verbose) {
            this.bridgeMap[options.name][host] = id
          } else {
            this.bridgeMap[host] = id
          }
        }
      }