hoffmation-base 3.0.0-alpha.15 → 3.0.0-alpha.16
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/command/baseCommand.d.ts +1 -0
- package/lib/models/command/baseCommand.js +9 -0
- package/lib/models/command/dimmerSetLightCommand.js +1 -1
- package/lib/models/deviceSettings/actuatorSettings.d.ts +17 -0
- package/lib/models/deviceSettings/actuatorSettings.js +23 -5
- package/lib/models/deviceSettings/ledSettings.js +10 -18
- package/lib/models/deviceSettings/wledSettings.js +5 -13
- package/lib/server/devices/groups/lightGroup.js +2 -1
- package/lib/server/devices/sharedFunctions/lampUtils.d.ts +1 -0
- package/lib/server/devices/sharedFunctions/lampUtils.js +17 -6
- package/lib/server/services/blockAutomaticHandler.d.ts +2 -1
- package/lib/server/services/blockAutomaticHandler.js +17 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -39,5 +39,14 @@ class BaseCommand {
|
|
|
39
39
|
}
|
|
40
40
|
return `CommandType("${commandSource_1.CommandSource[this.source]}") stack => ${ownPart}`;
|
|
41
41
|
}
|
|
42
|
+
containsType(type) {
|
|
43
|
+
if (this._commandType === type) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (this.source instanceof BaseCommand) {
|
|
47
|
+
return this.source.containsType(type);
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
52
|
exports.BaseCommand = BaseCommand;
|
|
@@ -26,7 +26,7 @@ class DimmerSetLightCommand extends lampSetLightCommand_1.LampSetLightCommand {
|
|
|
26
26
|
const manual = c.isForceAction;
|
|
27
27
|
switch (c.time) {
|
|
28
28
|
case timeCallback_1.TimeOfDay.Daylight:
|
|
29
|
-
return new DimmerSetLightCommand(c,
|
|
29
|
+
return new DimmerSetLightCommand(c, manual || s.dayOn, 'Daylight', c.timeout, s.dayBrightness);
|
|
30
30
|
case timeCallback_1.TimeOfDay.BeforeSunrise:
|
|
31
31
|
return new DimmerSetLightCommand(c, manual || s.dawnOn, 'Dawn', c.timeout, s.dawnBrightness, undefined);
|
|
32
32
|
case timeCallback_1.TimeOfDay.AfterSunset:
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { DeviceSettings } from './deviceSettings';
|
|
2
2
|
export declare class ActuatorSettings extends DeviceSettings {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to turn on the device at dawn in time-based commands or automatic.
|
|
5
|
+
* @type {boolean}
|
|
6
|
+
*/
|
|
3
7
|
dawnOn: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether to turn on the device at dusk in time-based commands or automatic.
|
|
10
|
+
* @type {boolean}
|
|
11
|
+
*/
|
|
4
12
|
duskOn: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to turn on the device at night in time-based commands or automatic.
|
|
15
|
+
* @type {boolean}
|
|
16
|
+
*/
|
|
5
17
|
nightOn: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to turn on the device at day in time-based commands or automatic.
|
|
20
|
+
* @type {boolean}
|
|
21
|
+
*/
|
|
22
|
+
dayOn: boolean;
|
|
6
23
|
/**
|
|
7
24
|
* Indicates if this device controls e.g. an Eltako, which has it's own Turn Off Time logic.
|
|
8
25
|
* @type {boolean}
|
|
@@ -6,9 +6,26 @@ const server_1 = require("../../server");
|
|
|
6
6
|
class ActuatorSettings extends deviceSettings_1.DeviceSettings {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
9
|
+
/**
|
|
10
|
+
* Whether to turn on the device at dawn in time-based commands or automatic.
|
|
11
|
+
* @type {boolean}
|
|
12
|
+
*/
|
|
9
13
|
this.dawnOn = true;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to turn on the device at dusk in time-based commands or automatic.
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
*/
|
|
10
18
|
this.duskOn = true;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to turn on the device at night in time-based commands or automatic.
|
|
21
|
+
* @type {boolean}
|
|
22
|
+
*/
|
|
11
23
|
this.nightOn = true;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to turn on the device at day in time-based commands or automatic.
|
|
26
|
+
* @type {boolean}
|
|
27
|
+
*/
|
|
28
|
+
this.dayOn = false;
|
|
12
29
|
/**
|
|
13
30
|
* Indicates if this device controls e.g. an Eltako, which has it's own Turn Off Time logic.
|
|
14
31
|
* @type {boolean}
|
|
@@ -33,15 +50,16 @@ class ActuatorSettings extends deviceSettings_1.DeviceSettings {
|
|
|
33
50
|
this.includeInAmbientLight = false;
|
|
34
51
|
}
|
|
35
52
|
fromPartialObject(data) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37
54
|
this.dawnOn = (_a = data.dawnOn) !== null && _a !== void 0 ? _a : this.dawnOn;
|
|
38
55
|
this.duskOn = (_b = data.duskOn) !== null && _b !== void 0 ? _b : this.duskOn;
|
|
39
56
|
this.nightOn = (_c = data.nightOn) !== null && _c !== void 0 ? _c : this.nightOn;
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
57
|
+
this.dayOn = (_d = data.dayOn) !== null && _d !== void 0 ? _d : this.dayOn;
|
|
58
|
+
this.isStromStoss = (_e = data.isStromStoss) !== null && _e !== void 0 ? _e : this.isStromStoss;
|
|
59
|
+
this.stromStossResendTime = (_f = data.stromStossResendTime) !== null && _f !== void 0 ? _f : this.stromStossResendTime;
|
|
42
60
|
this.resetToAutomaticOnForceOffAfterForceOn =
|
|
43
|
-
(
|
|
44
|
-
this.includeInAmbientLight = (
|
|
61
|
+
(_g = data.resetToAutomaticOnForceOffAfterForceOn) !== null && _g !== void 0 ? _g : this.resetToAutomaticOnForceOffAfterForceOn;
|
|
62
|
+
this.includeInAmbientLight = (_h = data.includeInAmbientLight) !== null && _h !== void 0 ? _h : this.includeInAmbientLight;
|
|
45
63
|
super.fromPartialObject(data);
|
|
46
64
|
}
|
|
47
65
|
toJSON() {
|
|
@@ -25,24 +25,16 @@ 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
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
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;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
29
|
+
this.dayColorTemp = (_a = data.dayColorTemp) !== null && _a !== void 0 ? _a : this.dayColorTemp;
|
|
30
|
+
this.dawnColorTemp = (_b = data.dawnColorTemp) !== null && _b !== void 0 ? _b : this.dawnColorTemp;
|
|
31
|
+
this.duskColorTemp = (_c = data.duskColorTemp) !== null && _c !== void 0 ? _c : this.duskColorTemp;
|
|
32
|
+
this.nightColorTemp = (_d = data.nightColorTemp) !== null && _d !== void 0 ? _d : this.nightColorTemp;
|
|
33
|
+
this.defaultColor = (_f = server_1.Utils.formatHex((_e = data.defaultColor) !== null && _e !== void 0 ? _e : this.defaultColor)) !== null && _f !== void 0 ? _f : LedSettings.fallbackColor;
|
|
34
|
+
this.dayColor = (_h = server_1.Utils.formatHex((_g = data.dayColor) !== null && _g !== void 0 ? _g : this.dayColor)) !== null && _h !== void 0 ? _h : LedSettings.fallbackColor;
|
|
35
|
+
this.dawnColor = (_k = server_1.Utils.formatHex((_j = data.dawnColor) !== null && _j !== void 0 ? _j : this.dawnColor)) !== null && _k !== void 0 ? _k : LedSettings.fallbackColor;
|
|
36
|
+
this.duskColor = (_m = server_1.Utils.formatHex((_l = data.duskColor) !== null && _l !== void 0 ? _l : this.duskColor)) !== null && _m !== void 0 ? _m : LedSettings.fallbackColor;
|
|
37
|
+
this.nightColor = (_p = server_1.Utils.formatHex((_o = data.nightColor) !== null && _o !== void 0 ? _o : this.nightColor)) !== null && _p !== void 0 ? _p : LedSettings.fallbackColor;
|
|
46
38
|
super.fromPartialObject(data);
|
|
47
39
|
}
|
|
48
40
|
toJSON() {
|
|
@@ -16,19 +16,11 @@ class WledSettings extends dimmerSettings_1.DimmerSettings {
|
|
|
16
16
|
this.nightBrightness = 2;
|
|
17
17
|
}
|
|
18
18
|
fromPartialObject(data) {
|
|
19
|
-
var _a, _b, _c, _d
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.duskOn = (_e = data.duskOn) !== null && _e !== void 0 ? _e : this.duskOn;
|
|
25
|
-
this.duskBrightness = (_f = data.duskBrightness) !== null && _f !== void 0 ? _f : this.duskBrightness;
|
|
26
|
-
this.nightOn = (_g = data.nightOn) !== null && _g !== void 0 ? _g : this.nightOn;
|
|
27
|
-
this.nightBrightness = (_h = data.nightBrightness) !== null && _h !== void 0 ? _h : this.nightBrightness;
|
|
28
|
-
this.dawnPreset = (_j = data.dawnPreset) !== null && _j !== void 0 ? _j : this.dawnPreset;
|
|
29
|
-
this.dayPreset = (_k = data.dayPreset) !== null && _k !== void 0 ? _k : this.dayPreset;
|
|
30
|
-
this.duskPreset = (_l = data.duskPreset) !== null && _l !== void 0 ? _l : this.duskPreset;
|
|
31
|
-
this.nightPreset = (_m = data.nightPreset) !== null && _m !== void 0 ? _m : this.nightPreset;
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
this.dawnPreset = (_a = data.dawnPreset) !== null && _a !== void 0 ? _a : this.dawnPreset;
|
|
21
|
+
this.dayPreset = (_b = data.dayPreset) !== null && _b !== void 0 ? _b : this.dayPreset;
|
|
22
|
+
this.duskPreset = (_c = data.duskPreset) !== null && _c !== void 0 ? _c : this.duskPreset;
|
|
23
|
+
this.nightPreset = (_d = data.nightPreset) !== null && _d !== void 0 ? _d : this.nightPreset;
|
|
32
24
|
super.fromPartialObject(data);
|
|
33
25
|
}
|
|
34
26
|
toJSON() {
|
|
@@ -135,7 +135,8 @@ class LightGroup extends base_group_1.BaseGroup {
|
|
|
135
135
|
}
|
|
136
136
|
setAllActuatorsTimeBased(c) {
|
|
137
137
|
this.getOutlets().forEach((s) => {
|
|
138
|
-
if ((c.time === models_1.TimeOfDay.
|
|
138
|
+
if ((c.time === models_1.TimeOfDay.Daylight && s.settings.dayOn) ||
|
|
139
|
+
(c.time === models_1.TimeOfDay.Night && s.settings.nightOn) ||
|
|
139
140
|
(c.time === models_1.TimeOfDay.BeforeSunrise && s.settings.dawnOn) ||
|
|
140
141
|
(c.time === models_1.TimeOfDay.AfterSunset && s.settings.duskOn)) {
|
|
141
142
|
s.setActuator(new models_1.ActuatorSetStateCommand(c, true, `LightGroup setAllActuatorsTimeBased`, c.timeout));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { iActuator, iLamp } from '../baseDeviceInterfaces';
|
|
2
2
|
import { ActuatorSetStateCommand, LampSetTimeBasedCommand, LampToggleLightCommand } from '../../../models';
|
|
3
3
|
export declare class LampUtils {
|
|
4
|
+
private static stromStossContinueTimeouts;
|
|
4
5
|
static stromStossOn(actuator: iActuator): void;
|
|
5
6
|
static setTimeBased(device: iLamp, c: LampSetTimeBasedCommand): void;
|
|
6
7
|
static checkUnBlock(device: iActuator, command: ActuatorSetStateCommand): boolean;
|
|
@@ -5,18 +5,22 @@ const services_1 = require("../../services");
|
|
|
5
5
|
const models_1 = require("../../../models");
|
|
6
6
|
class LampUtils {
|
|
7
7
|
static stromStossOn(actuator) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
if (!LampUtils.stromStossContinueTimeouts.has(actuator.id)) {
|
|
9
|
+
LampUtils.stromStossContinueTimeouts.set(actuator.id, services_1.Utils.guardedTimeout(() => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
LampUtils.stromStossContinueTimeouts.delete(actuator.id);
|
|
12
|
+
if ((_b = (_a = actuator.room) === null || _a === void 0 ? void 0 : _a.PraesenzGroup) === null || _b === void 0 ? void 0 : _b.anyPresent()) {
|
|
13
|
+
actuator.setActuator(new models_1.ActuatorSetStateCommand(models_1.CommandSource.Automatic, true, 'StromStoss On due to Presence'));
|
|
14
|
+
}
|
|
15
|
+
}, actuator.settings.stromStossResendTime * 1000, this));
|
|
16
|
+
}
|
|
14
17
|
services_1.Utils.guardedTimeout(() => {
|
|
15
18
|
actuator.setActuator(new models_1.ActuatorSetStateCommand(models_1.CommandSource.Force, false, 'StromStoss Off'));
|
|
16
19
|
}, 3000, this);
|
|
17
20
|
}
|
|
18
21
|
static setTimeBased(device, c) {
|
|
19
22
|
if (c.isManual ||
|
|
23
|
+
(c.time === models_1.TimeOfDay.Daylight && device.settings.dayOn) ||
|
|
20
24
|
(c.time === models_1.TimeOfDay.Night && device.settings.nightOn) ||
|
|
21
25
|
(c.time === models_1.TimeOfDay.BeforeSunrise && device.settings.dawnOn) ||
|
|
22
26
|
(c.time === models_1.TimeOfDay.AfterSunset && device.settings.duskOn)) {
|
|
@@ -65,6 +69,12 @@ class LampUtils {
|
|
|
65
69
|
return false;
|
|
66
70
|
}
|
|
67
71
|
static setActuator(device, c) {
|
|
72
|
+
if (device.settings.isStromStoss &&
|
|
73
|
+
c.on &&
|
|
74
|
+
c.containsType(models_1.CommandType.ActuatorRestoreTargetAutomaticValueCommand)) {
|
|
75
|
+
// Don't restore automatic state on Strommstoss-Relais as this might result in a loop.
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
68
78
|
const dontBlock = LampUtils.checkUnBlock(device, c);
|
|
69
79
|
if (LampUtils.checkBlockActive(device, c)) {
|
|
70
80
|
return;
|
|
@@ -88,3 +98,4 @@ class LampUtils {
|
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
exports.LampUtils = LampUtils;
|
|
101
|
+
LampUtils.stromStossContinueTimeouts = new Map();
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { CollisionSolving, RestoreTargetAutomaticValueCommand } from '../../models';
|
|
3
3
|
export declare class BlockAutomaticHandler {
|
|
4
4
|
private readonly _restoreAutomatic;
|
|
5
|
+
private _delayedLiftTimeout;
|
|
5
6
|
constructor(restoreAutomaticCb: (c: RestoreTargetAutomaticValueCommand) => void);
|
|
6
7
|
private _automaticBlockedUntil;
|
|
7
8
|
get automaticBlockedUntil(): Date;
|
|
@@ -11,7 +12,7 @@ export declare class BlockAutomaticHandler {
|
|
|
11
12
|
get automaticBlockActive(): boolean;
|
|
12
13
|
disableAutomatic(durationMS: number, onCollideAction?: CollisionSolving): void;
|
|
13
14
|
disableAutomaticUntil(targetDate: Date, onCollideAction?: CollisionSolving): void;
|
|
14
|
-
liftAutomaticBlock(): void;
|
|
15
|
+
liftAutomaticBlock(delay?: number): void;
|
|
15
16
|
private updateRestoreTimeout;
|
|
16
17
|
toJSON(): Partial<BlockAutomaticHandler>;
|
|
17
18
|
}
|
|
@@ -9,6 +9,7 @@ const utils_1 = require("./utils");
|
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
10
|
class BlockAutomaticHandler {
|
|
11
11
|
constructor(restoreAutomaticCb) {
|
|
12
|
+
this._delayedLiftTimeout = null;
|
|
12
13
|
this._automaticBlockedUntil = new Date(0);
|
|
13
14
|
this._restoreAutomaticStateTimeout = null;
|
|
14
15
|
this._restoreAutomatic = restoreAutomaticCb;
|
|
@@ -38,8 +39,22 @@ class BlockAutomaticHandler {
|
|
|
38
39
|
}
|
|
39
40
|
this.automaticBlockedUntil = targetDate;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
// TODO: Missing conversion to command
|
|
43
|
+
liftAutomaticBlock(delay = 0) {
|
|
44
|
+
if (delay <= 0) {
|
|
45
|
+
this.automaticBlockedUntil = new Date(0);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (this._delayedLiftTimeout !== null) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const currentBlockedUntil = this._automaticBlockedUntil;
|
|
52
|
+
this._delayedLiftTimeout = utils_1.Utils.guardedTimeout(() => {
|
|
53
|
+
this._delayedLiftTimeout = null;
|
|
54
|
+
if (this.automaticBlockActive && this._automaticBlockedUntil.getTime() === currentBlockedUntil.getTime()) {
|
|
55
|
+
this.liftAutomaticBlock(0);
|
|
56
|
+
}
|
|
57
|
+
}, delay, this);
|
|
43
58
|
}
|
|
44
59
|
updateRestoreTimeout() {
|
|
45
60
|
if (this._restoreAutomaticStateTimeout !== null) {
|