hoffmation-base 3.0.0-alpha.37 → 3.0.0-alpha.38

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.
@@ -23,4 +23,5 @@ export declare class BlockAutomaticUntilCommand extends BaseCommand {
23
23
  * @param revertToAutomaticAtBlockLift - Whether the device should revert to automatic afterward. --> Default: {@link SettingsService.settings.blockAutomaticHandlerDefaults.revertToAutomaticAtBlockLift}
24
24
  */
25
25
  constructor(source: CommandSource | BaseCommand, targetDate: Date, reason?: string, onCollideAction?: CollisionSolving, revertToAutomaticAtBlockLift?: boolean);
26
+ get logMessage(): string;
26
27
  }
@@ -25,5 +25,8 @@ class BlockAutomaticUntilCommand extends baseCommand_1.BaseCommand {
25
25
  this.revertToAutomaticAtBlockLift =
26
26
  (_f = revertToAutomaticAtBlockLift !== null && revertToAutomaticAtBlockLift !== void 0 ? revertToAutomaticAtBlockLift : (_e = (_d = server_1.SettingsService.settings) === null || _d === void 0 ? void 0 : _d.blockAutomaticHandlerDefaults) === null || _e === void 0 ? void 0 : _e.revertToAutomaticAtBlockLift) !== null && _f !== void 0 ? _f : true;
27
27
  }
28
+ get logMessage() {
29
+ return `Block automatic until ${this.targetDate.toISOString()}, reason: ${this.reasonTrace}`;
30
+ }
28
31
  }
29
32
  exports.BlockAutomaticUntilCommand = BlockAutomaticUntilCommand;
@@ -57,7 +57,7 @@ class Dachs {
57
57
  this.warmWaterSensor = new dachsTemperatureSensor_1.DachsTemperatureSensor(this.config.roomName, 'ww', 'Water Temperature');
58
58
  this.heatStorageTempSensor = new dachsTemperatureSensor_1.DachsTemperatureSensor(this.config.roomName, 'hs', 'Heat Storage Temperature');
59
59
  services_1.Utils.guardedInterval(this.loadData, this.config.refreshInterval, this);
60
- this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
60
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
61
61
  }
62
62
  /** @inheritDoc */
63
63
  get info() {
@@ -23,7 +23,7 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
23
23
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.lamp);
24
24
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
25
25
  this.lightOnSwitchID = `${this.info.fullID}.2.STATE`;
26
- this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
26
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
27
27
  }
28
28
  get actuatorOn() {
29
29
  return this._actuatorOn;
@@ -29,6 +29,10 @@ class LampUtils {
29
29
  }
30
30
  static checkUnBlock(device, command) {
31
31
  let dontBlock = false;
32
+ if (command.containsType(models_1.CommandType.ActuatorRestoreTargetAutomaticValueCommand)) {
33
+ // We are restoring the automatic value, so we don't want to block the device
34
+ return true;
35
+ }
32
36
  if (command.isForceAction &&
33
37
  device.settings.resetToAutomaticOnForceOffAfterForceOn &&
34
38
  !command.on &&
@@ -24,7 +24,7 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
24
24
  this._onID = `${this.info.fullID}.on`;
25
25
  this._presetID = `${this.info.fullID}.ps`;
26
26
  this._brightnessID = `${this.info.fullID}.bri`;
27
- this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
27
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
28
28
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.lamp);
29
29
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.dimmablelamp);
30
30
  }
@@ -21,7 +21,7 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
21
21
  this._actuatorOn = false;
22
22
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.actuator);
23
23
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
24
- this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
24
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
25
25
  }
26
26
  /** @inheritDoc */
27
27
  get actuatorOn() {
@@ -85,7 +85,7 @@ class AcDevice {
85
85
  utils_1.Utils.guardedInterval(this.persist, 15 * 60 * 1000, this, true);
86
86
  this.persistDeviceInfo();
87
87
  this.loadDeviceSettings();
88
- this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
88
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
89
89
  }
90
90
  /** @inheritDoc */
91
91
  get energySettings() {
@@ -1,13 +1,15 @@
1
- import { BlockAutomaticCommand, BlockAutomaticLiftBlockCommand, BlockAutomaticUntilCommand, RestoreTargetAutomaticValueCommand } from '../../models';
1
+ import { BlockAutomaticCommand, BlockAutomaticLiftBlockCommand, BlockAutomaticUntilCommand, LogLevel, RestoreTargetAutomaticValueCommand } from '../../models';
2
+ import { LogDebugType } from './log-service';
2
3
  /**
3
4
  * This class is responsible for blocking automatic actions for a specific duration.
4
5
  * It also provides the possibility to lift the block before the duration is over {@link BlockAutomaticLiftBlockCommand}.
5
6
  */
6
7
  export declare class BlockAutomaticHandler {
8
+ private readonly _logger;
7
9
  private readonly _restoreAutomatic;
8
10
  private _automaticBlockedUntil;
9
11
  private _restoreAutomaticStateTimeout;
10
- constructor(restoreAutomaticCb: (c: RestoreTargetAutomaticValueCommand) => void);
12
+ constructor(restoreAutomaticCb: (c: RestoreTargetAutomaticValueCommand) => void, _logger: (level: LogLevel, message: string, logDebugType?: LogDebugType) => void);
11
13
  get automaticBlockedUntil(): Date;
12
14
  private set automaticBlockedUntil(value);
13
15
  get automaticBlockActive(): boolean;
@@ -12,7 +12,8 @@ const lodash_1 = __importDefault(require("lodash"));
12
12
  * It also provides the possibility to lift the block before the duration is over {@link BlockAutomaticLiftBlockCommand}.
13
13
  */
14
14
  class BlockAutomaticHandler {
15
- constructor(restoreAutomaticCb) {
15
+ constructor(restoreAutomaticCb, _logger) {
16
+ this._logger = _logger;
16
17
  this._automaticBlockedUntil = new Date(0);
17
18
  this._restoreAutomaticStateTimeout = null;
18
19
  this._restoreAutomatic = restoreAutomaticCb;
@@ -34,8 +35,10 @@ class BlockAutomaticHandler {
34
35
  if (this._automaticBlockedUntil > now &&
35
36
  c.onCollideAction != models_1.CollisionSolving.override &&
36
37
  (c.onCollideAction != models_1.CollisionSolving.overrideIfGreater || c.targetDate < this._automaticBlockedUntil)) {
38
+ this._logger(models_1.LogLevel.Info, `Block already active until "${this.automaticBlockedUntil.toLocaleTimeString('de-DE')}" --> ignoring: ${c.logMessage}`);
37
39
  return;
38
40
  }
41
+ this._logger(models_1.LogLevel.Info, c.logMessage);
39
42
  this.automaticBlockedUntil = c.targetDate;
40
43
  if (c.revertToAutomaticAtBlockLift) {
41
44
  const revertCommand = new models_1.RestoreTargetAutomaticValueCommand(c, 'Restore to automatic state after block.');
@@ -66,7 +69,7 @@ class BlockAutomaticHandler {
66
69
  }, this._automaticBlockedUntil.getTime() - utils_1.Utils.nowMS() + 500, this);
67
70
  }
68
71
  toJSON() {
69
- return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['_restoreAutomatic']));
72
+ return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['_restoreAutomatic', '_logger']));
70
73
  }
71
74
  }
72
75
  exports.BlockAutomaticHandler = BlockAutomaticHandler;
@@ -44,7 +44,7 @@ class OwnGoveeDevice {
44
44
  this._info.allDevicesKey = `govee-${roomName}-${deviceId}`;
45
45
  devices_1.Devices.alLDevices[`govee-${roomName}-${deviceId}`] = this;
46
46
  this.persistDeviceInfo();
47
- this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
47
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
48
48
  utils_1.Utils.guardedTimeout(this.loadDeviceSettings, 300, this);
49
49
  }
50
50
  get color() {