homey-api 1.5.15 → 1.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -253,6 +253,7 @@ class Manager extends EventEmitter {
253
253
  } else {
254
254
  // Get from HTTP
255
255
  result = await this.homey.call({
256
+ $timeout,
256
257
  headers,
257
258
  body,
258
259
  path: `/api/manager/${this.id}${path}`,
@@ -288,8 +288,6 @@ class HomeyAPIV2 extends HomeyAPI {
288
288
  promises.push(pings[HomeyAPI.DISCOVERY_STRATEGIES.MDNS]);
289
289
  }
290
290
 
291
- // TODO: Move this to the catch handler to always fallback on cloud
292
- // Now mdns or local will error first and cloud won't have a chance!!
293
291
  if (pings[HomeyAPI.DISCOVERY_STRATEGIES.CLOUD]) {
294
292
  promises.push(pings[HomeyAPI.DISCOVERY_STRATEGIES.CLOUD]);
295
293
  }
@@ -301,7 +299,16 @@ class HomeyAPIV2 extends HomeyAPI {
301
299
  return Promise.race(promises);
302
300
  })
303
301
  .then(result => resolve(result))
304
- .catch(() => reject(new HomeyOfflineError()));
302
+ .catch(err => {
303
+ // Last resort: try cloud
304
+ if (pings[HomeyAPI.DISCOVERY_STRATEGIES.CLOUD]) {
305
+ return pings[HomeyAPI.DISCOVERY_STRATEGIES.CLOUD].catch(err => {
306
+ throw new HomeyOfflineError(err);
307
+ });
308
+ }
309
+
310
+ reject(new HomeyOfflineError(err));
311
+ });
305
312
  } else if (pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL]) {
306
313
  pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL]
307
314
  .then(result => resolve(result))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-api",
3
- "version": "1.5.15",
3
+ "version": "1.5.16",
4
4
  "description": "Homey API",
5
5
  "main": "src/index.js",
6
6
  "types": "assets/types/homey-api.d.ts",