hoffmation-base 2.20.3 → 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.
- package/lib/models/deviceSettings/ledSettings.d.ts +1 -0
- package/lib/models/deviceSettings/ledSettings.js +20 -19
- package/lib/server/devices/IoBrokerBaseDevice.js +1 -1
- package/lib/server/devices/blueIris/cameraDevice.js +4 -0
- package/lib/server/devices/groups/presenceGroup.d.ts +5 -2
- package/lib/server/devices/groups/presenceGroup.js +35 -26
- package/lib/server/devices/zigbee/BaseDevices/zigbeeLedRGBCCT.js +3 -1
- package/lib/server/services/govee/own-govee-device.js +3 -2
- package/lib/server/services/utils/utils.d.ts +1 -0
- package/lib/server/services/utils/utils.js +9 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ const server_1 = require("../../server");
|
|
|
6
6
|
class LedSettings extends dimmerSettings_1.DimmerSettings {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
9
|
-
this.defaultColor =
|
|
9
|
+
this.defaultColor = LedSettings.fallbackColor;
|
|
10
10
|
this.dayOn = false;
|
|
11
11
|
this.dayBrightness = 100;
|
|
12
12
|
this.dayColor = this.defaultColor;
|
|
@@ -25,24 +25,24 @@ class LedSettings extends dimmerSettings_1.DimmerSettings {
|
|
|
25
25
|
this.nightColorTemp = -1;
|
|
26
26
|
}
|
|
27
27
|
fromPartialObject(data) {
|
|
28
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
29
|
+
this.dayOn = (_a = data.dayOn) !== null && _a !== void 0 ? _a : this.dayOn;
|
|
30
|
+
this.dayBrightness = (_b = data.dayBrightness) !== null && _b !== void 0 ? _b : this.dayBrightness;
|
|
31
|
+
this.dayColorTemp = (_c = data.dayColorTemp) !== null && _c !== void 0 ? _c : this.dayColorTemp;
|
|
32
|
+
this.dawnOn = (_d = data.dawnOn) !== null && _d !== void 0 ? _d : this.dawnOn;
|
|
33
|
+
this.dawnBrightness = (_e = data.dawnBrightness) !== null && _e !== void 0 ? _e : this.dawnBrightness;
|
|
34
|
+
this.dawnColorTemp = (_f = data.dawnColorTemp) !== null && _f !== void 0 ? _f : this.dawnColorTemp;
|
|
35
|
+
this.duskOn = (_g = data.duskOn) !== null && _g !== void 0 ? _g : this.duskOn;
|
|
36
|
+
this.duskBrightness = (_h = data.duskBrightness) !== null && _h !== void 0 ? _h : this.duskBrightness;
|
|
37
|
+
this.duskColorTemp = (_j = data.duskColorTemp) !== null && _j !== void 0 ? _j : this.duskColorTemp;
|
|
38
|
+
this.nightOn = (_k = data.nightOn) !== null && _k !== void 0 ? _k : this.nightOn;
|
|
39
|
+
this.nightBrightness = (_l = data.nightBrightness) !== null && _l !== void 0 ? _l : this.nightBrightness;
|
|
40
|
+
this.nightColorTemp = (_m = data.nightColorTemp) !== null && _m !== void 0 ? _m : this.nightColorTemp;
|
|
41
|
+
this.defaultColor = (_p = server_1.Utils.formatHex((_o = data.defaultColor) !== null && _o !== void 0 ? _o : this.defaultColor)) !== null && _p !== void 0 ? _p : LedSettings.fallbackColor;
|
|
42
|
+
this.dayColor = (_r = server_1.Utils.formatHex((_q = data.dayColor) !== null && _q !== void 0 ? _q : this.dayColor)) !== null && _r !== void 0 ? _r : LedSettings.fallbackColor;
|
|
43
|
+
this.dawnColor = (_t = server_1.Utils.formatHex((_s = data.dawnColor) !== null && _s !== void 0 ? _s : this.dawnColor)) !== null && _t !== void 0 ? _t : LedSettings.fallbackColor;
|
|
44
|
+
this.duskColor = (_v = server_1.Utils.formatHex((_u = data.duskColor) !== null && _u !== void 0 ? _u : this.duskColor)) !== null && _v !== void 0 ? _v : LedSettings.fallbackColor;
|
|
45
|
+
this.nightColor = (_x = server_1.Utils.formatHex((_w = data.nightColor) !== null && _w !== void 0 ? _w : this.nightColor)) !== null && _x !== void 0 ? _x : LedSettings.fallbackColor;
|
|
46
46
|
super.fromPartialObject(data);
|
|
47
47
|
}
|
|
48
48
|
toJSON() {
|
|
@@ -50,3 +50,4 @@ class LedSettings extends dimmerSettings_1.DimmerSettings {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
exports.LedSettings = LedSettings;
|
|
53
|
+
LedSettings.fallbackColor = '#fbbc32';
|
|
@@ -23,7 +23,7 @@ class IoBrokerBaseDevice {
|
|
|
23
23
|
this.individualStateCallbacks = new Map();
|
|
24
24
|
this.addToCorrectRoom();
|
|
25
25
|
this.persistDeviceInfo();
|
|
26
|
-
services_1.Utils.guardedTimeout(this.loadDeviceSettings,
|
|
26
|
+
services_1.Utils.guardedTimeout(this.loadDeviceSettings, 300, this);
|
|
27
27
|
}
|
|
28
28
|
get id() {
|
|
29
29
|
const result = services_1.Utils.guard(this.info.allDevicesKey);
|
|
@@ -282,6 +282,10 @@ class CameraDevice {
|
|
|
282
282
|
this._movementDetectFallbackTimeout = services_1.Utils.guardedTimeout(() => {
|
|
283
283
|
var _a;
|
|
284
284
|
this._movementDetectFallbackTimeout = null;
|
|
285
|
+
if (!this._movementDetected) {
|
|
286
|
+
// Der Fallback wird nicht benötigt, da bereits das Movement zurückgesetzt wurde
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
285
289
|
this._movementDetected = false;
|
|
286
290
|
this.updateMovement(false);
|
|
287
291
|
if (this._movementDetectedStateId !== undefined) {
|
|
@@ -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,37 +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;
|
|
100
|
+
const presentAmount = this.presentAmount();
|
|
84
101
|
this.log(models_1.LogLevel.Debug, `Delayed Movement reset. Active Motions: ${this.presentAmount()}\tTime after Last Movement including Reset: ${timeAfterReset}`);
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
cb();
|
|
102
|
+
if (presentAmount <= 0 && timeAfterReset > 0) {
|
|
103
|
+
this.executeLastLeftCbs();
|
|
88
104
|
}
|
|
89
105
|
}, Math.abs(timeAfterReset) + 500, this);
|
|
90
106
|
}
|
|
91
|
-
addLastLeftCallback(cb) {
|
|
92
|
-
this.getMotionDetector().forEach((b) => {
|
|
93
|
-
b.addMovementCallback((val) => {
|
|
94
|
-
this.lastLeftCB(val, cb);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
addFirstEnterCallback(cb) {
|
|
99
|
-
this.getMotionDetector().forEach((b) => {
|
|
100
|
-
b.addMovementCallback((val) => {
|
|
101
|
-
this.firstEnterCallback(val, cb);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
107
|
/**
|
|
106
108
|
* In case of an existing delayed last left callback timeout, this removes it.
|
|
107
109
|
* @private
|
|
@@ -111,7 +113,7 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
111
113
|
clearTimeout(this._lastLeftTimeout);
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
|
-
|
|
116
|
+
motionSensorOnFirstEnter(val) {
|
|
115
117
|
if (!val) {
|
|
116
118
|
return;
|
|
117
119
|
}
|
|
@@ -119,7 +121,14 @@ class PresenceGroup extends base_group_1.BaseGroup {
|
|
|
119
121
|
if (this.presentAmount() > 1) {
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
122
|
-
cb
|
|
124
|
+
for (const cb of this._firstEnterCbs) {
|
|
125
|
+
cb();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
executeLastLeftCbs() {
|
|
129
|
+
for (const cb of this._lastLeftCbs) {
|
|
130
|
+
cb();
|
|
131
|
+
}
|
|
123
132
|
}
|
|
124
133
|
}
|
|
125
134
|
exports.PresenceGroup = PresenceGroup;
|
|
@@ -4,6 +4,7 @@ exports.ZigbeeLedRGBCCT = void 0;
|
|
|
4
4
|
const models_1 = require("../../../../models");
|
|
5
5
|
const DeviceCapability_1 = require("../../DeviceCapability");
|
|
6
6
|
const zigbeeDimmer_1 = require("./zigbeeDimmer");
|
|
7
|
+
const services_1 = require("../../../services");
|
|
7
8
|
class ZigbeeLedRGBCCT extends zigbeeDimmer_1.ZigbeeDimmer {
|
|
8
9
|
constructor(pInfo, deviceType) {
|
|
9
10
|
super(pInfo, deviceType);
|
|
@@ -77,7 +78,8 @@ class ZigbeeLedRGBCCT extends zigbeeDimmer_1.ZigbeeDimmer {
|
|
|
77
78
|
brightness = 10;
|
|
78
79
|
}
|
|
79
80
|
this.log(models_1.LogLevel.Debug, `LED Schalten An: ${pValue}\tHelligkeit: ${brightness}%\tFarbe: "${color}"\tColorTemperatur: ${colorTemp}`);
|
|
80
|
-
|
|
81
|
+
const formattedColor = services_1.Utils.formatHex(color);
|
|
82
|
+
if (formattedColor !== null) {
|
|
81
83
|
this.ioConn.setState(this._stateIdColor, color, (err) => {
|
|
82
84
|
if (err) {
|
|
83
85
|
this.log(models_1.LogLevel.Error, `LED Farbe schalten ergab Fehler: ${err}`);
|
|
@@ -39,7 +39,7 @@ class OwnGoveeDevice {
|
|
|
39
39
|
devices_1.Devices.alLDevices[`govee-${roomName}-${deviceId}`] = this;
|
|
40
40
|
this.persistDeviceInfo();
|
|
41
41
|
this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
|
|
42
|
-
this.loadDeviceSettings
|
|
42
|
+
utils_1.Utils.guardedTimeout(this.loadDeviceSettings, 300, this);
|
|
43
43
|
}
|
|
44
44
|
get color() {
|
|
45
45
|
return this._color;
|
|
@@ -131,7 +131,8 @@ class OwnGoveeDevice {
|
|
|
131
131
|
brightness = 10;
|
|
132
132
|
}
|
|
133
133
|
this.log(models_1.LogLevel.Debug, `LED Schalten An: ${pValue}\tHelligkeit: ${brightness}%\tFarbe: "${color}"\tColorTemperatur: ${colorTemp}`);
|
|
134
|
-
|
|
134
|
+
const formattedColor = utils_1.Utils.formatHex(color);
|
|
135
|
+
if (formattedColor !== null) {
|
|
135
136
|
this.setColor(color);
|
|
136
137
|
}
|
|
137
138
|
let dontBlock = false;
|
|
@@ -33,4 +33,5 @@ export declare class Utils {
|
|
|
33
33
|
private static deepOmit;
|
|
34
34
|
static nextMatchingDate(hours?: number, minutes?: number, now?: Date): Date;
|
|
35
35
|
static timeWithinBorders(minimumHours: number, minimumMinutes: number, maxHours: number, maxMinutes: number, now?: Date): boolean;
|
|
36
|
+
static formatHex(hex: string): string | null;
|
|
36
37
|
}
|
|
@@ -234,5 +234,14 @@ class Utils {
|
|
|
234
234
|
}
|
|
235
235
|
return true;
|
|
236
236
|
}
|
|
237
|
+
static formatHex(hex) {
|
|
238
|
+
if (hex === undefined || hex === null || hex === '') {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (!hex.startsWith('#')) {
|
|
242
|
+
return `#${hex}`;
|
|
243
|
+
}
|
|
244
|
+
return hex;
|
|
245
|
+
}
|
|
237
246
|
}
|
|
238
247
|
exports.Utils = Utils;
|