hoffmation-base 3.0.0-alpha.2 → 3.0.0-alpha.20

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.
Files changed (74) hide show
  1. package/lib/models/command/ShutterSetLevelCommand.js +2 -1
  2. package/lib/models/command/WindowRestoreDesiredPositionCommand.js +1 -0
  3. package/lib/models/command/WindowSetDesiredPositionCommand.js +1 -0
  4. package/lib/models/command/WindowSetRolloByWeatherStatusCommand.js +1 -0
  5. package/lib/models/command/actuatorSetStateCommand.js +3 -2
  6. package/lib/models/command/actuatorToggleCommand.js +2 -1
  7. package/lib/models/command/actuatorWriteStateToDeviceCommand.d.ts +1 -1
  8. package/lib/models/command/actuatorWriteStateToDeviceCommand.js +7 -2
  9. package/lib/models/command/baseCommand.d.ts +4 -1
  10. package/lib/models/command/baseCommand.js +25 -6
  11. package/lib/models/command/blockAutomaticCommand.d.ts +17 -0
  12. package/lib/models/command/blockAutomaticCommand.js +22 -0
  13. package/lib/models/command/blockAutomaticLiftBlockCommand.d.ts +12 -0
  14. package/lib/models/command/blockAutomaticLiftBlockCommand.js +17 -0
  15. package/lib/models/command/blockAutomaticUntilCommand.d.ts +17 -0
  16. package/lib/models/command/blockAutomaticUntilCommand.js +22 -0
  17. package/lib/models/command/commandSource.js +1 -0
  18. package/lib/models/command/commandType.d.ts +3 -0
  19. package/lib/models/command/commandType.js +3 -0
  20. package/lib/models/command/dimmerSetLightCommand.js +6 -5
  21. package/lib/models/command/index.d.ts +3 -0
  22. package/lib/models/command/index.js +7 -1
  23. package/lib/models/command/lampSetLightCommand.js +2 -1
  24. package/lib/models/command/lampSetTimeBasedCommand.js +1 -1
  25. package/lib/models/command/lampToggleLightCommand.js +1 -1
  26. package/lib/models/command/ledSetLightCommand.js +2 -1
  27. package/lib/models/command/lightGroupSwitchTimeConditionalCommand.js +1 -0
  28. package/lib/models/command/restoreTargetAutomaticValueCommand.js +2 -1
  29. package/lib/models/command/roomRestoreLightCommand.js +1 -0
  30. package/lib/models/command/roomRestoreShutterPositionCommand.js +1 -0
  31. package/lib/models/command/shutterSunriseUpCommand.js +1 -0
  32. package/lib/models/command/shutterSunsetDownCommand.js +1 -0
  33. package/lib/models/command/wledSetLightCommand.d.ts +1 -0
  34. package/lib/models/command/wledSetLightCommand.js +4 -0
  35. package/lib/models/deviceSettings/acSettings.d.ts +7 -1
  36. package/lib/models/deviceSettings/acSettings.js +11 -4
  37. package/lib/models/deviceSettings/actuatorSettings.d.ts +17 -0
  38. package/lib/models/deviceSettings/actuatorSettings.js +23 -5
  39. package/lib/models/deviceSettings/ledSettings.js +10 -18
  40. package/lib/models/deviceSettings/wledSettings.js +5 -13
  41. package/lib/models/groupSettings/heatGroupSettings.d.ts +4 -0
  42. package/lib/models/groupSettings/heatGroupSettings.js +4 -0
  43. package/lib/models/rooms/RoomBase.js +2 -2
  44. package/lib/server/devices/IoBrokerBaseDevice.d.ts +2 -0
  45. package/lib/server/devices/IoBrokerBaseDevice.js +12 -1
  46. package/lib/server/devices/baseDeviceInterfaces/iAcDevice.d.ts +0 -5
  47. package/lib/server/devices/groups/heatGroup.d.ts +1 -0
  48. package/lib/server/devices/groups/heatGroup.js +2 -3
  49. package/lib/server/devices/groups/lightGroup.d.ts +2 -2
  50. package/lib/server/devices/groups/lightGroup.js +11 -10
  51. package/lib/server/devices/hmIPDevices/hmIpLampe.js +1 -2
  52. package/lib/server/devices/hmIPDevices/hmIpRoll.js +2 -2
  53. package/lib/server/devices/sharedFunctions/lampUtils.d.ts +1 -0
  54. package/lib/server/devices/sharedFunctions/lampUtils.js +30 -15
  55. package/lib/server/devices/wledDevice.d.ts +1 -0
  56. package/lib/server/devices/wledDevice.js +13 -8
  57. package/lib/server/devices/zigbee/BaseDevices/ZigbeeActuator.js +1 -2
  58. package/lib/server/devices/zigbee/BaseDevices/zigbeeDevice.d.ts +0 -2
  59. package/lib/server/devices/zigbee/BaseDevices/zigbeeDevice.js +9 -18
  60. package/lib/server/devices/zigbee/BaseDevices/zigbeeDimmer.js +8 -8
  61. package/lib/server/devices/zigbee/BaseDevices/zigbeeLedRGBCCT.d.ts +2 -1
  62. package/lib/server/devices/zigbee/BaseDevices/zigbeeLedRGBCCT.js +6 -4
  63. package/lib/server/devices/zigbee/BaseDevices/zigbeeShutter.js +3 -3
  64. package/lib/server/services/ac/ac-device.d.ts +0 -5
  65. package/lib/server/services/ac/ac-device.js +17 -18
  66. package/lib/server/services/ac/daikin-service.js +2 -1
  67. package/lib/server/services/ac/own-daikin-device.js +12 -4
  68. package/lib/server/services/api/api-service.d.ts +65 -2
  69. package/lib/server/services/api/api-service.js +108 -18
  70. package/lib/server/services/blockAutomaticHandler.d.ts +6 -8
  71. package/lib/server/services/blockAutomaticHandler.js +11 -14
  72. package/lib/server/services/govee/own-govee-device.js +4 -7
  73. package/lib/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +1 -1
@@ -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() {
@@ -3,6 +3,10 @@ import { iIdHolder } from '../iIdHolder';
3
3
  import { GroupSettings } from './groupSettings';
4
4
  export declare class HeatGroupSettings extends GroupSettings {
5
5
  automaticPoints: TemperatureSettings[];
6
+ /**
7
+ * Whether the temperature should be calculated automatically, or the manualTemperature should be used
8
+ * @type {boolean}
9
+ */
6
10
  automaticMode: boolean;
7
11
  automaticFallBackTemperatur: number;
8
12
  /**
@@ -7,6 +7,10 @@ class HeatGroupSettings extends groupSettings_1.GroupSettings {
7
7
  constructor() {
8
8
  super(...arguments);
9
9
  this.automaticPoints = [];
10
+ /**
11
+ * Whether the temperature should be calculated automatically, or the manualTemperature should be used
12
+ * @type {boolean}
13
+ */
10
14
  this.automaticMode = true;
11
15
  this.automaticFallBackTemperatur = 20;
12
16
  /**
@@ -115,7 +115,7 @@ class RoomBase {
115
115
  }
116
116
  if (c.movementDependant && this.PraesenzGroup && !((_a = this.PraesenzGroup) === null || _a === void 0 ? void 0 : _a.anyPresent())) {
117
117
  this.log(logLevel_1.LogLevel.Trace, 'Turn off lights as no-one is present.');
118
- this.LightGroup.switchAll(new command_1.ActuatorSetStateCommand(c, false, 'Room.setLightTimeBased but no one is present'));
118
+ this.LightGroup.switchAll(new command_1.ActuatorSetStateCommand(c, false, 'No one is present --> Turn off lights.'));
119
119
  return;
120
120
  }
121
121
  if (!this.settings.lampOffset && !this.settings.roomIsAlwaysDark) {
@@ -132,7 +132,7 @@ class RoomBase {
132
132
  })))) {
133
133
  timeOfDay = server_1.Utils.nowTime().hours > 16 ? timeCallback_1.TimeOfDay.AfterSunset : timeCallback_1.TimeOfDay.BeforeSunrise;
134
134
  }
135
- this.LightGroup.switchTimeConditional(new command_1.LightGroupSwitchTimeConditionalCommand(c, timeOfDay, 'Roombase.setLightTimeBased'));
135
+ this.LightGroup.switchTimeConditional(new command_1.LightGroupSwitchTimeConditionalCommand(c, timeOfDay));
136
136
  }
137
137
  isNowLightTime() {
138
138
  var _a;
@@ -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
  }
@@ -6,11 +6,6 @@ export interface iAcDevice extends iBaseDevice {
6
6
  readonly on: boolean;
7
7
  readonly temperature: number;
8
8
  readonly mode: AcMode;
9
- /**
10
- * Disable automatic Turn-On for given amount of ms and turn off immediately.
11
- * @param {number} timeout
12
- */
13
- deactivateAutomaticChange(timeout: number): void;
14
9
  onTemperaturChange(newTemperatur: number): void;
15
10
  setDesiredMode(mode: AcMode, writeToDevice: boolean): void;
16
11
  turnOn(): void;
@@ -25,6 +25,7 @@ export declare class HeatGroup extends BaseGroup {
25
25
  initialize(): void;
26
26
  /**
27
27
  * Sets all ACs to new desired Value
28
+ * TODO: Migrate to new Command System
28
29
  * @param {boolean} newDesiredState
29
30
  * @param {boolean} force Whether this was a manual trigger, thus blocking automatic changes for 1 hour
30
31
  */
@@ -127,6 +127,7 @@ class HeatGroup extends base_group_1.BaseGroup {
127
127
  }
128
128
  /**
129
129
  * Sets all ACs to new desired Value
130
+ * TODO: Migrate to new Command System
130
131
  * @param {boolean} newDesiredState
131
132
  * @param {boolean} force Whether this was a manual trigger, thus blocking automatic changes for 1 hour
132
133
  */
@@ -139,9 +140,7 @@ class HeatGroup extends base_group_1.BaseGroup {
139
140
  continue;
140
141
  }
141
142
  dev.turnOff();
142
- if (force) {
143
- dev.deactivateAutomaticChange(60 * 60 * 1000);
144
- }
143
+ dev.blockAutomationHandler.disableAutomatic(new models_1.BlockAutomaticCommand(force ? models_1.CommandSource.Force : models_1.CommandSource.Unknown, 60 * 60 * 1000));
145
144
  }
146
145
  }
147
146
  deleteAutomaticPoint(name) {
@@ -1,6 +1,6 @@
1
1
  import { BaseGroup } from './base-group';
2
2
  import { iActuator, iLamp } from '../baseDeviceInterfaces';
3
- import { ActuatorSetStateCommand, LampSetLightCommand, LampSetTimeBasedCommand, LedSetLightCommand, LightGroupSwitchTimeConditionalCommand, TimeCallback, TimeOfDay, WledSetLightCommand } from '../../../models';
3
+ import { ActuatorSetStateCommand, LampSetLightCommand, LampSetTimeBasedCommand, LedSetLightCommand, LightGroupSwitchTimeConditionalCommand, TimeCallback, WledSetLightCommand } from '../../../models';
4
4
  import { WledDevice } from '../wledDevice';
5
5
  import { iLedRgbCct } from '../baseDeviceInterfaces/iLedRgbCct';
6
6
  export declare class LightGroup extends BaseGroup {
@@ -20,7 +20,7 @@ export declare class LightGroup extends BaseGroup {
20
20
  setAllLampen(c: LampSetLightCommand): void;
21
21
  setAllLampenTimeBased(c: LampSetTimeBasedCommand): void;
22
22
  setAllOutlets(c: ActuatorSetStateCommand): void;
23
- setAllActuatorsTimeBased(time: TimeOfDay): void;
23
+ setAllActuatorsTimeBased(c: LampSetTimeBasedCommand): void;
24
24
  setAllLED(c: LedSetLightCommand): void;
25
25
  setAllWled(c: WledSetLightCommand): void;
26
26
  initialize(): void;
@@ -70,7 +70,7 @@ class LightGroup extends base_group_1.BaseGroup {
70
70
  switchAll(c) {
71
71
  this.getAllAsActuator().forEach((a) => {
72
72
  if (a.settings.includeInAmbientLight && !c.isForceAction && !c.on && this._ambientLightOn) {
73
- a.log(models_1.LogLevel.Info, `Ambient light mode is active --> Skip non force light off command in ${this.roomName}`);
73
+ a.log(models_1.LogLevel.Info, `Ambient light mode is active --> Skip non force light off command in ${this.roomName}; command: ${c.logMessage}`);
74
74
  return;
75
75
  }
76
76
  a.setActuator(c);
@@ -106,16 +106,16 @@ class LightGroup extends base_group_1.BaseGroup {
106
106
  resultLampen = darkOutside;
107
107
  }
108
108
  if (resultLampen) {
109
- this.setAllLampenTimeBased(new models_1.LampSetTimeBasedCommand(models_1.CommandSource.Automatic, c.time, 'LightGroup switchTimeConditional'));
109
+ this.setAllLampenTimeBased(new models_1.LampSetTimeBasedCommand(c, c.time));
110
110
  }
111
111
  else {
112
- this.setAllLampen(new models_1.LampSetLightCommand(models_1.CommandSource.Automatic, false, 'LightGroup switchTimeConditional --> off'));
112
+ this.setAllLampen(new models_1.LampSetLightCommand(c, false));
113
113
  }
114
114
  if (resultSteckdosen) {
115
- this.setAllActuatorsTimeBased(c.time);
115
+ this.setAllActuatorsTimeBased(new models_1.LampSetTimeBasedCommand(c, c.time));
116
116
  }
117
117
  else {
118
- this.setAllOutlets(new models_1.ActuatorSetStateCommand(models_1.CommandSource.Automatic, false, 'LightGroup switchTimeConditional --> off'));
118
+ this.setAllOutlets(new models_1.ActuatorSetStateCommand(c, false));
119
119
  }
120
120
  }
121
121
  setAllLampen(c) {
@@ -133,12 +133,13 @@ class LightGroup extends base_group_1.BaseGroup {
133
133
  s.setActuator(c);
134
134
  });
135
135
  }
136
- setAllActuatorsTimeBased(time) {
136
+ setAllActuatorsTimeBased(c) {
137
137
  this.getOutlets().forEach((s) => {
138
- if ((time === models_1.TimeOfDay.Night && s.settings.nightOn) ||
139
- (time === models_1.TimeOfDay.BeforeSunrise && s.settings.dawnOn) ||
140
- (time === models_1.TimeOfDay.AfterSunset && s.settings.duskOn)) {
141
- s.setActuator(new models_1.ActuatorSetStateCommand(models_1.CommandSource.Automatic, true, `LightGroup setAllActuatorsTimeBased`));
138
+ if ((c.time === models_1.TimeOfDay.Daylight && s.settings.dayOn) ||
139
+ (c.time === models_1.TimeOfDay.Night && s.settings.nightOn) ||
140
+ (c.time === models_1.TimeOfDay.BeforeSunrise && s.settings.dawnOn) ||
141
+ (c.time === models_1.TimeOfDay.AfterSunset && s.settings.duskOn)) {
142
+ s.setActuator(new models_1.ActuatorSetStateCommand(c, true, `LightGroup setAllActuatorsTimeBased`, c.timeout));
142
143
  }
143
144
  });
144
145
  }
@@ -25,8 +25,7 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
25
25
  return this.lightOn;
26
26
  }
27
27
  restoreTargetAutomaticValue(c) {
28
- this.log(models_1.LogLevel.Debug, c.logMessage);
29
- this.setLight(new models_1.LampSetLightCommand(c, this.targetAutomaticState, 'Lampen RestoreTargetAutomaticValue'));
28
+ this.setLight(new models_1.LampSetLightCommand(c, this.targetAutomaticState));
30
29
  }
31
30
  update(idSplit, state, initial = false) {
32
31
  this.log(models_1.LogLevel.DeepTrace, `Lampen Update : ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
@@ -77,7 +77,6 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
77
77
  }
78
78
  }
79
79
  setLevel(command) {
80
- this.log(models_2.LogLevel.Debug, command.logMessage);
81
80
  let targetLevel = command.level;
82
81
  if (!this._firstCommandRecieved && !command.isInitial) {
83
82
  this._firstCommandRecieved = true;
@@ -87,7 +86,7 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
87
86
  return;
88
87
  }
89
88
  if (this.currentLevel === targetLevel && !command.isForceAction) {
90
- this.log(models_2.LogLevel.Debug, `Skip Rollo command to Position ${targetLevel} as this is the current one`, services_1.LogDebugType.SkipUnchangedRolloPosition);
89
+ this.log(models_2.LogLevel.Debug, `Skip Rollo command to Position ${targetLevel} as this is the current one, commandLog: ${command.logMessage}`, services_1.LogDebugType.SkipUnchangedRolloPosition);
91
90
  return;
92
91
  }
93
92
  if (this._setLevelSwitchID === '') {
@@ -97,6 +96,7 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
97
96
  if (!this.checkIoConnection(true)) {
98
97
  return;
99
98
  }
99
+ this.log(models_2.LogLevel.Debug, command.logMessage);
100
100
  if (this._window !== undefined) {
101
101
  if (this._window.griffeInPosition(models_1.WindowPosition.offen) > 0 && command.level < 100) {
102
102
  if (!command.skipOpenWarning) {
@@ -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,21 +5,26 @@ 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
- if ((c.time === models_1.TimeOfDay.Night && device.settings.nightOn) ||
22
+ if (c.isManual ||
23
+ (c.time === models_1.TimeOfDay.Daylight && device.settings.dayOn) ||
24
+ (c.time === models_1.TimeOfDay.Night && device.settings.nightOn) ||
20
25
  (c.time === models_1.TimeOfDay.BeforeSunrise && device.settings.dawnOn) ||
21
26
  (c.time === models_1.TimeOfDay.AfterSunset && device.settings.duskOn)) {
22
- device.setLight(new models_1.LampSetLightCommand(c, true, `SetLight due to TimeBased ${c.time}`, c.timeout));
27
+ device.setLight(new models_1.LampSetLightCommand(c, true, `SetLight due to TimeBased ${models_1.TimeOfDay[c.time]}`, c.timeout));
23
28
  }
24
29
  }
25
30
  static checkUnBlock(device, command) {
@@ -29,8 +34,7 @@ class LampUtils {
29
34
  !command.on &&
30
35
  device.blockAutomationHandler.automaticBlockActive) {
31
36
  dontBlock = true;
32
- device.log(models_1.LogLevel.Debug, `Reset Automatic Block as we are turning off manually after a force on`);
33
- device.blockAutomationHandler.liftAutomaticBlock();
37
+ device.blockAutomationHandler.liftAutomaticBlock(new models_1.BlockAutomaticLiftBlockCommand(command, 'Reset Automatic Block as we are turning off manually after a force on'));
34
38
  }
35
39
  return dontBlock;
36
40
  }
@@ -42,15 +46,15 @@ class LampUtils {
42
46
  c.time = services_1.TimeCallbackService.dayType((_a = device.room) === null || _a === void 0 ? void 0 : _a.settings.lampOffset);
43
47
  }
44
48
  if (newVal && c.time !== undefined) {
45
- device.setTimeBased(new models_1.LampSetTimeBasedCommand(c, c.time, 'SetLight Due to toggle Light', timeout));
49
+ device.setTimeBased(new models_1.LampSetTimeBasedCommand(c, c.time, '', timeout));
46
50
  return true;
47
51
  }
48
- device.setLight(new models_1.LampSetLightCommand(c, newVal, 'SetLight Due to toggle Light', timeout));
52
+ device.setLight(new models_1.LampSetLightCommand(c, newVal, '', timeout));
49
53
  return newVal;
50
54
  }
51
55
  static checkBlockActive(device, c) {
52
56
  if (!c.isForceAction && device.blockAutomationHandler.automaticBlockActive) {
53
- device.log(models_1.LogLevel.Debug, `Skip automatic command to ${c.on} as it is locked until ${new Date(device.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString()}`);
57
+ device.log(models_1.LogLevel.Debug, `Skip command to ${c.on} as it is locked until ${new Date(device.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString()}; command Log: ${c.logMessage}`);
54
58
  device.targetAutomaticState = c.on;
55
59
  return true;
56
60
  }
@@ -64,22 +68,33 @@ class LampUtils {
64
68
  return false;
65
69
  }
66
70
  static setActuator(device, c) {
71
+ if (device.settings.isStromStoss &&
72
+ c.on &&
73
+ c.containsType(models_1.CommandType.ActuatorRestoreTargetAutomaticValueCommand)) {
74
+ // Don't restore automatic state on Strommstoss-Relais as this might result in a loop.
75
+ return;
76
+ }
67
77
  const dontBlock = LampUtils.checkUnBlock(device, c);
68
78
  if (LampUtils.checkBlockActive(device, c)) {
69
79
  return;
70
80
  }
81
+ if (c.isAutomaticAction) {
82
+ // Preserve the target state for the automatic handler, as
83
+ device.targetAutomaticState = c.on;
84
+ }
71
85
  if (LampUtils.checkUnchanged(device, c)) {
72
86
  return;
73
87
  }
74
88
  device.queuedValue = c.on;
75
- device.writeActuatorStateToDevice(new models_1.ActuatorWriteStateToDeviceCommand(c.on, c));
89
+ device.writeActuatorStateToDevice(new models_1.ActuatorWriteStateToDeviceCommand(c, c.on));
76
90
  if (device.settings.isStromStoss && c.on) {
77
91
  c.timeout = 3000;
78
92
  LampUtils.stromStossOn(device);
79
93
  }
80
94
  if (c.timeout > -1 && !dontBlock) {
81
- device.blockAutomationHandler.disableAutomatic(c.timeout, models_1.CollisionSolving.overrideIfGreater);
95
+ device.blockAutomationHandler.disableAutomatic(new models_1.BlockAutomaticCommand(c, c.timeout, '', models_1.CollisionSolving.overrideIfGreater));
82
96
  }
83
97
  }
84
98
  }
85
99
  exports.LampUtils = LampUtils;
100
+ 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;
@@ -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);
@@ -16,10 +17,13 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
16
17
  this.queuedValue = null;
17
18
  this.settings = new models_1.WledSettings();
18
19
  this.targetAutomaticState = false;
20
+ this._debounceStateDelay = 500;
19
21
  this._onID = `${this.info.fullID}.on`;
20
22
  this._presetID = `${this.info.fullID}.ps`;
21
23
  this._brightnessID = `${this.info.fullID}.bri`;
22
24
  this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
25
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.lamp);
26
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.dimmablelamp);
23
27
  }
24
28
  get actuatorOn() {
25
29
  return this.on;
@@ -28,8 +32,7 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
28
32
  return this.on;
29
33
  }
30
34
  restoreTargetAutomaticValue(c) {
31
- this.log(models_1.LogLevel.Debug, c.logMessage);
32
- this.setLight(new models_1.WledSetLightCommand(c, this.targetAutomaticState, 'Lampen RestoreTargetAutomaticValue'));
35
+ this.setLight(new models_1.WledSetLightCommand(c, this.targetAutomaticState));
33
36
  }
34
37
  update(idSplit, state, initial = false, _pOverride = false) {
35
38
  this.queuedValue = null;
@@ -47,7 +50,6 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
47
50
  this.setWled(new models_1.WledSetLightCommand(c, c.on, 'Set Wled due to DimmerSetLightCommand', c.timeout, c.brightness, c.transitionTime, undefined));
48
51
  }
49
52
  setWled(c) {
50
- this.log(models_1.LogLevel.Debug, c.logMessage);
51
53
  if (this._onID === '') {
52
54
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Keine On ID für "${this.info.customName}" bekannt.`);
53
55
  return;
@@ -60,28 +62,31 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
60
62
  if (sharedFunctions_1.LampUtils.checkBlockActive(this, c)) {
61
63
  return;
62
64
  }
65
+ this.log(models_1.LogLevel.Debug, c.logMessage);
63
66
  if (c.on && c.brightness !== -1 && this.brightness < 10) {
64
67
  c.brightness = 10;
65
68
  }
66
- services_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `WLED Schalten: "${this.info.customName}" An: ${c.on}\tHelligkeit: ${c.brightness}%`);
67
69
  this.queuedValue = c.on;
68
- this.writeActuatorStateToDevice(new models_1.ActuatorWriteStateToDeviceCommand(c.on, c, 'WLED Schalten'));
69
- if (c.preset !== undefined) {
70
+ if (!c.on) {
71
+ this.writeActuatorStateToDevice(new models_1.ActuatorWriteStateToDeviceCommand(c, c.on, 'WLED ausschalten'));
72
+ }
73
+ else if (c.preset !== undefined) {
74
+ // This also turns the device on
70
75
  this.setState(this._presetID, c.preset, undefined, (err) => {
71
76
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `WLED schalten ergab Fehler: ${err}`);
72
77
  });
73
78
  }
74
79
  else if (c.brightness > -1) {
80
+ // This also turns the device on
75
81
  this.setState(this._brightnessID, c.brightness, undefined, (err) => {
76
82
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Dimmer Helligkeit schalten ergab Fehler: ${err}`);
77
83
  });
78
84
  }
79
85
  if (c.timeout !== undefined && c.timeout > -1 && !dontBlock) {
80
- this.blockAutomationHandler.disableAutomatic(c.timeout, models_1.CollisionSolving.overrideIfGreater);
86
+ this.blockAutomationHandler.disableAutomatic(new models_1.BlockAutomaticCommand(c, c.timeout, '', models_1.CollisionSolving.overrideIfGreater));
81
87
  }
82
88
  }
83
89
  setTimeBased(c) {
84
- this.log(models_1.LogLevel.Debug, `Wled setTimeBased ${c.time}`);
85
90
  this.setWled(models_1.WledSetLightCommand.byTimeBased(this.settings, c));
86
91
  }
87
92
  persist() {
@@ -23,8 +23,7 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
23
23
  this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
24
24
  }
25
25
  restoreTargetAutomaticValue(c) {
26
- this.log(models_1.LogLevel.Debug, `Restore Target Automatic value`);
27
- this.setActuator(new models_1.ActuatorSetStateCommand(c, this.targetAutomaticState, 'Restore Target Automatic value'));
26
+ this.setActuator(new models_1.ActuatorSetStateCommand(c, this.targetAutomaticState));
28
27
  }
29
28
  update(idSplit, state, initial = false, handledByChildObject = false) {
30
29
  if (!handledByChildObject) {
@@ -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();
@@ -40,16 +37,18 @@ class ZigbeeDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
40
37
  }
41
38
  switch (idSplit[3]) {
42
39
  case 'available':
43
- this._available = state.val;
44
- if (!this._available) {
45
- this.log(models_1.LogLevel.Debug, `Das Zigbee Gerät ist nicht erreichbar.`);
40
+ const newAvailability = state.val;
41
+ if (this._available && !newAvailability) {
42
+ this.log(models_1.LogLevel.Debug, `Device became unavailable.`);
46
43
  }
44
+ this._available = newAvailability;
47
45
  break;
48
46
  case 'link_quality':
49
- this._linkQuality = state.val;
50
- if (this._linkQuality < 5) {
51
- this.log(models_1.LogLevel.Debug, `Das Zigbee Gerät hat eine schlechte Verbindung (${this._linkQuality}).`);
47
+ const newValue = state.val;
48
+ if (this._linkQuality > 5 && newValue <= 5) {
49
+ this.log(models_1.LogLevel.Debug, `The link-quality dropped to a critical level: ${newValue}`);
52
50
  }
51
+ this._linkQuality = state.val;
53
52
  break;
54
53
  }
55
54
  this.stateMap.set(idSplit[3], state);
@@ -76,15 +75,7 @@ class ZigbeeDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
76
75
  this.log(models_1.LogLevel.Warn, `Device unavailable --> Not changing ${pointId} to ${state}`);
77
76
  return;
78
77
  }
79
- if (this._debounceStateDelay === 0 || services_1.Utils.nowMS() - this._lastWrite > this._debounceStateDelay) {
80
- this._lastWrite = services_1.Utils.nowMS();
81
- super.setState(pointId, state, onSuccess, onError);
82
- return;
83
- }
84
- services_1.Utils.guardedTimeout(() => {
85
- this.log(models_1.LogLevel.Trace, `Debounced write to ${pointId} to ${state}`);
86
- this.setState(pointId, state, onSuccess, onError);
87
- }, this._debounceStateDelay, this);
78
+ super.setState(pointId, state, onSuccess, onError);
88
79
  }
89
80
  }
90
81
  exports.ZigbeeDevice = ZigbeeDevice;