hoffmation-base 3.0.0-alpha.15 → 3.0.0-alpha.17

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,7 +11,7 @@ class ActuatorSetStateCommand extends baseCommand_1.BaseCommand {
11
11
  this._commandType = commandType_1.CommandType.ActuatorSetStateCommand;
12
12
  }
13
13
  get logMessage() {
14
- return `Actuator setState to ${this.on} for reason: ${this.reasonTrace}`;
14
+ return `Actuator setState to ${this.on} with timeout ${this.timeout} for reason: ${this.reasonTrace}`;
15
15
  }
16
16
  static byActuatorAndToggleCommand(device, c) {
17
17
  const newVal = device.queuedValue !== null ? !device.queuedValue : !device.actuatorOn;
@@ -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;
@@ -20,13 +20,13 @@ class DimmerSetLightCommand extends lampSetLightCommand_1.LampSetLightCommand {
20
20
  this._commandType = commandType_1.CommandType.DimmerSetLightCommand;
21
21
  }
22
22
  get logMessage() {
23
- return `Dimmer setLight to ${this.on} for reason: ${this.reasonTrace}`;
23
+ return `Dimmer setLight to ${this.on} with Brightness ${this.brightness} with timeout ${this.timeout} for reason: ${this.reasonTrace}`;
24
24
  }
25
25
  static byTimeBased(s, c) {
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:
@@ -9,7 +9,7 @@ class LampSetLightCommand extends actuatorSetStateCommand_1.ActuatorSetStateComm
9
9
  this._commandType = commandType_1.CommandType.LampSetLightCommand;
10
10
  }
11
11
  get logMessage() {
12
- return `Lamp setLight to ${this.on} for reason: ${this.reasonTrace}`;
12
+ return `Lamp setLight to ${this.on} with timeout ${this.timeout} for reason: ${this.reasonTrace}`;
13
13
  }
14
14
  }
15
15
  exports.LampSetLightCommand = LampSetLightCommand;
@@ -8,5 +8,6 @@ export declare class WledSetLightCommand extends DimmerSetLightCommand {
8
8
  preset?: number | undefined;
9
9
  _commandType: CommandType;
10
10
  constructor(source: CommandSource | BaseCommand, on: boolean, reason?: string, timeout?: number, brightness?: number, transitionTime?: number, preset?: number | undefined);
11
+ get logMessage(): string;
11
12
  static byTimeBased(settings: WledSettings, c: LampSetTimeBasedCommand): WledSetLightCommand;
12
13
  }
@@ -10,6 +10,9 @@ class WledSetLightCommand extends dimmerSetLightCommand_1.DimmerSetLightCommand
10
10
  this.preset = preset;
11
11
  this._commandType = commandType_1.CommandType.WledSetLightCommand;
12
12
  }
13
+ get logMessage() {
14
+ return `Dimmer setLight to ${this.on} with Brightness ${this.brightness}, timeout ${this.timeout} and preset ${this.preset} for reason: ${this.reasonTrace}`;
15
+ }
13
16
  static byTimeBased(settings, c) {
14
17
  switch (c.time) {
15
18
  case timeCallback_1.TimeOfDay.Daylight:
@@ -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() {
@@ -14,6 +14,8 @@ export declare abstract class IoBrokerBaseDevice implements iRoomDevice {
14
14
  };
15
15
  private _room;
16
16
  readonly deviceCapabilities: DeviceCapability[];
17
+ protected _debounceStateDelay: number;
18
+ protected _lastWrite: number;
17
19
  get customName(): string;
18
20
  get room(): RoomBase;
19
21
  protected readonly individualStateCallbacks: Map<string, Array<(val: ioBroker.StateValue) => void>>;
@@ -20,6 +20,9 @@ class IoBrokerBaseDevice {
20
20
  this.settings = undefined;
21
21
  this._room = undefined;
22
22
  this.deviceCapabilities = [];
23
+ // If configured > 0, this indicates the minimum time between state writes in ms
24
+ this._debounceStateDelay = 0;
25
+ this._lastWrite = 0;
23
26
  this.individualStateCallbacks = new Map();
24
27
  this.addToCorrectRoom();
25
28
  this.persistDeviceInfo();
@@ -152,13 +155,21 @@ class IoBrokerBaseDevice {
152
155
  if (!this.checkIoConnection(true)) {
153
156
  return;
154
157
  }
158
+ if (this._debounceStateDelay > 0 && services_1.Utils.nowMS() - this._lastWrite < this._debounceStateDelay) {
159
+ services_1.Utils.guardedTimeout(() => {
160
+ this.log(models_1.LogLevel.Trace, `Debounced write for ${pointId} to ${state}`);
161
+ this.setState(pointId, state, onSuccess, onError);
162
+ }, this._debounceStateDelay, this);
163
+ return;
164
+ }
165
+ this._lastWrite = services_1.Utils.nowMS();
155
166
  (_a = this.ioConn) === null || _a === void 0 ? void 0 : _a.setState(pointId, state, (err) => {
156
167
  if (err) {
157
168
  if (onError) {
158
169
  onError(err);
159
170
  }
160
171
  else {
161
- console.log(`Error occured while setting state "${pointId}" to "${state}": ${err}`);
172
+ this.log(models_1.LogLevel.Error, `Error occured while setting state "${pointId}" to "${state}": ${err}`);
162
173
  }
163
174
  return;
164
175
  }
@@ -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();
@@ -11,6 +11,7 @@ export declare class WledDevice extends IoBrokerBaseDevice implements iDimmableL
11
11
  settings: WledSettings;
12
12
  readonly blockAutomationHandler: BlockAutomaticHandler;
13
13
  targetAutomaticState: boolean;
14
+ protected readonly _debounceStateDelay: number;
14
15
  private readonly _onID;
15
16
  private readonly _presetID;
16
17
  private readonly _brightnessID;
@@ -17,6 +17,7 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
17
17
  this.queuedValue = null;
18
18
  this.settings = new models_1.WledSettings();
19
19
  this.targetAutomaticState = false;
20
+ this._debounceStateDelay = 500;
20
21
  this._onID = `${this.info.fullID}.on`;
21
22
  this._presetID = `${this.info.fullID}.ps`;
22
23
  this._brightnessID = `${this.info.fullID}.bri`;
@@ -49,7 +50,6 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
49
50
  this.setWled(new models_1.WledSetLightCommand(c, c.on, 'Set Wled due to DimmerSetLightCommand', c.timeout, c.brightness, c.transitionTime, undefined));
50
51
  }
51
52
  setWled(c) {
52
- this.log(models_1.LogLevel.Debug, c.logMessage);
53
53
  if (this._onID === '') {
54
54
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Keine On ID für "${this.info.customName}" bekannt.`);
55
55
  return;
@@ -62,13 +62,13 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
62
62
  if (sharedFunctions_1.LampUtils.checkBlockActive(this, c)) {
63
63
  return;
64
64
  }
65
+ this.log(models_1.LogLevel.Debug, c.logMessage);
65
66
  if (c.on && c.brightness !== -1 && this.brightness < 10) {
66
67
  c.brightness = 10;
67
68
  }
68
- services_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `WLED Schalten: "${this.info.customName}" An: ${c.on}\tHelligkeit: ${c.brightness}%`);
69
69
  this.queuedValue = c.on;
70
- this.writeActuatorStateToDevice(new models_1.ActuatorWriteStateToDeviceCommand(c, c.on, 'WLED Schalten'));
71
70
  if (c.preset !== undefined) {
71
+ // Warning: This also turns the device on
72
72
  this.setState(this._presetID, c.preset, undefined, (err) => {
73
73
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `WLED schalten ergab Fehler: ${err}`);
74
74
  });
@@ -78,12 +78,12 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
78
78
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Dimmer Helligkeit schalten ergab Fehler: ${err}`);
79
79
  });
80
80
  }
81
+ this.writeActuatorStateToDevice(new models_1.ActuatorWriteStateToDeviceCommand(c, c.on, 'WLED Schalten'));
81
82
  if (c.timeout !== undefined && c.timeout > -1 && !dontBlock) {
82
83
  this.blockAutomationHandler.disableAutomatic(c.timeout, models_1.CollisionSolving.overrideIfGreater);
83
84
  }
84
85
  }
85
86
  setTimeBased(c) {
86
- this.log(models_1.LogLevel.Debug, `Wled setTimeBased ${c.time}`);
87
87
  this.setWled(models_1.WledSetLightCommand.byTimeBased(this.settings, c));
88
88
  }
89
89
  persist() {
@@ -6,8 +6,6 @@ import { iDisposable } from '../../../services';
6
6
  export declare class ZigbeeDevice extends IoBrokerBaseDevice implements iDisposable {
7
7
  protected _available: boolean;
8
8
  protected _dontSendOnUnavailable: boolean;
9
- protected _debounceStateDelay: number;
10
- private _lastWrite;
11
9
  private readonly _deviceQueryId;
12
10
  get available(): boolean;
13
11
  protected _linkQuality: number;
@@ -18,9 +18,6 @@ class ZigbeeDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
18
18
  super(pInfo, pType);
19
19
  this._available = false;
20
20
  this._dontSendOnUnavailable = false;
21
- // If configured > 0, this indicates the minimum time between state writes in ms
22
- this._debounceStateDelay = 0;
23
- this._lastWrite = 0;
24
21
  this._linkQuality = 0;
25
22
  this.persistZigbeeInterval = services_1.Utils.guardedInterval(() => {
26
23
  this.persistZigbeeDevice();
@@ -78,15 +75,7 @@ class ZigbeeDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
78
75
  this.log(models_1.LogLevel.Warn, `Device unavailable --> Not changing ${pointId} to ${state}`);
79
76
  return;
80
77
  }
81
- if (this._debounceStateDelay === 0 || services_1.Utils.nowMS() - this._lastWrite > this._debounceStateDelay) {
82
- this._lastWrite = services_1.Utils.nowMS();
83
- super.setState(pointId, state, onSuccess, onError);
84
- return;
85
- }
86
- services_1.Utils.guardedTimeout(() => {
87
- this.log(models_1.LogLevel.Trace, `Debounced write to ${pointId} to ${state}`);
88
- this.setState(pointId, state, onSuccess, onError);
89
- }, this._debounceStateDelay, this);
78
+ super.setState(pointId, state, onSuccess, onError);
90
79
  }
91
80
  }
92
81
  exports.ZigbeeDevice = ZigbeeDevice;
@@ -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) {