homey-api 3.4.12 → 3.4.14
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.
|
@@ -29,7 +29,7 @@ class Homey extends APIDefinition {
|
|
|
29
29
|
* @param {string|array} [opts.strategy] - One string, or an array of {@link HomeyAPI#DISCOVERY_STRATEGIES} strings, to connect to the Homey.
|
|
30
30
|
* @returns {Promise<HomeyAPI>}
|
|
31
31
|
*/
|
|
32
|
-
async authenticate({ strategy } = {}) {
|
|
32
|
+
async authenticate({ strategy, reconnect } = {}) {
|
|
33
33
|
const HomeyAPI = (() => {
|
|
34
34
|
if (this.apiVersion === 1) return HomeyAPIV1;
|
|
35
35
|
if (this.apiVersion === 2) return HomeyAPIV2;
|
|
@@ -40,6 +40,7 @@ class Homey extends APIDefinition {
|
|
|
40
40
|
|
|
41
41
|
const homey = new HomeyAPI({
|
|
42
42
|
strategy,
|
|
43
|
+
reconnect,
|
|
43
44
|
api: this.__api,
|
|
44
45
|
properties: this.__properties,
|
|
45
46
|
debug: (...props) => {
|
|
@@ -34,20 +34,20 @@ class Flow extends FlowV3 {
|
|
|
34
34
|
static transformSet(item) {
|
|
35
35
|
if (item.trigger) {
|
|
36
36
|
item.trigger.uri = item.trigger.id.split(':', 3).join(':');
|
|
37
|
-
item.trigger.id = item.trigger.id.split(':').
|
|
37
|
+
item.trigger.id = item.trigger.id.split(':').slice(3).join(':');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (Array.isArray(item.conditions)) {
|
|
41
41
|
item.conditions.forEach(card => {
|
|
42
42
|
card.uri = card.id.split(':', 3).join(':');
|
|
43
|
-
card.id = card.id.split(':').
|
|
43
|
+
card.id = card.id.split(':').slice(3).join(':');
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (Array.isArray(item.actions)) {
|
|
48
48
|
item.actions.forEach(card => {
|
|
49
49
|
card.uri = card.id.split(':', 3).join(':');
|
|
50
|
-
card.id = card.id.split(':').
|
|
50
|
+
card.id = card.id.split(':').slice(3).join(':');
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -67,7 +67,7 @@ class ManagerFlow extends ManagerFlowV3 {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
return this.__super__getFlowCardTrigger({
|
|
70
|
-
id: id.split(':').
|
|
70
|
+
id: id.split(':').slice(3).join(':'),
|
|
71
71
|
uri: id.split(':', 3).join(':'),
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -81,7 +81,7 @@ class ManagerFlow extends ManagerFlowV3 {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
return this.__super__getFlowCardCondition({
|
|
84
|
-
id: id.split(':').
|
|
84
|
+
id: id.split(':').slice(3).join(':'),
|
|
85
85
|
uri: id.split(':', 3).join(':'),
|
|
86
86
|
});
|
|
87
87
|
}
|
|
@@ -91,7 +91,7 @@ class ManagerFlow extends ManagerFlowV3 {
|
|
|
91
91
|
...props
|
|
92
92
|
}) {
|
|
93
93
|
return this.__super__runFlowCardCondition({
|
|
94
|
-
id: id.split(':').
|
|
94
|
+
id: id.split(':').slice(3).join(':'),
|
|
95
95
|
uri: id.split(':', 3).join(':'),
|
|
96
96
|
...props,
|
|
97
97
|
});
|
|
@@ -106,7 +106,7 @@ class ManagerFlow extends ManagerFlowV3 {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
return this.__super__getFlowCardAction({
|
|
109
|
-
id: id.split(':').
|
|
109
|
+
id: id.split(':').slice(3).join(':'),
|
|
110
110
|
uri: id.split(':', 3).join(':'),
|
|
111
111
|
});
|
|
112
112
|
}
|
|
@@ -116,7 +116,7 @@ class ManagerFlow extends ManagerFlowV3 {
|
|
|
116
116
|
...props
|
|
117
117
|
}) {
|
|
118
118
|
return this.__super__runFlowCardAction({
|
|
119
|
-
id: id.split(':').
|
|
119
|
+
id: id.split(':').slice(3).join(':'),
|
|
120
120
|
uri: id.split(':', 3).join(':'),
|
|
121
121
|
...props,
|
|
122
122
|
});
|
|
@@ -127,7 +127,7 @@ class ManagerFlow extends ManagerFlowV3 {
|
|
|
127
127
|
...props
|
|
128
128
|
}) {
|
|
129
129
|
return this.__super__getFlowCardAutocomplete({
|
|
130
|
-
id: id.split(':').
|
|
130
|
+
id: id.split(':').slice(3).join(':'),
|
|
131
131
|
uri: id.split(':', 3).join(':'),
|
|
132
132
|
...props,
|
|
133
133
|
});
|
|
@@ -49,6 +49,7 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
49
49
|
baseUrl = null,
|
|
50
50
|
token = null,
|
|
51
51
|
session = null,
|
|
52
|
+
reconnect = true,
|
|
52
53
|
...props
|
|
53
54
|
}) {
|
|
54
55
|
super({ properties, ...props });
|
|
@@ -65,6 +66,12 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
65
66
|
writable: true,
|
|
66
67
|
});
|
|
67
68
|
|
|
69
|
+
Object.defineProperty(this, '__reconnect', {
|
|
70
|
+
value: reconnect,
|
|
71
|
+
enumerable: false,
|
|
72
|
+
writable: true,
|
|
73
|
+
});
|
|
74
|
+
|
|
68
75
|
Object.defineProperty(this, '__token', {
|
|
69
76
|
value: token,
|
|
70
77
|
enumerable: false,
|
|
@@ -584,6 +591,11 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
584
591
|
|
|
585
592
|
await this.connect();
|
|
586
593
|
await Util.timeout(new Promise((resolve, reject) => {
|
|
594
|
+
if (this.isConnected() !== true) {
|
|
595
|
+
reject(new Error('Not connected after connect.'));
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
|
|
587
599
|
this.__homeySocket.once('disconnect', (reason) => {
|
|
588
600
|
reject(new Error(reason));
|
|
589
601
|
});
|
|
@@ -655,9 +667,7 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
655
667
|
};
|
|
656
668
|
}
|
|
657
669
|
|
|
658
|
-
async connect({
|
|
659
|
-
reconnect = true
|
|
660
|
-
} = {}) {
|
|
670
|
+
async connect() {
|
|
661
671
|
if (!this.__connectPromise) {
|
|
662
672
|
this.__connectPromise = Promise.resolve().then(async () => {
|
|
663
673
|
// Ensure Base URL
|
|
@@ -676,7 +686,7 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
676
686
|
pingTimeout: 8000,
|
|
677
687
|
pingInterval: 5000,
|
|
678
688
|
},
|
|
679
|
-
reconnection:
|
|
689
|
+
reconnection: this.__reconnect,
|
|
680
690
|
});
|
|
681
691
|
|
|
682
692
|
this.__socket.on('disconnect', reason => {
|