homebridge-dummy 1.3.2 → 1.4.0-beta.0
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/CHANGELOG.md +12 -1
- package/README.md +34 -2
- package/config.schema.json +140 -28
- package/dist/accessory/base.d.ts +27 -8
- package/dist/accessory/base.js +46 -36
- package/dist/accessory/base.js.map +1 -1
- package/dist/accessory/group.d.ts +9 -1
- package/dist/accessory/group.js +14 -9
- package/dist/accessory/group.js.map +1 -1
- package/dist/accessory/helpers.d.ts +3 -5
- package/dist/accessory/helpers.js +12 -12
- package/dist/accessory/helpers.js.map +1 -1
- package/dist/accessory/lock.d.ts +6 -6
- package/dist/accessory/lock.js +14 -8
- package/dist/accessory/lock.js.map +1 -1
- package/dist/accessory/onoff/lightbulb.d.ts +4 -4
- package/dist/accessory/onoff/lightbulb.js +3 -3
- package/dist/accessory/onoff/lightbulb.js.map +1 -1
- package/dist/accessory/onoff/onoff.d.ts +7 -7
- package/dist/accessory/onoff/onoff.js +25 -13
- package/dist/accessory/onoff/onoff.js.map +1 -1
- package/dist/accessory/position/garage.d.ts +3 -4
- package/dist/accessory/position/garage.js +3 -3
- package/dist/accessory/position/garage.js.map +1 -1
- package/dist/accessory/position/position.d.ts +6 -6
- package/dist/accessory/position/position.js +14 -8
- package/dist/accessory/position/position.js.map +1 -1
- package/dist/accessory/sensor.d.ts +4 -5
- package/dist/accessory/sensor.js +14 -15
- package/dist/accessory/sensor.js.map +1 -1
- package/dist/accessory/thermostat.d.ts +5 -6
- package/dist/accessory/thermostat.js +17 -17
- package/dist/accessory/thermostat.js.map +1 -1
- package/dist/homebridge/platform.d.ts +1 -1
- package/dist/homebridge/platform.js +29 -12
- package/dist/homebridge/platform.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +1 -1
- package/dist/homebridge-ui/public/ui.js +1 -1
- package/dist/i18n/de.d.ts +20 -0
- package/dist/i18n/en.d.ts +20 -0
- package/dist/i18n/en.js +20 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts +20 -0
- package/dist/i18n/i18n.d.ts +20 -0
- package/dist/i18n/ru.d.ts +20 -0
- package/dist/i18n/template.d.ts +20 -0
- package/dist/model/conditions.d.ts +14 -0
- package/dist/model/conditions.js +99 -0
- package/dist/model/conditions.js.map +1 -0
- package/dist/model/enums.d.ts +15 -4
- package/dist/model/enums.js +36 -12
- package/dist/model/enums.js.map +1 -1
- package/dist/model/types.d.ts +13 -3
- package/dist/timeout/limiter.d.ts +2 -2
- package/dist/timeout/limiter.js +8 -8
- package/dist/timeout/limiter.js.map +1 -1
- package/dist/timeout/schedule.d.ts +3 -3
- package/dist/timeout/schedule.js +18 -18
- package/dist/timeout/schedule.js.map +1 -1
- package/dist/timeout/timeout.d.ts +6 -4
- package/dist/timeout/timeout.js +12 -7
- package/dist/timeout/timeout.js.map +1 -1
- package/dist/timeout/timer.d.ts +2 -3
- package/dist/timeout/timer.js +7 -9
- package/dist/timeout/timer.js.map +1 -1
- package/dist/tools/configMigration.js +2 -2
- package/dist/tools/configMigration.js.map +1 -1
- package/package.json +1 -1
package/dist/i18n/es.d.ts
CHANGED
|
@@ -8,6 +8,17 @@ declare const es: {
|
|
|
8
8
|
error: string;
|
|
9
9
|
executed: string;
|
|
10
10
|
};
|
|
11
|
+
conditions: {
|
|
12
|
+
currentResult: string;
|
|
13
|
+
evaluatingConditions: string;
|
|
14
|
+
satisfied: string;
|
|
15
|
+
notSatisfied: string;
|
|
16
|
+
selfReference: string;
|
|
17
|
+
statesEqual: string;
|
|
18
|
+
statesNotEqual: string;
|
|
19
|
+
stateUnknown: string;
|
|
20
|
+
statesUnrelated: string;
|
|
21
|
+
};
|
|
11
22
|
lightbulb: {
|
|
12
23
|
brightness: string;
|
|
13
24
|
stateOn: string;
|
|
@@ -28,6 +39,7 @@ declare const es: {
|
|
|
28
39
|
unsecured: string;
|
|
29
40
|
};
|
|
30
41
|
onOff: {
|
|
42
|
+
badDefault: string;
|
|
31
43
|
stateOff: string;
|
|
32
44
|
stateOn: string;
|
|
33
45
|
};
|
|
@@ -70,6 +82,7 @@ declare const es: {
|
|
|
70
82
|
description: {
|
|
71
83
|
commands: string;
|
|
72
84
|
cron: string;
|
|
85
|
+
conditions: string;
|
|
73
86
|
limiter: string;
|
|
74
87
|
random: string;
|
|
75
88
|
schedule: string;
|
|
@@ -102,10 +115,13 @@ declare const es: {
|
|
|
102
115
|
minutely: string;
|
|
103
116
|
month: string;
|
|
104
117
|
monthly: string;
|
|
118
|
+
none: string;
|
|
105
119
|
occupancySensor: string;
|
|
106
120
|
off: string;
|
|
107
121
|
on: string;
|
|
108
122
|
open: string;
|
|
123
|
+
operatorAnd: string;
|
|
124
|
+
operatorOr: string;
|
|
109
125
|
outlet: string;
|
|
110
126
|
milliseconds: string;
|
|
111
127
|
minutes: string;
|
|
@@ -139,6 +155,7 @@ declare const es: {
|
|
|
139
155
|
yes: string;
|
|
140
156
|
title: {
|
|
141
157
|
accessory: string;
|
|
158
|
+
accessoryState: string;
|
|
142
159
|
commandClose: string;
|
|
143
160
|
commandOff: string;
|
|
144
161
|
commandOn: string;
|
|
@@ -147,6 +164,8 @@ declare const es: {
|
|
|
147
164
|
commands: string;
|
|
148
165
|
commandTemperature: string;
|
|
149
166
|
commandUnlock: string;
|
|
167
|
+
condition: string;
|
|
168
|
+
conditions: string;
|
|
150
169
|
cron: string;
|
|
151
170
|
cronCustom: string;
|
|
152
171
|
defaultBrightness: string;
|
|
@@ -161,6 +180,7 @@ declare const es: {
|
|
|
161
180
|
limit: string;
|
|
162
181
|
limiter: string;
|
|
163
182
|
name: string;
|
|
183
|
+
operator: string;
|
|
164
184
|
period: string;
|
|
165
185
|
preset: string;
|
|
166
186
|
random: string;
|
package/dist/i18n/i18n.d.ts
CHANGED
|
@@ -19,6 +19,17 @@ declare const translations: {
|
|
|
19
19
|
error: string;
|
|
20
20
|
executed: string;
|
|
21
21
|
};
|
|
22
|
+
conditions: {
|
|
23
|
+
currentResult: string;
|
|
24
|
+
evaluatingConditions: string;
|
|
25
|
+
satisfied: string;
|
|
26
|
+
notSatisfied: string;
|
|
27
|
+
selfReference: string;
|
|
28
|
+
statesEqual: string;
|
|
29
|
+
statesNotEqual: string;
|
|
30
|
+
stateUnknown: string;
|
|
31
|
+
statesUnrelated: string;
|
|
32
|
+
};
|
|
22
33
|
lightbulb: {
|
|
23
34
|
brightness: string;
|
|
24
35
|
stateOn: string;
|
|
@@ -39,6 +50,7 @@ declare const translations: {
|
|
|
39
50
|
unsecured: string;
|
|
40
51
|
};
|
|
41
52
|
onOff: {
|
|
53
|
+
badDefault: string;
|
|
42
54
|
stateOff: string;
|
|
43
55
|
stateOn: string;
|
|
44
56
|
};
|
|
@@ -81,6 +93,7 @@ declare const translations: {
|
|
|
81
93
|
description: {
|
|
82
94
|
commands: string;
|
|
83
95
|
cron: string;
|
|
96
|
+
conditions: string;
|
|
84
97
|
limiter: string;
|
|
85
98
|
random: string;
|
|
86
99
|
schedule: string;
|
|
@@ -113,10 +126,13 @@ declare const translations: {
|
|
|
113
126
|
minutely: string;
|
|
114
127
|
month: string;
|
|
115
128
|
monthly: string;
|
|
129
|
+
none: string;
|
|
116
130
|
occupancySensor: string;
|
|
117
131
|
off: string;
|
|
118
132
|
on: string;
|
|
119
133
|
open: string;
|
|
134
|
+
operatorAnd: string;
|
|
135
|
+
operatorOr: string;
|
|
120
136
|
outlet: string;
|
|
121
137
|
milliseconds: string;
|
|
122
138
|
minutes: string;
|
|
@@ -150,6 +166,7 @@ declare const translations: {
|
|
|
150
166
|
yes: string;
|
|
151
167
|
title: {
|
|
152
168
|
accessory: string;
|
|
169
|
+
accessoryState: string;
|
|
153
170
|
commandClose: string;
|
|
154
171
|
commandOff: string;
|
|
155
172
|
commandOn: string;
|
|
@@ -158,6 +175,8 @@ declare const translations: {
|
|
|
158
175
|
commands: string;
|
|
159
176
|
commandTemperature: string;
|
|
160
177
|
commandUnlock: string;
|
|
178
|
+
condition: string;
|
|
179
|
+
conditions: string;
|
|
161
180
|
cron: string;
|
|
162
181
|
cronCustom: string;
|
|
163
182
|
defaultBrightness: string;
|
|
@@ -172,6 +191,7 @@ declare const translations: {
|
|
|
172
191
|
limit: string;
|
|
173
192
|
limiter: string;
|
|
174
193
|
name: string;
|
|
194
|
+
operator: string;
|
|
175
195
|
period: string;
|
|
176
196
|
preset: string;
|
|
177
197
|
random: string;
|
package/dist/i18n/ru.d.ts
CHANGED
|
@@ -8,6 +8,17 @@ declare const ru: {
|
|
|
8
8
|
error: string;
|
|
9
9
|
executed: string;
|
|
10
10
|
};
|
|
11
|
+
conditions: {
|
|
12
|
+
currentResult: string;
|
|
13
|
+
evaluatingConditions: string;
|
|
14
|
+
satisfied: string;
|
|
15
|
+
notSatisfied: string;
|
|
16
|
+
selfReference: string;
|
|
17
|
+
statesEqual: string;
|
|
18
|
+
statesNotEqual: string;
|
|
19
|
+
stateUnknown: string;
|
|
20
|
+
statesUnrelated: string;
|
|
21
|
+
};
|
|
11
22
|
lightbulb: {
|
|
12
23
|
brightness: string;
|
|
13
24
|
stateOn: string;
|
|
@@ -28,6 +39,7 @@ declare const ru: {
|
|
|
28
39
|
unsecured: string;
|
|
29
40
|
};
|
|
30
41
|
onOff: {
|
|
42
|
+
badDefault: string;
|
|
31
43
|
stateOff: string;
|
|
32
44
|
stateOn: string;
|
|
33
45
|
};
|
|
@@ -70,6 +82,7 @@ declare const ru: {
|
|
|
70
82
|
description: {
|
|
71
83
|
commands: string;
|
|
72
84
|
cron: string;
|
|
85
|
+
conditions: string;
|
|
73
86
|
limiter: string;
|
|
74
87
|
random: string;
|
|
75
88
|
schedule: string;
|
|
@@ -102,10 +115,13 @@ declare const ru: {
|
|
|
102
115
|
minutely: string;
|
|
103
116
|
month: string;
|
|
104
117
|
monthly: string;
|
|
118
|
+
none: string;
|
|
105
119
|
occupancySensor: string;
|
|
106
120
|
off: string;
|
|
107
121
|
on: string;
|
|
108
122
|
open: string;
|
|
123
|
+
operatorAnd: string;
|
|
124
|
+
operatorOr: string;
|
|
109
125
|
outlet: string;
|
|
110
126
|
milliseconds: string;
|
|
111
127
|
minutes: string;
|
|
@@ -139,6 +155,7 @@ declare const ru: {
|
|
|
139
155
|
yes: string;
|
|
140
156
|
title: {
|
|
141
157
|
accessory: string;
|
|
158
|
+
accessoryState: string;
|
|
142
159
|
commandClose: string;
|
|
143
160
|
commandOff: string;
|
|
144
161
|
commandOn: string;
|
|
@@ -147,6 +164,8 @@ declare const ru: {
|
|
|
147
164
|
commands: string;
|
|
148
165
|
commandTemperature: string;
|
|
149
166
|
commandUnlock: string;
|
|
167
|
+
condition: string;
|
|
168
|
+
conditions: string;
|
|
150
169
|
cron: string;
|
|
151
170
|
cronCustom: string;
|
|
152
171
|
defaultBrightness: string;
|
|
@@ -161,6 +180,7 @@ declare const ru: {
|
|
|
161
180
|
limit: string;
|
|
162
181
|
limiter: string;
|
|
163
182
|
name: string;
|
|
183
|
+
operator: string;
|
|
164
184
|
period: string;
|
|
165
185
|
preset: string;
|
|
166
186
|
random: string;
|
package/dist/i18n/template.d.ts
CHANGED
|
@@ -8,6 +8,17 @@ declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
|
8
8
|
error: string;
|
|
9
9
|
executed: string;
|
|
10
10
|
};
|
|
11
|
+
conditions: {
|
|
12
|
+
currentResult: string;
|
|
13
|
+
evaluatingConditions: string;
|
|
14
|
+
satisfied: string;
|
|
15
|
+
notSatisfied: string;
|
|
16
|
+
selfReference: string;
|
|
17
|
+
statesEqual: string;
|
|
18
|
+
statesNotEqual: string;
|
|
19
|
+
stateUnknown: string;
|
|
20
|
+
statesUnrelated: string;
|
|
21
|
+
};
|
|
11
22
|
lightbulb: {
|
|
12
23
|
brightness: string;
|
|
13
24
|
stateOn: string;
|
|
@@ -28,6 +39,7 @@ declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
|
28
39
|
unsecured: string;
|
|
29
40
|
};
|
|
30
41
|
onOff: {
|
|
42
|
+
badDefault: string;
|
|
31
43
|
stateOff: string;
|
|
32
44
|
stateOn: string;
|
|
33
45
|
};
|
|
@@ -70,6 +82,7 @@ declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
|
70
82
|
description: {
|
|
71
83
|
commands: string;
|
|
72
84
|
cron: string;
|
|
85
|
+
conditions: string;
|
|
73
86
|
limiter: string;
|
|
74
87
|
random: string;
|
|
75
88
|
schedule: string;
|
|
@@ -102,10 +115,13 @@ declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
|
102
115
|
minutely: string;
|
|
103
116
|
month: string;
|
|
104
117
|
monthly: string;
|
|
118
|
+
none: string;
|
|
105
119
|
occupancySensor: string;
|
|
106
120
|
off: string;
|
|
107
121
|
on: string;
|
|
108
122
|
open: string;
|
|
123
|
+
operatorAnd: string;
|
|
124
|
+
operatorOr: string;
|
|
109
125
|
outlet: string;
|
|
110
126
|
milliseconds: string;
|
|
111
127
|
minutes: string;
|
|
@@ -139,6 +155,7 @@ declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
|
139
155
|
yes: string;
|
|
140
156
|
title: {
|
|
141
157
|
accessory: string;
|
|
158
|
+
accessoryState: string;
|
|
142
159
|
commandClose: string;
|
|
143
160
|
commandOff: string;
|
|
144
161
|
commandOn: string;
|
|
@@ -147,6 +164,8 @@ declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
|
147
164
|
commands: string;
|
|
148
165
|
commandTemperature: string;
|
|
149
166
|
commandUnlock: string;
|
|
167
|
+
condition: string;
|
|
168
|
+
conditions: string;
|
|
150
169
|
cron: string;
|
|
151
170
|
cronCustom: string;
|
|
152
171
|
defaultBrightness: string;
|
|
@@ -161,6 +180,7 @@ declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
|
161
180
|
limit: string;
|
|
162
181
|
limiter: string;
|
|
163
182
|
name: string;
|
|
183
|
+
operator: string;
|
|
164
184
|
period: string;
|
|
165
185
|
preset: string;
|
|
166
186
|
random: string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConditionsConfig } from './types.js';
|
|
2
|
+
import { AccessoryState } from './enums.js';
|
|
3
|
+
import { Log } from '../tools/log.js';
|
|
4
|
+
export declare class ConditionManager {
|
|
5
|
+
private readonly log;
|
|
6
|
+
private readonly targets;
|
|
7
|
+
private readonly triggersToTargets;
|
|
8
|
+
private readonly triggerStates;
|
|
9
|
+
constructor(log: Log);
|
|
10
|
+
register(name: string, identifier: string, conditions: ConditionsConfig | undefined, trigger: () => Promise<void>, reset: (() => Promise<void>) | undefined, disableLogging: boolean): void;
|
|
11
|
+
onStateChange(triggerId: string, state: AccessoryState): Promise<void>;
|
|
12
|
+
private evaluateConditions;
|
|
13
|
+
private compareStates;
|
|
14
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ConditionOperator, getStateType } from './enums.js';
|
|
2
|
+
import { assert } from '../tools/validation.js';
|
|
3
|
+
import { strings } from '../i18n/i18n.js';
|
|
4
|
+
export class ConditionManager {
|
|
5
|
+
log;
|
|
6
|
+
targets = new Map();
|
|
7
|
+
triggersToTargets = new Map();
|
|
8
|
+
triggerStates = new Map();
|
|
9
|
+
constructor(log) {
|
|
10
|
+
this.log = log;
|
|
11
|
+
}
|
|
12
|
+
register(name, identifier, conditions, trigger, reset, disableLogging) {
|
|
13
|
+
if (conditions === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!assert(this.log, name, conditions, 'operator', 'operands')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let valid = true;
|
|
20
|
+
for (const operand of conditions.operands) {
|
|
21
|
+
valid = valid && assert(this.log, name, operand, 'accessoryId', 'accessoryState');
|
|
22
|
+
if (operand.accessoryId === identifier) {
|
|
23
|
+
this.log.error(strings.conditions.selfReference, name);
|
|
24
|
+
valid = false;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!valid) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const target = { name, identifier, conditions, trigger, reset, disableLogging };
|
|
32
|
+
this.targets.set(identifier, target);
|
|
33
|
+
for (const operand of conditions.operands) {
|
|
34
|
+
const targetList = this.triggersToTargets.get(operand.accessoryId) ?? [];
|
|
35
|
+
targetList.push(identifier);
|
|
36
|
+
this.triggersToTargets.set(operand.accessoryId, targetList);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async onStateChange(triggerId, state) {
|
|
40
|
+
const targetIds = this.triggersToTargets.get(triggerId);
|
|
41
|
+
if (!targetIds) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.triggerStates.set(triggerId, state);
|
|
45
|
+
for (const targetId of targetIds) {
|
|
46
|
+
const target = this.targets.get(targetId);
|
|
47
|
+
if (!target) {
|
|
48
|
+
throw new Error('Unable to find target associated with the supplied trigger');
|
|
49
|
+
}
|
|
50
|
+
this.log.ifVerbose(strings.conditions.evaluatingConditions, target.name);
|
|
51
|
+
if (this.evaluateConditions(target.conditions)) {
|
|
52
|
+
if (!target.disableLogging) {
|
|
53
|
+
this.log.always(strings.conditions.satisfied, target.name);
|
|
54
|
+
}
|
|
55
|
+
await target.trigger();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.log.ifVerbose(strings.conditions.notSatisfied, target.name);
|
|
59
|
+
await target.reset?.();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
evaluateConditions(conditions) {
|
|
64
|
+
let result;
|
|
65
|
+
for (const operand of conditions.operands) {
|
|
66
|
+
const currentState = this.triggerStates.get(operand.accessoryId);
|
|
67
|
+
if (!currentState) {
|
|
68
|
+
this.log.ifVerbose(strings.conditions.stateUnknown, `'${operand.accessoryId}'`);
|
|
69
|
+
result = false;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
const operandResult = this.compareStates(currentState, operand.accessoryState);
|
|
73
|
+
switch (conditions.operator) {
|
|
74
|
+
case ConditionOperator.AND:
|
|
75
|
+
result = result === undefined ? operandResult : result && operandResult;
|
|
76
|
+
break;
|
|
77
|
+
case ConditionOperator.OR:
|
|
78
|
+
result = result === undefined ? operandResult : result || operandResult;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
this.log.ifVerbose(strings.conditions.currentResult, `'${String(result)}'`);
|
|
82
|
+
}
|
|
83
|
+
return result ?? false;
|
|
84
|
+
}
|
|
85
|
+
compareStates(current, desired) {
|
|
86
|
+
if (current === desired) {
|
|
87
|
+
this.log.ifVerbose(strings.conditions.statesEqual, `'${current}'`);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
const stateType = getStateType(current);
|
|
91
|
+
if (stateType && !Object.values(stateType).includes(desired)) {
|
|
92
|
+
this.log.error(strings.conditions.statesUnrelated, `'${current}'`, `'${desired}'`);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
this.log.ifVerbose(strings.conditions.statesNotEqual, `'${current}'`, `'${desired}'`);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/model/conditions.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG7E,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAW1C,MAAM,OAAO,gBAAgB;IAOE;IALZ,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IACpC,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEhD,aAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEnE,YAA6B,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;IAAG,CAAC;IAElC,QAAQ,CAAC,IAAY,EAAE,UAAkB,EAAE,UAAwC,EACxF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IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,EAAE,IAAI,OAAO,GAAG,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC;YACnF,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,IAAI,OAAO,GAAG,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC;QACtF,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
package/dist/model/enums.d.ts
CHANGED
|
@@ -28,16 +28,27 @@ export declare enum SensorCharacteristic {
|
|
|
28
28
|
OccupancyDetected = "OccupancyDetected",
|
|
29
29
|
SmokeDetected = "SmokeDetected"
|
|
30
30
|
}
|
|
31
|
-
export declare enum
|
|
31
|
+
export declare enum ConditionOperator {
|
|
32
|
+
AND = "and",
|
|
33
|
+
OR = "or"
|
|
34
|
+
}
|
|
35
|
+
export declare enum OnState {
|
|
36
|
+
ON = "on",
|
|
37
|
+
OFF = "off"
|
|
38
|
+
}
|
|
39
|
+
export declare function isValidOnState(input?: OnState): boolean;
|
|
40
|
+
export declare enum LockState {
|
|
32
41
|
LOCKED = "locked",
|
|
33
42
|
UNLOCKED = "unlocked"
|
|
34
43
|
}
|
|
35
|
-
export declare function isValidLockState(input?:
|
|
36
|
-
export declare enum
|
|
44
|
+
export declare function isValidLockState(input?: LockState): boolean;
|
|
45
|
+
export declare enum Position {
|
|
37
46
|
OPEN = "open",
|
|
38
47
|
CLOSED = "closed"
|
|
39
48
|
}
|
|
40
|
-
export declare function isValidPosition(input?:
|
|
49
|
+
export declare function isValidPosition(input?: Position): boolean;
|
|
50
|
+
export type AccessoryState = OnState | Position | LockState;
|
|
51
|
+
export declare function getStateType(input: AccessoryState): typeof OnState | typeof LockState | typeof Position | undefined;
|
|
41
52
|
export declare enum DefaultThermostatState {
|
|
42
53
|
AUTO = "auto",
|
|
43
54
|
COOL = "cool",
|
package/dist/model/enums.js
CHANGED
|
@@ -33,21 +33,45 @@ export var SensorCharacteristic;
|
|
|
33
33
|
SensorCharacteristic["OccupancyDetected"] = "OccupancyDetected";
|
|
34
34
|
SensorCharacteristic["SmokeDetected"] = "SmokeDetected";
|
|
35
35
|
})(SensorCharacteristic || (SensorCharacteristic = {}));
|
|
36
|
-
export var
|
|
37
|
-
(function (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})(
|
|
36
|
+
export var ConditionOperator;
|
|
37
|
+
(function (ConditionOperator) {
|
|
38
|
+
ConditionOperator["AND"] = "and";
|
|
39
|
+
ConditionOperator["OR"] = "or";
|
|
40
|
+
})(ConditionOperator || (ConditionOperator = {}));
|
|
41
|
+
export var OnState;
|
|
42
|
+
(function (OnState) {
|
|
43
|
+
OnState["ON"] = "on";
|
|
44
|
+
OnState["OFF"] = "off";
|
|
45
|
+
})(OnState || (OnState = {}));
|
|
46
|
+
export function isValidOnState(input) {
|
|
47
|
+
return input === undefined || Object.values(OnState).includes(input);
|
|
48
|
+
}
|
|
49
|
+
export var LockState;
|
|
50
|
+
(function (LockState) {
|
|
51
|
+
LockState["LOCKED"] = "locked";
|
|
52
|
+
LockState["UNLOCKED"] = "unlocked";
|
|
53
|
+
})(LockState || (LockState = {}));
|
|
41
54
|
export function isValidLockState(input) {
|
|
42
|
-
return input === undefined || Object.values(
|
|
55
|
+
return input === undefined || Object.values(LockState).includes(input);
|
|
43
56
|
}
|
|
44
|
-
export var
|
|
45
|
-
(function (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})(
|
|
57
|
+
export var Position;
|
|
58
|
+
(function (Position) {
|
|
59
|
+
Position["OPEN"] = "open";
|
|
60
|
+
Position["CLOSED"] = "closed";
|
|
61
|
+
})(Position || (Position = {}));
|
|
49
62
|
export function isValidPosition(input) {
|
|
50
|
-
return input === undefined || Object.values(
|
|
63
|
+
return input === undefined || Object.values(Position).includes(input);
|
|
64
|
+
}
|
|
65
|
+
export function getStateType(input) {
|
|
66
|
+
if (isValidOnState(input)) {
|
|
67
|
+
return OnState;
|
|
68
|
+
}
|
|
69
|
+
if (isValidPosition(input)) {
|
|
70
|
+
return Position;
|
|
71
|
+
}
|
|
72
|
+
if (isValidLockState(input)) {
|
|
73
|
+
return LockState;
|
|
74
|
+
}
|
|
51
75
|
}
|
|
52
76
|
export var DefaultThermostatState;
|
|
53
77
|
(function (DefaultThermostatState) {
|
package/dist/model/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../src/model/enums.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,sDAAqC,CAAA;IACrC,wCAAuB,CAAA;IACvB,gDAA+B,CAAA;IAC/B,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,kCAAiB,CAAA;IACjB,kDAAiC,CAAA;AACnC,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,yDAA2C,CAAA;IAC3C,2DAA6C,CAAA;IAC7C,6CAA+B,CAAA;IAC/B,uCAAyB,CAAA;IACzB,2CAA6B,CAAA;IAC7B,iDAAmC,CAAA;IACnC,yCAA2B,CAAA;AAC7B,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAiB;IACjD,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAN,IAAY,oBAQX;AARD,WAAY,oBAAoB;IAC9B,uEAA+C,CAAA;IAC/C,yEAAiD,CAAA;IACjD,iEAAyC,CA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;AARD,WAAY,cAAc;IACxB,2CAAyB,CAAA;IACzB,qDAAmC,CAAA;IACnC,2BAAS,CAAA;IACT,qDAAmC,CAAA;IACnC,yEAAuD,CAAA;IACvD,mDAAiC,CAAA;IACjC,yDAAuC,CAAA;AACzC,CAAC,EARW,cAAc,KAAd,cAAc,QAQzB;AAED,MAAM,UAAU,eAAe,CAAI,CAAqC;IACtE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/model/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccessoryConfig, CharacteristicValue, PlatformConfig } from 'homebridge';
|
|
2
2
|
export type ServiceType = typeof import('homebridge').Service;
|
|
3
3
|
export type CharacteristicType = typeof import('homebridge').Characteristic;
|
|
4
|
-
import {
|
|
4
|
+
import { AccessoryState, AccessoryType, ConditionOperator, DefaultThermostatState, LockState, OnState, Position, ScheduleType, SensorType, TemperatureUnits, TimePeriod, TimeUnits } from './enums.js';
|
|
5
5
|
export type LegacyAccessoryConfig = AccessoryConfig & {
|
|
6
6
|
name: string;
|
|
7
7
|
dimmer?: boolean;
|
|
@@ -43,6 +43,14 @@ export type LimiterConfig = Assertable & {
|
|
|
43
43
|
units: TimeUnits;
|
|
44
44
|
period: TimePeriod;
|
|
45
45
|
};
|
|
46
|
+
export type Operand = Assertable & {
|
|
47
|
+
accessoryId: string;
|
|
48
|
+
accessoryState: AccessoryState;
|
|
49
|
+
};
|
|
50
|
+
export type ConditionsConfig = Assertable & {
|
|
51
|
+
operator: ConditionOperator;
|
|
52
|
+
operands: Operand[];
|
|
53
|
+
};
|
|
46
54
|
export type DummyConfig = {
|
|
47
55
|
id: string;
|
|
48
56
|
name: string;
|
|
@@ -52,12 +60,14 @@ export type DummyConfig = {
|
|
|
52
60
|
timer?: TimerConfig;
|
|
53
61
|
schedule?: ScheduleConfig;
|
|
54
62
|
limiter?: LimiterConfig;
|
|
63
|
+
conditions?: ConditionsConfig;
|
|
55
64
|
resetOnRestart?: boolean;
|
|
56
65
|
enableWebook?: boolean;
|
|
57
66
|
disableLogging?: boolean;
|
|
58
67
|
};
|
|
59
68
|
export type OnOffConfig = DummyConfig & {
|
|
60
69
|
defaultOn?: CharacteristicValue;
|
|
70
|
+
defaultState?: OnState;
|
|
61
71
|
commandOn?: string;
|
|
62
72
|
commandOff?: string;
|
|
63
73
|
};
|
|
@@ -67,7 +77,7 @@ export type LightbulbConfig = OnOffConfig & {
|
|
|
67
77
|
};
|
|
68
78
|
export type SwitchConfig = OnOffConfig & {};
|
|
69
79
|
export type LockConfig = DummyConfig & {
|
|
70
|
-
defaultLockState?:
|
|
80
|
+
defaultLockState?: LockState;
|
|
71
81
|
commandLock?: string;
|
|
72
82
|
commandUnlock?: string;
|
|
73
83
|
};
|
|
@@ -80,7 +90,7 @@ export type ThermostatConfig = DummyConfig & {
|
|
|
80
90
|
commandTemperature?: string;
|
|
81
91
|
};
|
|
82
92
|
export type PositionConfig = DummyConfig & {
|
|
83
|
-
defaultPosition?:
|
|
93
|
+
defaultPosition?: Position;
|
|
84
94
|
commandOpen?: string;
|
|
85
95
|
commandClose?: string;
|
|
86
96
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Timeout } from './timeout.js';
|
|
2
|
+
import { DummyAddonDependency } from '../accessory/base.js';
|
|
2
3
|
import { LimiterConfig } from '../model/types.js';
|
|
3
|
-
import { Log } from '../tools/log.js';
|
|
4
4
|
export default class Limiter extends Timeout {
|
|
5
5
|
private readonly config;
|
|
6
|
-
static new(
|
|
6
|
+
static new(dependency: DummyAddonDependency, config?: LimiterConfig): Limiter | undefined;
|
|
7
7
|
private limit;
|
|
8
8
|
private constructor();
|
|
9
9
|
private get limitStorageKey();
|
package/dist/timeout/limiter.js
CHANGED
|
@@ -5,12 +5,12 @@ import { Storage } from '../tools/storage.js';
|
|
|
5
5
|
import { assert } from '../tools/validation.js';
|
|
6
6
|
export default class Limiter extends Timeout {
|
|
7
7
|
config;
|
|
8
|
-
static new(
|
|
9
|
-
if (!assert(log, caller, config, 'limit', 'units', 'period')) {
|
|
8
|
+
static new(dependency, config) {
|
|
9
|
+
if (config === undefined || !assert(dependency.log, dependency.caller, config, 'limit', 'units', 'period')) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
if (!isValidTimeUnits(config.units)) {
|
|
13
|
-
log.error(strings.limiter.badUnits, caller, `'${config.units}'`, printableValues(TimeUnits));
|
|
13
|
+
dependency.log.error(strings.limiter.badUnits, dependency.caller, `'${config.units}'`, printableValues(TimeUnits));
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
let periodLength;
|
|
@@ -28,19 +28,19 @@ export default class Limiter extends Timeout {
|
|
|
28
28
|
periodLength = 31 * DAY;
|
|
29
29
|
break;
|
|
30
30
|
default:
|
|
31
|
-
log.error(strings.limiter.badPeriod, caller, `'${config.period}'`, printableValues(TimePeriod));
|
|
31
|
+
dependency.log.error(strings.limiter.badPeriod, dependency.caller, `'${config.period}'`, printableValues(TimePeriod));
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
const delay = getDelay(config.limit, config.units);
|
|
35
35
|
if (delay > periodLength) {
|
|
36
|
-
log.error(strings.limiter.limitExceedsPeriod, caller);
|
|
36
|
+
dependency.log.error(strings.limiter.limitExceedsPeriod, dependency.caller);
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
return new Limiter(
|
|
39
|
+
return new Limiter(dependency, config);
|
|
40
40
|
}
|
|
41
41
|
limit = { timeRemaining: -1, resetTimestamp: -1, startTimestamp: undefined };
|
|
42
|
-
constructor(
|
|
43
|
-
super(
|
|
42
|
+
constructor(dependency, config) {
|
|
43
|
+
super(dependency);
|
|
44
44
|
this.config = config;
|
|
45
45
|
const cache = Storage.get(this.limitStorageKey);
|
|
46
46
|
if (cache === undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limiter.js","sourceRoot":"","sources":["../../src/timeout/limiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"limiter.js","sourceRoot":"","sources":["../../src/timeout/limiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5E,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG7F,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIhD,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IA2C6B;IAzCvE,MAAM,CAAC,GAAG,CAAC,UAAgC,EAAE,MAAsB;QAEjE,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC3G,OAAO;QACT,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,MAAM,CAAC,KAAK,GAAG,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;YACnH,OAAO;QACT,CAA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