homey-api 3.0.0-rc.11 → 3.0.0-rc.13
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.
- package/assets/specifications/AthomCloudAPI.json +16 -0
- package/assets/types/homey-api.private.d.ts +23 -0
- package/lib/HomeyAPI/HomeyAPIV2/ManagerFlow/Flow.js +2 -0
- package/lib/HomeyAPI/HomeyAPIV2/ManagerFlow.js +1 -1
- package/lib/HomeyAPI/HomeyAPIV3/Manager.js +1 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerFlow/Flow.js +96 -1
- package/package.json +1 -1
|
@@ -863,6 +863,22 @@
|
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
865
|
},
|
|
866
|
+
"activateHomey": {
|
|
867
|
+
"path": "/homey/{id}/activate",
|
|
868
|
+
"method": "post",
|
|
869
|
+
"private": true,
|
|
870
|
+
"parameters": {
|
|
871
|
+
"id": {
|
|
872
|
+
"in": "path",
|
|
873
|
+
"type": "string",
|
|
874
|
+
"required": true
|
|
875
|
+
},
|
|
876
|
+
"userId": {
|
|
877
|
+
"type": "string",
|
|
878
|
+
"in": "body"
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
},
|
|
866
882
|
"addHomeyLicense": {
|
|
867
883
|
"path": "/homey/{homeyId}/license/{license}",
|
|
868
884
|
"method": "post",
|
|
@@ -2628,6 +2628,29 @@
|
|
|
2628
2628
|
|
|
2629
2629
|
|
|
2630
2630
|
|
|
2631
|
+
):
|
|
2632
|
+
Promise<any>;
|
|
2633
|
+
|
|
2634
|
+
activateHomey(
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
|
|
2638
|
+
|
|
2639
|
+
opts: {
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
id: string,
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
userId: string,
|
|
2647
|
+
|
|
2648
|
+
|
|
2649
|
+
},
|
|
2650
|
+
|
|
2651
|
+
|
|
2652
|
+
|
|
2653
|
+
|
|
2631
2654
|
):
|
|
2632
2655
|
Promise<any>;
|
|
2633
2656
|
|
|
@@ -66,7 +66,7 @@ class ManagerFlow extends Manager {
|
|
|
66
66
|
return this.__cache['flowcardtrigger'][id];
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
return this.
|
|
69
|
+
return this.__super__getFlowCardTrigger({
|
|
70
70
|
id: id.split(':').reverse()[0],
|
|
71
71
|
uri: id.split(':', 3).join(':'),
|
|
72
72
|
});
|
|
@@ -213,6 +213,7 @@ class Manager extends EventEmitter {
|
|
|
213
213
|
// This is about ~2x faster than HTTP
|
|
214
214
|
if (this.homey.isConnected() && $socket === true) {
|
|
215
215
|
result = await Util.timeout(new Promise((resolve, reject) => {
|
|
216
|
+
this.__debug(`IO ${operationId}`);
|
|
216
217
|
this.homey.__ioNamespace.emit('api', {
|
|
217
218
|
args,
|
|
218
219
|
operation: operationId,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
|
|
1
3
|
'use strict';
|
|
2
4
|
|
|
3
5
|
const Item = require('../Item');
|
|
@@ -9,7 +11,100 @@ class Flow extends Item {
|
|
|
9
11
|
* @returns Promise<Boolean>
|
|
10
12
|
*/
|
|
11
13
|
async isBroken() {
|
|
12
|
-
|
|
14
|
+
const managerFlow = this.homey.flow;
|
|
15
|
+
if (!managerFlow.isConnected()) {
|
|
16
|
+
throw new Error('Flow.isBroken requires ManagerFlow to be connected.');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const managerFlowToken = this.homey.flowtoken;
|
|
20
|
+
if (!managerFlowToken.isConnected()) {
|
|
21
|
+
throw new Error('Flow.isBroken requires ManagerFlowToken to be connected.');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Array of local & global Token IDs.
|
|
25
|
+
// For example [ 'foo', 'homey:x:y|abc' ]
|
|
26
|
+
const tokenIds = [];
|
|
27
|
+
|
|
28
|
+
const checkToken = async tokenId => {
|
|
29
|
+
// If this is a global Token, fetch all FlowTokens
|
|
30
|
+
if (tokenId.includes('|')) {
|
|
31
|
+
const flowTokens = await managerFlowToken.getFlowTokens(); // Fill the cache
|
|
32
|
+
for (const flowTokenId of Object.keys(flowTokens)) {
|
|
33
|
+
tokenIds.push(flowTokenId);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
tokenId = tokenId.replace('|', ':');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!tokenIds.includes(tokenId)) {
|
|
40
|
+
throw new Error(`Missing Token: ${tokenId}`);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const checkTokens = async card => {
|
|
45
|
+
// Check droptoken
|
|
46
|
+
if (card.droptoken) {
|
|
47
|
+
await checkToken(card.droptoken);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof card.args === 'object') {
|
|
51
|
+
for (const arg of Object.values(card.args)) {
|
|
52
|
+
if (typeof arg !== 'string') continue;
|
|
53
|
+
for (const [tokenMatch, tokenId] of arg.matchAll(/\[\[(.*?)\]\]/g)) {
|
|
54
|
+
await checkToken(tokenId);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Check Trigger
|
|
61
|
+
if (this.trigger) {
|
|
62
|
+
try {
|
|
63
|
+
await managerFlow.getFlowCardTriggers(); // Fill the cache
|
|
64
|
+
const triggerCard = await this.manager.getFlowCardTrigger({ id: this.trigger.id });
|
|
65
|
+
await checkTokens(this.trigger);
|
|
66
|
+
|
|
67
|
+
// Add FlowCardTrigger.tokens to internal tokens cache
|
|
68
|
+
if (Array.isArray(triggerCard.tokens)) {
|
|
69
|
+
for (const tokenId of Object.keys(triggerCard.tokens)) {
|
|
70
|
+
tokenIds.push(tokenId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
this.__debug(err.message);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Check Conditions
|
|
80
|
+
if (Array.isArray(this.conditions)) {
|
|
81
|
+
for (const condition of Object.values(this.conditions)) {
|
|
82
|
+
try {
|
|
83
|
+
await managerFlow.getFlowCardConditions(); // Fill the cache
|
|
84
|
+
const conditionCard = await this.manager.getFlowCardCondition({ id: condition.id });
|
|
85
|
+
await checkTokens(condition);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
this.__debug(err.message);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Check Actions
|
|
94
|
+
if (Array.isArray(this.actions)) {
|
|
95
|
+
for (const action of Object.values(this.actions)) {
|
|
96
|
+
try {
|
|
97
|
+
await managerFlow.getFlowCardActions(); // Fill the cache
|
|
98
|
+
const actionCard = await this.manager.getFlowCardAction({ id: action.id });
|
|
99
|
+
await checkTokens(action);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
this.__debug(err.message);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return false;
|
|
13
108
|
}
|
|
14
109
|
|
|
15
110
|
}
|