hoffmation-base 3.3.2 → 3.3.3

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.
@@ -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() {