homey-api 1.5.7 → 1.5.10

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.
@@ -444,6 +444,25 @@
444
444
 
445
445
 
446
446
 
447
+ opts: {
448
+
449
+
450
+ appId: string,
451
+
452
+
453
+ },
454
+
455
+
456
+
457
+
458
+ ):
459
+ Promise<any>;
460
+
461
+ getAppDriversStats(
462
+
463
+
464
+
465
+
447
466
  opts: {
448
467
 
449
468
 
@@ -2758,6 +2777,11 @@
2758
2777
 
2759
2778
  getAppInstallsStatistics(
2760
2779
 
2780
+ ):
2781
+ Promise<any>;
2782
+
2783
+ getAppDriversStatistics(
2784
+
2761
2785
  ):
2762
2786
  Promise<any>;
2763
2787
 
package/lib/API.js CHANGED
@@ -68,6 +68,8 @@ class API {
68
68
 
69
69
  this[operationId] = async ({
70
70
  $validate = true,
71
+ $timeout = 10000,
72
+ $timeoutMessage = null,
71
73
  $body = {},
72
74
  $query = {},
73
75
  $headers = {},
@@ -144,6 +146,8 @@ class API {
144
146
  body,
145
147
  path: pathWithParameters,
146
148
  context: { operation },
149
+ timeout: $timeout,
150
+ timeoutMessage: $timeoutMessage,
147
151
  });
148
152
  };
149
153
  }
@@ -76,7 +76,16 @@ class Device extends Item {
76
76
  * @returns {Promise<void>}
77
77
  * @function HomeyAPIV2.ManagerDevices.Device#setCapabilityValue
78
78
  */
79
- async setCapabilityValue({
79
+ async setCapabilityValue(options, ...args) {
80
+ // Legacy compatibility from node-athom-api
81
+ if (typeof options === 'string') {
82
+ return this.setCapabilityValueLegacy(options, ...args);
83
+ }
84
+
85
+ return this.__setCapabilityValue(options);
86
+ }
87
+
88
+ async __setCapabilityValue({
80
89
  capabilityId,
81
90
  value,
82
91
  opts,
@@ -93,6 +102,14 @@ class Device extends Item {
93
102
  });
94
103
  }
95
104
 
105
+ async setCapabilityValueLegacy(capabilityId, value, opts) {
106
+ return this.__setCapabilityValue({
107
+ capabilityId,
108
+ value,
109
+ opts,
110
+ });
111
+ }
112
+
96
113
  async connect() {
97
114
  this.__debug('connect');
98
115
 
@@ -215,15 +215,15 @@ class Manager extends EventEmitter {
215
215
  case 'getAll': {
216
216
  // If array (uri + id)
217
217
  if (this.__cache[itemId]
218
- && this.__cacheAllComplete[itemId]
219
- && itemType === 'filter') {
218
+ && this.__cacheAllComplete[itemId]
219
+ && itemType === 'filter') {
220
220
  this.__debug(`Serving ${itemId}:all from cache`);
221
221
  return Object.values(this.__cache[itemId]);
222
222
  }
223
223
 
224
224
  // If object (id)
225
225
  if (this.__cache[itemId]
226
- && this.__cacheAllComplete[itemId]) {
226
+ && this.__cacheAllComplete[itemId]) {
227
227
  this.__debug(`Serving ${itemId}:all from cache`);
228
228
  return this.__cache[itemId];
229
229
  }
@@ -382,8 +382,8 @@ class Manager extends EventEmitter {
382
382
 
383
383
  // Transform & add to cache if this is a CRUD event
384
384
  if (event.endsWith('.create')
385
- || event.endsWith('.update')
386
- || event.endsWith('.delete')) {
385
+ || event.endsWith('.update')
386
+ || event.endsWith('.delete')) {
387
387
  const [itemId, operation] = event.split('.');
388
388
  const ItemClass = this.constructor.ITEMS[itemId] || Item;
389
389
  const itemType = this.__itemsById[itemId].type;
@@ -449,6 +449,18 @@ class Manager extends EventEmitter {
449
449
  }
450
450
  }
451
451
 
452
+ destroy() {
453
+ for (const id of Object.keys(this.__cache)) {
454
+ this.__cache[id] = {};
455
+ }
456
+
457
+ for (const id of Object.keys(this.__cacheAllComplete)) {
458
+ this.__cacheAllComplete[id] = false;
459
+ }
460
+
461
+ this.disconnect().catch(() => { });
462
+ }
463
+
452
464
  }
453
465
 
454
466
  module.exports = Manager;
package/lib/Util.js CHANGED
@@ -86,6 +86,13 @@ class Util {
86
86
  return (typeof window !== 'undefined');
87
87
  }
88
88
 
89
+ /**
90
+ * @returns {boolean}
91
+ */
92
+ static isNodeJS() {
93
+ return (typeof process !== 'undefined');
94
+ }
95
+
89
96
  /**
90
97
  * @param {string} name - Query parameter name
91
98
  * @returns {string|null}
@@ -148,7 +155,11 @@ class Util {
148
155
  return window.localStorage.getItem(key) || null;
149
156
  }
150
157
 
151
- return process.env[key] || null;
158
+ if (this.isNodeJS()) {
159
+ return process.env[key] || null;
160
+ }
161
+
162
+ return null;
152
163
  }
153
164
 
154
165
  static envKey(key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-api",
3
- "version": "1.5.7",
3
+ "version": "1.5.10",
4
4
  "description": "Homey API",
5
5
  "main": "src/index.js",
6
6
  "types": "assets/types/homey-api.d.ts",