hoffmation-base 3.3.2 → 3.3.8

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.
@@ -165,10 +165,8 @@ class WindowGroup extends base_group_1.BaseGroup {
165
165
  if (this.sunsetShutterCallback && room.settings.rolloOffset) {
166
166
  this.sunsetShutterCallback.minuteOffset = room.settings.rolloOffset.sunset;
167
167
  this.sunsetShutterCallback.sunTimeOffset = room.settings.rolloOffset;
168
- if (room.settings.sonnenUntergangRolloAdditionalOffsetPerCloudiness > 0) {
169
- this.sunsetShutterCallback.cloudOffset =
170
- services_1.WeatherService.getCurrentCloudiness() * room.settings.sonnenUntergangRolloAdditionalOffsetPerCloudiness;
171
- }
168
+ this.sunsetShutterCallback.cloudOffset =
169
+ services_1.WeatherService.getCurrentCloudiness() * room.settings.sonnenUntergangRolloAdditionalOffsetPerCloudiness;
172
170
  this.sunsetShutterCallback.recalcNextToDo(new Date());
173
171
  }
174
172
  if (this.sunsetShutterCallback === undefined) {
@@ -16,7 +16,7 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
16
16
  protected _movementDetectedCallback: Array<(action: MotionSensorAction) => void>;
17
17
  protected _needsMovementResetFallback: boolean;
18
18
  protected _fallBackTimeout: NodeJS.Timeout | undefined;
19
- protected _timeSinceLastMotion: number;
19
+ protected _motionDetectedTimestamp: number;
20
20
  protected readonly _occupancyStateId: string;
21
21
  private _movementDetected;
22
22
  constructor(pInfo: IoBrokerDeviceInfo, type: DeviceType);
@@ -20,7 +20,7 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
20
20
  this._initialized = false;
21
21
  this._movementDetectedCallback = [];
22
22
  this._needsMovementResetFallback = true;
23
- this._timeSinceLastMotion = 0;
23
+ this._motionDetectedTimestamp = 0;
24
24
  this._occupancyStateId = 'occupancy';
25
25
  this._movementDetected = false;
26
26
  this.deviceCapabilities.push(enums_1.DeviceCapability.motionSensor);
@@ -60,7 +60,10 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
60
60
  // Time since last motion in seconds
61
61
  /** @inheritDoc */
62
62
  get timeSinceLastMotion() {
63
- return this._timeSinceLastMotion;
63
+ if (this._motionDetectedTimestamp === 0) {
64
+ return 0;
65
+ }
66
+ return (utils_1.Utils.nowMS() - this._motionDetectedTimestamp) / 1000;
64
67
  }
65
68
  /**
66
69
  * Adds a callback for when a motion state has changed.
@@ -83,6 +86,9 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
83
86
  }, 1000, this);
84
87
  return;
85
88
  }
89
+ else if (newState) {
90
+ this._motionDetectedTimestamp = utils_1.Utils.nowMS();
91
+ }
86
92
  if (newState === this._movementDetected) {
87
93
  this.log(enums_1.LogLevel.Debug, `Skip movement because state is already ${newState}`, enums_1.LogDebugType.SkipUnchangedMovementState);
88
94
  if (newState) {
@@ -120,10 +126,6 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
120
126
  this.log(enums_1.LogLevel.Trace, `Motion sensor: Update for motion state of ${this.info.customName}: ${state.val}`);
121
127
  this.updateMovement(state.val);
122
128
  break;
123
- case 'no_motion':
124
- this.log(state.val < 100 ? enums_1.LogLevel.Trace : enums_1.LogLevel.DeepTrace, `Motion sensor: Update for time since last motion of ${this.info.customName}: ${state.val}`);
125
- this._timeSinceLastMotion = state.val;
126
- break;
127
129
  }
128
130
  }
129
131
  resetFallbackTimeout() {
@@ -35,7 +35,7 @@ class TimeCallback {
35
35
  this.lastDone = new Date(0);
36
36
  }
37
37
  recalcNextToDo(now) {
38
- var _a;
38
+ var _a, _b;
39
39
  const today = new Date(now.getTime());
40
40
  today.setHours(0, 0, 0, 0);
41
41
  let nextCalculatedTime;
@@ -71,16 +71,13 @@ class TimeCallback {
71
71
  }
72
72
  break;
73
73
  case enums_1.TimeCallbackType.SunSet:
74
- if (this.nextToDo === undefined || this.lastDone.getDate() === this.calculationSunset.getDate()) {
74
+ if (this._calculationSunset === undefined ||
75
+ this.nextToDo === undefined ||
76
+ this.lastDone.getDate() === this.calculationSunset.getDate()) {
75
77
  this._calculationSunset = new Date(services_1.TimeCallbackService.nextSunSet.getTime());
76
78
  }
77
- if (this.cloudOffset === undefined) {
78
- this.cloudOffset = 0;
79
- }
80
- else {
81
- this.cloudOffset = this.cloudOffset * -1;
82
- }
83
- nextCalculatedTime = new Date(this.calculationSunset.getTime() + (this.minuteOffset + this.cloudOffset) * 60 * 1000);
79
+ (_a = this.cloudOffset) !== null && _a !== void 0 ? _a : (this.cloudOffset = 0);
80
+ nextCalculatedTime = new Date(this.calculationSunset.getTime() + (this.minuteOffset - this.cloudOffset) * 60 * 1000);
84
81
  if (this.sunTimeOffset) {
85
82
  const nextMaxSS = this.sunTimeOffset.getNextMaximumSunset(now);
86
83
  if (nextMaxSS < nextCalculatedTime && nextCalculatedTime.getDate() === nextMaxSS.getDate()) {
@@ -89,7 +86,7 @@ class TimeCallback {
89
86
  }
90
87
  break;
91
88
  }
92
- if (((_a = this.nextToDo) === null || _a === void 0 ? void 0 : _a.getTime()) == nextCalculatedTime.getTime()) {
89
+ if (((_b = this.nextToDo) === null || _b === void 0 ? void 0 : _b.getTime()) == nextCalculatedTime.getTime()) {
93
90
  // No change
94
91
  return;
95
92
  }