hoffmation-base 3.0.0-alpha.39 → 3.0.0-alpha.40

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.
@@ -14,14 +14,14 @@ export declare class HmIpRoll extends HmIPDevice implements iShutter {
14
14
  constructor(pInfo: IoBrokerDeviceInfo);
15
15
  private _currentLevel;
16
16
  get currentLevel(): number;
17
- set currentLevel(value: number);
17
+ /** @inheritDoc */
18
+ update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
18
19
  private _window?;
19
20
  get window(): Window | undefined;
20
21
  set window(value: Window | undefined);
21
22
  get desiredWindowShutterLevel(): number;
22
23
  persist(): void;
23
- /** @inheritDoc */
24
- update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
24
+ private setCurrentLevel;
25
25
  setLevel(command: ShutterSetLevelCommand): void;
26
26
  toJSON(): Partial<IoBrokerBaseDevice>;
27
27
  }
@@ -37,18 +37,17 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
37
37
  }
38
38
  return this._currentLevel;
39
39
  }
40
- set currentLevel(value) {
41
- if (value !== this._setLevel && services_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
42
- value = this._setLevel;
43
- }
44
- if (value !== this._currentLevel && this._window) {
45
- services_1.Utils.guardedNewThread(() => {
46
- var _a;
47
- (_a = this._window) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(new models_2.ShutterPositionChangedAction(this, value));
48
- }, this);
49
- this.persist();
40
+ /** @inheritDoc */
41
+ update(idSplit, state, initial = false) {
42
+ this.log(models_2.LogLevel.DeepTrace, `Rollo Update : ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
43
+ super.update(idSplit, state, initial, true);
44
+ switch (idSplit[3]) {
45
+ case '3':
46
+ if (idSplit[4] === 'LEVEL') {
47
+ this.setCurrentLevel(state.val, true);
48
+ }
49
+ break;
50
50
  }
51
- this._currentLevel = value;
52
51
  }
53
52
  get window() {
54
53
  return this._window;
@@ -66,17 +65,18 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
66
65
  var _a;
67
66
  (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistShutter(this);
68
67
  }
69
- /** @inheritDoc */
70
- update(idSplit, state, initial = false) {
71
- this.log(models_2.LogLevel.DeepTrace, `Rollo Update : ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
72
- super.update(idSplit, state, initial, true);
73
- switch (idSplit[3]) {
74
- case '3':
75
- if (idSplit[4] === 'LEVEL') {
76
- this.currentLevel = state.val;
77
- }
78
- break;
68
+ setCurrentLevel(value, initial = false) {
69
+ if (value !== this._setLevel && services_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
70
+ value = this._setLevel;
79
71
  }
72
+ if (value !== this._currentLevel && this._window && !initial) {
73
+ services_1.Utils.guardedNewThread(() => {
74
+ var _a;
75
+ (_a = this._window) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(new models_2.ShutterPositionChangedAction(this, value));
76
+ }, this);
77
+ this.persist();
78
+ }
79
+ this._currentLevel = value;
80
80
  }
81
81
  setLevel(command) {
82
82
  let targetLevel = command.level;
@@ -89,7 +89,7 @@ class ZigbeeDimmer extends zigbeeLamp_1.ZigbeeLamp {
89
89
  }
90
90
  this.setBrightnessState(this.settings.turnOnThreshhold, () => {
91
91
  services_1.Utils.guardedTimeout(() => {
92
- this.log(models_1.LogLevel.Info, `Delayed reduced brightness on ${this.info.customName}`);
92
+ this.log(models_1.LogLevel.Info, `Delayed reduced brightness on ${this.info.customName} to ${c.brightness} for command: ${c.logMessage}`);
93
93
  this.setBrightnessState(c.brightness);
94
94
  }, 1000, this);
95
95
  });
@@ -14,14 +14,12 @@ export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
14
14
  protected _setLevel: number;
15
15
  protected _setLevelTime: number;
16
16
  protected _shutterCalibrationData: ShutterCalibration;
17
- constructor(pInfo: IoBrokerDeviceInfo, pType: DeviceType);
18
17
  protected _currentLevel: number;
18
+ protected _window?: Window;
19
+ constructor(pInfo: IoBrokerDeviceInfo, pType: DeviceType);
19
20
  /** @inheritDoc */
20
21
  get currentLevel(): number;
21
22
  /** @inheritDoc */
22
- protected set currentLevel(value: number);
23
- protected _window?: Window;
24
- /** @inheritDoc */
25
23
  get window(): Window | undefined;
26
24
  /** @inheritDoc */
27
25
  set window(value: Window | undefined);
@@ -35,6 +33,7 @@ export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
35
33
  setLevel(c: ShutterSetLevelCommand): void;
36
34
  /** @inheritDoc */
37
35
  toJSON(): Partial<IoBrokerBaseDevice>;
36
+ protected setCurrentLevel(value: number, isInitial?: boolean): void;
38
37
  protected moveToPosition(pPosition: number): void;
39
38
  protected getAverageUp(): number;
40
39
  protected getAverageDown(): number;
@@ -45,20 +45,6 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
45
45
  return this._currentLevel;
46
46
  }
47
47
  /** @inheritDoc */
48
- set currentLevel(value) {
49
- if (value !== this._setLevel && services_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
50
- value = this._setLevel;
51
- }
52
- if (value !== this._currentLevel && this._window) {
53
- services_1.Utils.guardedNewThread(() => {
54
- var _a;
55
- (_a = this._window) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(new models_1.ShutterPositionChangedAction(this, value));
56
- }, this);
57
- this.persist();
58
- }
59
- this._currentLevel = value;
60
- }
61
- /** @inheritDoc */
62
48
  get window() {
63
49
  return this._window;
64
50
  }
@@ -119,6 +105,19 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
119
105
  toJSON() {
120
106
  return lodash_1.default.omit(super.toJSON(), ['_window']);
121
107
  }
108
+ setCurrentLevel(value, isInitial = false) {
109
+ if (value !== this._setLevel && services_1.Utils.nowMS() - this._setLevelTime < 60 * 10000) {
110
+ value = this._setLevel;
111
+ }
112
+ if (value !== this._currentLevel && this._window && !isInitial) {
113
+ services_1.Utils.guardedNewThread(() => {
114
+ var _a;
115
+ (_a = this._window) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(new models_1.ShutterPositionChangedAction(this, value));
116
+ }, this);
117
+ this.persist();
118
+ }
119
+ this._currentLevel = value;
120
+ }
122
121
  moveToPosition(pPosition) {
123
122
  this.log(models_1.LogLevel.Error, `Implement own moveToPosition(${pPosition}) Function`);
124
123
  }
@@ -153,7 +152,7 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
153
152
  clearTimeout(this._iMovementFinishTimeout);
154
153
  }
155
154
  this._iMovementFinishTimeout = services_1.Utils.guardedTimeout(() => {
156
- this.currentLevel = endPosition;
155
+ this.setCurrentLevel(endPosition, false);
157
156
  this._iMovementFinishTimeout = null;
158
157
  }, duration, this);
159
158
  }
@@ -15,7 +15,7 @@ class ZigbeeIkeaShutter extends BaseDevices_1.ZigbeeShutter {
15
15
  switch (idSplit[3]) {
16
16
  case 'position':
17
17
  this.log(models_1.LogLevel.Trace, `Shutter Update for ${this.info.customName} to "${state.val}"`);
18
- this.currentLevel = state.val;
18
+ this.setCurrentLevel(state.val, initial);
19
19
  break;
20
20
  }
21
21
  super.update(idSplit, state, initial, true);
@@ -89,7 +89,7 @@ class ZigbeeIlluShutter extends BaseDevices_1.ZigbeeShutter {
89
89
  const oldState = this._movementState;
90
90
  if (this._movementStartPos === 0 && oldState === MovementState.Up && this._setLevel === 100) {
91
91
  this.log(models_1.LogLevel.Debug, `New Time-Until-Top measurement for ${this.info.customName}: ${timePassed}ms`);
92
- this.currentLevel = this._setLevel;
92
+ this.setCurrentLevel(this._setLevel);
93
93
  this._shutterCalibrationData.counterUp++;
94
94
  this._shutterCalibrationData.averageUp +=
95
95
  (timePassed - this._shutterCalibrationData.averageUp) / this._shutterCalibrationData.counterUp;
@@ -99,7 +99,7 @@ class ZigbeeIlluShutter extends BaseDevices_1.ZigbeeShutter {
99
99
  }
100
100
  if (this._movementStartPos === 100 && oldState === MovementState.Down && this._setLevel === 0) {
101
101
  this.log(models_1.LogLevel.Debug, `New Time-Until-Bottom measurement for ${this.info.customName}: ${timePassed}ms`);
102
- this.currentLevel = this._setLevel;
102
+ this.setCurrentLevel(this._setLevel);
103
103
  this._shutterCalibrationData.counterDown++;
104
104
  this._shutterCalibrationData.averageDown +=
105
105
  (timePassed - this._shutterCalibrationData.averageDown) / this._shutterCalibrationData.counterDown;
@@ -111,10 +111,10 @@ class ZigbeeIlluShutter extends BaseDevices_1.ZigbeeShutter {
111
111
  return;
112
112
  }
113
113
  if (oldState === MovementState.Down) {
114
- this.currentLevel = Math.min(this._currentLevel - Math.round((timePassed * 100) / this.getAverageDown()), 0);
114
+ this.setCurrentLevel(Math.min(this._currentLevel - Math.round((timePassed * 100) / this.getAverageDown()), 0));
115
115
  }
116
116
  else if (oldState === MovementState.Up) {
117
- this.currentLevel = Math.max(this._currentLevel + Math.round((timePassed * 100) / this.getAverageUp()), 100);
117
+ this.setCurrentLevel(Math.max(this._currentLevel + Math.round((timePassed * 100) / this.getAverageUp()), 100));
118
118
  }
119
119
  }
120
120
  }
@@ -15,7 +15,7 @@ class ZigbeeUbisysShutter extends BaseDevices_1.ZigbeeShutter {
15
15
  switch (idSplit[3]) {
16
16
  case 'position':
17
17
  this.log(models_1.LogLevel.Trace, `Shutter Update for ${this.info.customName} to "${state.val}"`);
18
- this.currentLevel = state.val;
18
+ this.setCurrentLevel(state.val, initial);
19
19
  break;
20
20
  }
21
21
  super.update(idSplit, state, initial, true);