homey-api 3.0.0-rc.12 → 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.
|
@@ -11,10 +11,16 @@ class Flow extends Item {
|
|
|
11
11
|
* @returns Promise<Boolean>
|
|
12
12
|
*/
|
|
13
13
|
async isBroken() {
|
|
14
|
-
|
|
14
|
+
const managerFlow = this.homey.flow;
|
|
15
|
+
if (!managerFlow.isConnected()) {
|
|
15
16
|
throw new Error('Flow.isBroken requires ManagerFlow to be connected.');
|
|
16
17
|
}
|
|
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
|
+
|
|
18
24
|
// Array of local & global Token IDs.
|
|
19
25
|
// For example [ 'foo', 'homey:x:y|abc' ]
|
|
20
26
|
const tokenIds = [];
|
|
@@ -22,7 +28,6 @@ class Flow extends Item {
|
|
|
22
28
|
const checkToken = async tokenId => {
|
|
23
29
|
// If this is a global Token, fetch all FlowTokens
|
|
24
30
|
if (tokenId.includes('|')) {
|
|
25
|
-
const managerFlowToken = this.homey.flowtoken;
|
|
26
31
|
const flowTokens = await managerFlowToken.getFlowTokens(); // Fill the cache
|
|
27
32
|
for (const flowTokenId of Object.keys(flowTokens)) {
|
|
28
33
|
tokenIds.push(flowTokenId);
|
|
@@ -55,7 +60,7 @@ class Flow extends Item {
|
|
|
55
60
|
// Check Trigger
|
|
56
61
|
if (this.trigger) {
|
|
57
62
|
try {
|
|
58
|
-
await
|
|
63
|
+
await managerFlow.getFlowCardTriggers(); // Fill the cache
|
|
59
64
|
const triggerCard = await this.manager.getFlowCardTrigger({ id: this.trigger.id });
|
|
60
65
|
await checkTokens(this.trigger);
|
|
61
66
|
|
|
@@ -75,7 +80,7 @@ class Flow extends Item {
|
|
|
75
80
|
if (Array.isArray(this.conditions)) {
|
|
76
81
|
for (const condition of Object.values(this.conditions)) {
|
|
77
82
|
try {
|
|
78
|
-
await
|
|
83
|
+
await managerFlow.getFlowCardConditions(); // Fill the cache
|
|
79
84
|
const conditionCard = await this.manager.getFlowCardCondition({ id: condition.id });
|
|
80
85
|
await checkTokens(condition);
|
|
81
86
|
} catch (err) {
|
|
@@ -89,7 +94,7 @@ class Flow extends Item {
|
|
|
89
94
|
if (Array.isArray(this.actions)) {
|
|
90
95
|
for (const action of Object.values(this.actions)) {
|
|
91
96
|
try {
|
|
92
|
-
await
|
|
97
|
+
await managerFlow.getFlowCardActions(); // Fill the cache
|
|
93
98
|
const actionCard = await this.manager.getFlowCardAction({ id: action.id });
|
|
94
99
|
await checkTokens(action);
|
|
95
100
|
} catch (err) {
|