hoffmation-base 2.20.4 → 2.20.5
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.
|
@@ -3,18 +3,21 @@ import { iMotionSensor } from '../baseDeviceInterfaces';
|
|
|
3
3
|
export declare class PresenceGroup extends BaseGroup {
|
|
4
4
|
private _lastMovement;
|
|
5
5
|
private _lastLeftTimeout;
|
|
6
|
+
private _lastLeftCbs;
|
|
7
|
+
private _firstEnterCbs;
|
|
6
8
|
constructor(roomName: string, motionSensorIds: string[]);
|
|
7
9
|
getMotionDetector(): Array<iMotionSensor>;
|
|
8
10
|
initCallbacks(): void;
|
|
9
11
|
presentAmount(): number;
|
|
10
12
|
anyPresent(): boolean;
|
|
11
|
-
lastLeftCB(val: boolean, cb: () => void): void;
|
|
12
13
|
addLastLeftCallback(cb: () => void): void;
|
|
13
14
|
addFirstEnterCallback(cb: () => void): void;
|
|
15
|
+
private motionSensorOnLastLeft;
|
|
14
16
|
/**
|
|
15
17
|
* In case of an existing delayed last left callback timeout, this removes it.
|
|
16
18
|
* @private
|
|
17
19
|
*/
|
|
18
20
|
private resetLastLeftTimeout;
|
|
19
|
-
private
|
|
21
|
+
private motionSensorOnFirstEnter;
|
|
22
|
+
private executeLastLeftCbs;
|
|
20
23
|
}
|
|
@@ -12,6 +12,8 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
12
12
|
super(roomName, group_type_1.GroupType.Presence);
|
|
13
13
|
this._lastMovement = new Date(0);
|
|
14
14
|
this._lastLeftTimeout = null;
|
|
15
|
+
this._lastLeftCbs = [];
|
|
16
|
+
this._firstEnterCbs = [];
|
|
15
17
|
this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.MotionDetection, new device_list_1.DeviceList(motionSensorIds));
|
|
16
18
|
}
|
|
17
19
|
getMotionDetector() {
|
|
@@ -34,8 +36,9 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
34
36
|
});
|
|
35
37
|
});
|
|
36
38
|
this.addLastLeftCallback(() => {
|
|
37
|
-
var _a;
|
|
38
|
-
(_a = this.getRoom().
|
|
39
|
+
var _a, _b;
|
|
40
|
+
(_a = this.getRoom().WindowGroup) === null || _a === void 0 ? void 0 : _a.changeVibrationMotionBlock(false);
|
|
41
|
+
(_b = this.getRoom().LightGroup) === null || _b === void 0 ? void 0 : _b.switchAll(false);
|
|
39
42
|
});
|
|
40
43
|
this.addFirstEnterCallback(() => {
|
|
41
44
|
if (!this.getRoom().settings.lampenBeiBewegung) {
|
|
@@ -44,6 +47,16 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
44
47
|
this.log(models_1.LogLevel.DeepTrace, `Bewegung im Raum ${this.roomName} festgestellt --> Licht einschalten`);
|
|
45
48
|
this.getRoom().setLightTimeBased();
|
|
46
49
|
});
|
|
50
|
+
this.getMotionDetector().forEach((b) => {
|
|
51
|
+
b.addMovementCallback((val) => {
|
|
52
|
+
this.motionSensorOnFirstEnter(val);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
this.getMotionDetector().forEach((b) => {
|
|
56
|
+
b.addMovementCallback((val) => {
|
|
57
|
+
this.motionSensorOnLastLeft(val);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
47
60
|
}
|
|
48
61
|
presentAmount() {
|
|
49
62
|
let count = 0;
|
|
@@ -62,8 +75,13 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
62
75
|
}
|
|
63
76
|
return false;
|
|
64
77
|
}
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
addLastLeftCallback(cb) {
|
|
79
|
+
this._lastLeftCbs.push(cb);
|
|
80
|
+
}
|
|
81
|
+
addFirstEnterCallback(cb) {
|
|
82
|
+
this._firstEnterCbs.push(cb);
|
|
83
|
+
}
|
|
84
|
+
motionSensorOnLastLeft(val) {
|
|
67
85
|
if (val || this.anyPresent()) {
|
|
68
86
|
this.resetLastLeftTimeout();
|
|
69
87
|
return;
|
|
@@ -71,38 +89,21 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
71
89
|
let timeAfterReset = services_1.Utils.nowMS() - this._lastMovement.getTime() - this.getRoom().settings.movementResetTimer * 1000;
|
|
72
90
|
if (timeAfterReset > 0) {
|
|
73
91
|
this.log(models_1.LogLevel.Debug, `Movement reset. Active Motions: ${this.presentAmount()}\tTime after Last Movement including Reset: ${timeAfterReset}`);
|
|
74
|
-
|
|
75
|
-
cb();
|
|
92
|
+
this.executeLastLeftCbs();
|
|
76
93
|
return;
|
|
77
94
|
}
|
|
78
95
|
this.log(models_1.LogLevel.Debug, `Movement reset in ${this.roomName} delayed.`);
|
|
79
96
|
this.resetLastLeftTimeout();
|
|
80
97
|
this._lastLeftTimeout = services_1.Utils.guardedTimeout(() => {
|
|
81
|
-
var _a;
|
|
82
98
|
timeAfterReset =
|
|
83
99
|
services_1.Utils.nowMS() - this._lastMovement.getTime() - this.getRoom().settings.movementResetTimer * 1000;
|
|
84
100
|
const presentAmount = this.presentAmount();
|
|
85
101
|
this.log(models_1.LogLevel.Debug, `Delayed Movement reset. Active Motions: ${this.presentAmount()}\tTime after Last Movement including Reset: ${timeAfterReset}`);
|
|
86
102
|
if (presentAmount <= 0 && timeAfterReset > 0) {
|
|
87
|
-
|
|
88
|
-
cb();
|
|
103
|
+
this.executeLastLeftCbs();
|
|
89
104
|
}
|
|
90
105
|
}, Math.abs(timeAfterReset) + 500, this);
|
|
91
106
|
}
|
|
92
|
-
addLastLeftCallback(cb) {
|
|
93
|
-
this.getMotionDetector().forEach((b) => {
|
|
94
|
-
b.addMovementCallback((val) => {
|
|
95
|
-
this.lastLeftCB(val, cb);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
addFirstEnterCallback(cb) {
|
|
100
|
-
this.getMotionDetector().forEach((b) => {
|
|
101
|
-
b.addMovementCallback((val) => {
|
|
102
|
-
this.firstEnterCallback(val, cb);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
107
|
/**
|
|
107
108
|
* In case of an existing delayed last left callback timeout, this removes it.
|
|
108
109
|
* @private
|
|
@@ -112,7 +113,7 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
112
113
|
clearTimeout(this._lastLeftTimeout);
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
motionSensorOnFirstEnter(val) {
|
|
116
117
|
if (!val) {
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
@@ -120,7 +121,14 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
120
121
|
if (this.presentAmount() > 1) {
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
cb
|
|
124
|
+
for (const cb of this._firstEnterCbs) {
|
|
125
|
+
cb();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
executeLastLeftCbs() {
|
|
129
|
+
for (const cb of this._lastLeftCbs) {
|
|
130
|
+
cb();
|
|
131
|
+
}
|
|
124
132
|
}
|
|
125
133
|
}
|
|
126
134
|
exports.PresenceGroup = PresenceGroup;
|