hoffmation-base 2.18.6 → 2.18.7

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.
@@ -10,5 +10,5 @@ export interface iCameraDevice extends iMotionSensor {
10
10
  readonly alarmBlockedByGriff: boolean;
11
11
  readonly alarmBlockedByGriffTimeStamp: number;
12
12
  onGriffUpdate(open: boolean): void;
13
- update(stateName: string, state: ioBroker.State): void;
13
+ update(idSplit: string[], state: ioBroker.State): void;
14
14
  }
@@ -17,7 +17,7 @@ class BlueIrisCoordinator {
17
17
  services_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Unknown Blue Iris Device "${devName}"`);
18
18
  return;
19
19
  }
20
- dev.update(idSplit[4], state);
20
+ dev.update(idSplit, state);
21
21
  }
22
22
  }
23
23
  exports.BlueIrisCoordinator = BlueIrisCoordinator;
@@ -6,6 +6,10 @@ import { DeviceCapability } from '../DeviceCapability';
6
6
  import { DeviceType } from '../deviceType';
7
7
  export declare class CameraDevice implements iCameraDevice {
8
8
  readonly blueIrisName: string;
9
+ private _personDetectFallbackTimeout;
10
+ private _movementDetectFallbackTimeout;
11
+ private _personDetectedStateId;
12
+ private _movementDetectedStateId;
9
13
  get lastImage(): string;
10
14
  settings: CameraSettings;
11
15
  readonly deviceCapabilities: DeviceCapability[];
@@ -48,10 +52,12 @@ export declare class CameraDevice implements iCameraDevice {
48
52
  addMovementCallback(pCallback: (newState: boolean) => void): void;
49
53
  onGriffUpdate(open: boolean): void;
50
54
  persistMotionSensor(): void;
51
- update(stateName: string, state: ioBroker.State): void;
55
+ update(idSplit: string[], state: ioBroker.State): void;
52
56
  updateMovement(newState: boolean): void;
53
57
  log(level: LogLevel, message: string, debugType?: LogDebugType): void;
54
58
  toJSON(): Partial<iRoomDevice>;
55
59
  persistDeviceInfo(): void;
56
60
  loadDeviceSettings(): void;
61
+ private resetPersonDetectFallbackTimer;
62
+ private resetMovementFallbackTimer;
57
63
  }
@@ -12,6 +12,7 @@ const devices_1 = require("../devices");
12
12
  const DeviceInfo_1 = require("../DeviceInfo");
13
13
  const DeviceCapability_1 = require("../DeviceCapability");
14
14
  const deviceType_1 = require("../deviceType");
15
+ const ioBroker_1 = require("../../ioBroker");
15
16
  class CameraDevice {
16
17
  get lastImage() {
17
18
  return this._lastImage;
@@ -24,6 +25,10 @@ class CameraDevice {
24
25
  }
25
26
  constructor(mqttName, roomName, blueIrisName) {
26
27
  var _a;
28
+ this._personDetectFallbackTimeout = null;
29
+ this._movementDetectFallbackTimeout = null;
30
+ this._personDetectedStateId = undefined;
31
+ this._movementDetectedStateId = undefined;
27
32
  this.settings = new models_1.CameraSettings();
28
33
  this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.camera, DeviceCapability_1.DeviceCapability.motionSensor];
29
34
  this.deviceType = deviceType_1.DeviceType.Camera;
@@ -126,19 +131,27 @@ class CameraDevice {
126
131
  var _a;
127
132
  (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistMotionSensor(this);
128
133
  }
129
- update(stateName, state) {
134
+ update(idSplit, state) {
135
+ const stateName = idSplit[4];
130
136
  this.log(models_1.LogLevel.Debug, `Update for "${stateName}"`);
131
137
  switch (stateName) {
132
138
  case 'MotionDetected':
139
+ this._movementDetectedStateId = idSplit.join('.');
133
140
  if (this.settings.movementDetectionOnPersonOnly) {
134
141
  return;
135
142
  }
136
- this.updateMovement(state.val === 1);
143
+ const movementDetected = state.val === 1;
144
+ this.updateMovement(movementDetected);
145
+ if (movementDetected) {
146
+ this.resetMovementFallbackTimer();
147
+ }
137
148
  break;
138
149
  case 'PersonDetected':
150
+ this._personDetectedStateId = idSplit.join('.');
139
151
  const newValue = state.val === 1;
140
152
  if (newValue) {
141
153
  this.log(models_1.LogLevel.Info, `Person Detected`);
154
+ this.resetPersonDetectFallbackTimer();
142
155
  }
143
156
  this._personDetected = newValue;
144
157
  if (this.settings.movementDetectionOnPersonOnly) {
@@ -204,5 +217,37 @@ class CameraDevice {
204
217
  var _a;
205
218
  (_a = this.settings) === null || _a === void 0 ? void 0 : _a.initializeFromDb(this);
206
219
  }
220
+ resetPersonDetectFallbackTimer() {
221
+ if (this._personDetectFallbackTimeout !== null) {
222
+ clearTimeout(this._personDetectFallbackTimeout);
223
+ this._personDetectFallbackTimeout = null;
224
+ }
225
+ this._personDetectFallbackTimeout = services_1.Utils.guardedTimeout(() => {
226
+ var _a;
227
+ this._personDetectFallbackTimeout = null;
228
+ this._personDetected = false;
229
+ if (this.settings.movementDetectionOnPersonOnly) {
230
+ this.updateMovement(false);
231
+ }
232
+ if (this._personDetectedStateId !== undefined) {
233
+ (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._personDetectedStateId, { val: 0, ack: true });
234
+ }
235
+ }, 120000, this);
236
+ }
237
+ resetMovementFallbackTimer() {
238
+ if (this._movementDetectFallbackTimeout !== null) {
239
+ clearTimeout(this._movementDetectFallbackTimeout);
240
+ this._movementDetectFallbackTimeout = null;
241
+ }
242
+ this._movementDetectFallbackTimeout = services_1.Utils.guardedTimeout(() => {
243
+ var _a;
244
+ this._movementDetectFallbackTimeout = null;
245
+ this._movementDetected = false;
246
+ this.updateMovement(false);
247
+ if (this._movementDetectedStateId !== undefined) {
248
+ (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._movementDetectedStateId, { val: 0, ack: true });
249
+ }
250
+ }, 120000, this);
251
+ }
207
252
  }
208
253
  exports.CameraDevice = CameraDevice;