hoffmation-base 3.0.0-alpha.14 → 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.
@@ -11,4 +11,5 @@ export declare abstract class BaseCommand {
11
11
  get isManual(): boolean;
12
12
  get isInitial(): boolean;
13
13
  get reasonTrace(): string;
14
+ containsType(type: CommandType): boolean;
14
15
  }
@@ -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, true, 'Daylight', c.timeout, s.dayBrightness);
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.isStromStoss = (_d = data.isStromStoss) !== null && _d !== void 0 ? _d : this.isStromStoss;
41
- this.stromStossResendTime = (_e = data.stromStossResendTime) !== null && _e !== void 0 ? _e : this.stromStossResendTime;
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
- (_f = data.resetToAutomaticOnForceOffAfterForceOn) !== null && _f !== void 0 ? _f : this.resetToAutomaticOnForceOffAfterForceOn;
44
- this.includeInAmbientLight = (_g = data.includeInAmbientLight) !== null && _g !== void 0 ? _g : 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, _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;
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, _e, _f, _g, _h, _j, _k, _l, _m;
20
- this.dayOn = (_a = data.dayOn) !== null && _a !== void 0 ? _a : this.dayOn;
21
- this.dayBrightness = (_b = data.dayBrightness) !== null && _b !== void 0 ? _b : this.dayBrightness;
22
- this.dawnOn = (_c = data.dawnOn) !== null && _c !== void 0 ? _c : this.dawnOn;
23
- this.dawnBrightness = (_d = data.dawnBrightness) !== null && _d !== void 0 ? _d : this.dawnBrightness;
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.Night && s.settings.nightOn) ||
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
- services_1.Utils.guardedTimeout(() => {
9
- var _a, _b;
10
- if ((_b = (_a = actuator.room) === null || _a === void 0 ? void 0 : _a.PraesenzGroup) === null || _b === void 0 ? void 0 : _b.anyPresent()) {
11
- actuator.setActuator(new models_1.ActuatorSetStateCommand(models_1.CommandSource.Force, true, 'StromStoss On due to Presence'));
12
- }
13
- }, actuator.settings.stromStossResendTime * 1000, this);
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();
@@ -7,6 +7,7 @@ const services_1 = require("../services");
7
7
  const models_1 = require("../../models");
8
8
  const blockAutomaticHandler_1 = require("../services/blockAutomaticHandler");
9
9
  const sharedFunctions_1 = require("./sharedFunctions");
10
+ const DeviceCapability_1 = require("./DeviceCapability");
10
11
  class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
11
12
  constructor(pInfo) {
12
13
  super(pInfo, deviceType_1.DeviceType.WledDevice);
@@ -20,6 +21,8 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
20
21
  this._presetID = `${this.info.fullID}.ps`;
21
22
  this._brightnessID = `${this.info.fullID}.bri`;
22
23
  this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
24
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.lamp);
25
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.dimmablelamp);
23
26
  }
24
27
  get actuatorOn() {
25
28
  return this.on;
@@ -116,7 +116,7 @@ class AcDevice {
116
116
  }
117
117
  if (this.settings.useOwnTemperatureAndAutomatic) {
118
118
  // Device is in automatic mode so ignore energy and room temperature
119
- if ((heatGroup === null || heatGroup === void 0 ? void 0 : heatGroup.settings.automaticMode) === false) {
119
+ if (heatGroup === null || heatGroup === void 0 ? void 0 : heatGroup.settings.automaticMode) {
120
120
  return ac_mode_1.AcMode.Auto;
121
121
  }
122
122
  if (settings_service_1.SettingsService.heatMode !== config_1.HeatingMode.Sommer && this.settings.heatingAllowed) {
@@ -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
- liftAutomaticBlock() {
42
- this.automaticBlockedUntil = new Date(0);
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) {