homey-api 3.0.16 → 3.0.18

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.
@@ -204,23 +204,19 @@ class Manager extends EventEmitter {
204
204
  return result;
205
205
  }
206
206
 
207
- const pendingCall = (async () => {
208
- const result = await this.__request({
209
- $validate,
210
- $cache,
211
- $timeout,
212
- $socket,
213
- operationId,
214
- operation,
215
- path,
216
- body,
217
- query,
218
- headers,
219
- ...args
220
- });
221
-
222
- return result;
223
- })();
207
+ const pendingCall = this.__request({
208
+ $validate,
209
+ $cache,
210
+ $timeout,
211
+ $socket,
212
+ operationId,
213
+ operation,
214
+ path,
215
+ body,
216
+ query,
217
+ headers,
218
+ ...args
219
+ });
224
220
 
225
221
  if (
226
222
  operation.method.toLowerCase() === 'get' &&
@@ -229,7 +225,10 @@ class Manager extends EventEmitter {
229
225
  Object.keys(body).length === 0
230
226
  ) {
231
227
  this.__pendingCalls[pendingCallId] = pendingCall;
232
- this.__pendingCalls[pendingCallId].finally(() => {
228
+ this.__pendingCalls[pendingCallId].catch(() => {
229
+ // We do nothing with the error here the caller is responsible. We just want to
230
+ // cleanup the pending call.
231
+ }).finally(() => {
233
232
  delete this.__pendingCalls[pendingCallId];
234
233
  });
235
234
  }
@@ -18,6 +18,81 @@ class ManagerFlow extends Manager {
18
18
  FlowCardAction,
19
19
  }
20
20
 
21
+ async getFlowCardTrigger({
22
+ $cache = true,
23
+ id,
24
+ }) {
25
+ if ($cache === true && this.__cache['flowcardtrigger'][id]) {
26
+ return this.__cache['flowcardtrigger'][id];
27
+ }
28
+
29
+ return this.__super__getFlowCardTrigger({
30
+ id: id,
31
+ uri: id.split(':', 3).join(':'),
32
+ });
33
+ }
34
+
35
+ async getFlowCardCondition({
36
+ $cache = true,
37
+ id,
38
+ }) {
39
+ if ($cache === true && this.__cache['flowcardcondition'][id]) {
40
+ return this.__cache['flowcardcondition'][id];
41
+ }
42
+
43
+ return this.__super__getFlowCardCondition({
44
+ id: id,
45
+ uri: id.split(':', 3).join(':'),
46
+ });
47
+ }
48
+
49
+ async runFlowCardCondition({
50
+ id,
51
+ ...props
52
+ }) {
53
+ return this.__super__runFlowCardCondition({
54
+ id: id,
55
+ uri: id.split(':', 3).join(':'),
56
+ ...props,
57
+ });
58
+ }
59
+
60
+ async getFlowCardAction({
61
+ $cache = true,
62
+ id,
63
+ }) {
64
+ if ($cache === true && this.__cache['flowcardaction'][id]) {
65
+ return this.__cache['flowcardaction'][id];
66
+ }
67
+
68
+ return this.__super__getFlowCardAction({
69
+ id: id,
70
+ uri: id.split(':', 3).join(':'),
71
+ });
72
+ }
73
+
74
+ async runFlowCardAction({
75
+ id,
76
+ ...props
77
+ }) {
78
+ return this.__super__runFlowCardAction({
79
+ id: id,
80
+ uri: id.split(':', 3).join(':'),
81
+ ...props,
82
+ });
83
+ }
84
+
85
+ async getFlowCardAutocomplete({
86
+ id,
87
+ ...props
88
+ }) {
89
+ return this.__super__getFlowCardAutocomplete({
90
+ id: id,
91
+ uri: id.split(':', 3).join(':'),
92
+ ...props,
93
+ });
94
+ }
95
+
21
96
  }
22
97
 
23
98
  module.exports = ManagerFlow;
@@ -551,7 +551,9 @@ class HomeyAPIV3 extends HomeyAPI {
551
551
 
552
552
  await this.connect();
553
553
  await new Promise((resolve, reject) => {
554
- this.__ioNamespace.once('disconnect', reject);
554
+ this.__ioNamespace.once('disconnect', (reason) => {
555
+ reject(reason);
556
+ });
555
557
  this.__ioNamespace.emit('subscribe', uri, err => {
556
558
  if (err) {
557
559
  this.__debug('Failed to subscribe', uri, err);
package/lib/Util.js CHANGED
@@ -236,7 +236,7 @@ class Util {
236
236
  rejections[i] = err;
237
237
 
238
238
  if (rejections.length === promises.length) {
239
- reject(rejections);
239
+ reject(rejections[i]);
240
240
  }
241
241
  });
242
242
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-api",
3
- "version": "3.0.16",
3
+ "version": "3.0.18",
4
4
  "description": "Homey API",
5
5
  "main": "index.js",
6
6
  "files": [