hoffmation-base 3.2.3-alpha.5 → 3.2.3-alpha.6
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.
- package/lib/action/motionSensorAction.d.ts +2 -2
- package/lib/action/motionSensorAction.js +2 -2
- package/lib/api/api-service.d.ts +1 -0
- package/lib/api/api-service.js +10 -0
- package/lib/devices/CameraDevice.d.ts +4 -2
- package/lib/devices/CameraDevice.js +9 -5
- package/lib/interfaces/baseDevices/iCameraDevice.d.ts +4 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseAction } from './baseAction';
|
|
2
|
-
import { CommandType } from '../enums';
|
|
2
|
+
import { CommandSource, CommandType } from '../enums';
|
|
3
3
|
import { iMotionSensor } from '../interfaces';
|
|
4
4
|
export declare class MotionSensorAction extends BaseAction {
|
|
5
5
|
/** @inheritDoc */
|
|
@@ -12,5 +12,5 @@ export declare class MotionSensorAction extends BaseAction {
|
|
|
12
12
|
* The motion sensor that triggered the action
|
|
13
13
|
*/
|
|
14
14
|
readonly sensor: iMotionSensor;
|
|
15
|
-
constructor(sensor: iMotionSensor);
|
|
15
|
+
constructor(sensor: iMotionSensor, source?: CommandSource);
|
|
16
16
|
}
|
|
@@ -4,8 +4,8 @@ exports.MotionSensorAction = void 0;
|
|
|
4
4
|
const baseAction_1 = require("./baseAction");
|
|
5
5
|
const enums_1 = require("../enums");
|
|
6
6
|
class MotionSensorAction extends baseAction_1.BaseAction {
|
|
7
|
-
constructor(sensor) {
|
|
8
|
-
super(
|
|
7
|
+
constructor(sensor, source = enums_1.CommandSource.Automatic) {
|
|
8
|
+
super(source, `${sensor.customName} ${sensor.movementDetected ? 'detected' : 'cleared'} motion`);
|
|
9
9
|
/** @inheritDoc */
|
|
10
10
|
this.type = enums_1.CommandType.MotionSensorAction;
|
|
11
11
|
this.motionDetected = sensor.movementDetected;
|
package/lib/api/api-service.d.ts
CHANGED
|
@@ -156,6 +156,7 @@ export declare class API {
|
|
|
156
156
|
* @returns In case it failed the Error containing the reason
|
|
157
157
|
*/
|
|
158
158
|
static setRoomSettings(roomName: string, settings: Partial<DeviceSettings>): Error | null;
|
|
159
|
+
static cameraInformPersonDetected(deviceId: string): Error | void;
|
|
159
160
|
static getLastCameraImage(deviceId: string): Error | string;
|
|
160
161
|
static persistAllDeviceSettings(): void;
|
|
161
162
|
static loadAllDeviceSettingsFromDb(): void;
|
package/lib/api/api-service.js
CHANGED
|
@@ -370,6 +370,16 @@ class API {
|
|
|
370
370
|
r.settings.settingsContainer.persist(r);
|
|
371
371
|
return null;
|
|
372
372
|
}
|
|
373
|
+
static cameraInformPersonDetected(deviceId) {
|
|
374
|
+
const d = this.getDevice(deviceId);
|
|
375
|
+
if (d === undefined) {
|
|
376
|
+
return new Error(`Device with ID ${deviceId} not found`);
|
|
377
|
+
}
|
|
378
|
+
if (!d.deviceCapabilities.includes(enums_1.DeviceCapability.camera)) {
|
|
379
|
+
return new Error(`Device with ID ${deviceId} is no camera`);
|
|
380
|
+
}
|
|
381
|
+
d.setPersonDetected();
|
|
382
|
+
}
|
|
373
383
|
// TODO: Missing Comment
|
|
374
384
|
static getLastCameraImage(deviceId) {
|
|
375
385
|
const d = this.getDevice(deviceId);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { iBaseDevice, iCameraDevice, iCameraSettings } from '../interfaces';
|
|
2
|
-
import { LogDebugType, LogLevel } from '../enums';
|
|
2
|
+
import { CommandSource, LogDebugType, LogLevel } from '../enums';
|
|
3
3
|
import { MotionSensorAction } from '../action';
|
|
4
4
|
import { DeviceInfo } from './DeviceInfo';
|
|
5
5
|
import { RoomBaseDevice } from './RoomBaseDevice';
|
|
@@ -55,11 +55,13 @@ export declare abstract class CameraDevice extends RoomBaseDevice implements iCa
|
|
|
55
55
|
/** @inheritDoc */
|
|
56
56
|
blockForDevice(device: iBaseDevice, block: boolean): void;
|
|
57
57
|
/** @inheritDoc */
|
|
58
|
+
setPersonDetected(): void;
|
|
59
|
+
/** @inheritDoc */
|
|
58
60
|
persistMotionSensor(): void;
|
|
59
61
|
log(level: LogLevel, message: string, debugType?: LogDebugType): void;
|
|
60
62
|
private initializeMovementCounter;
|
|
61
63
|
protected onNewMotionDetectedValue(newValue: boolean): void;
|
|
62
|
-
protected onNewPersonDetectedValue(newValue: boolean): void;
|
|
64
|
+
protected onNewPersonDetectedValue(newValue: boolean, source?: CommandSource): void;
|
|
63
65
|
protected onNewImageSnapshot(image: string): void;
|
|
64
66
|
protected onNewDogDetectionValue(newDogDetectionVal: boolean): void;
|
|
65
67
|
protected abstract resetPersonDetectedState(): void;
|
|
@@ -94,6 +94,10 @@ class CameraDevice extends RoomBaseDevice_1.RoomBaseDevice {
|
|
|
94
94
|
this.log(enums_1.LogLevel.Debug, `Handle device ${block ? 'block' : 'unblock'}, new blocking amount: ${this._devicesBlockingAlarmMap.size}`);
|
|
95
95
|
}
|
|
96
96
|
/** @inheritDoc */
|
|
97
|
+
setPersonDetected() {
|
|
98
|
+
this.onNewPersonDetectedValue(true, enums_1.CommandSource.API);
|
|
99
|
+
}
|
|
100
|
+
/** @inheritDoc */
|
|
97
101
|
persistMotionSensor() {
|
|
98
102
|
var _a;
|
|
99
103
|
(_a = services_1.Persistence.dbo) === null || _a === void 0 ? void 0 : _a.persistMotionSensor(this);
|
|
@@ -133,7 +137,7 @@ class CameraDevice extends RoomBaseDevice_1.RoomBaseDevice {
|
|
|
133
137
|
this.resetMovementFallbackTimer();
|
|
134
138
|
}
|
|
135
139
|
}
|
|
136
|
-
onNewPersonDetectedValue(newValue) {
|
|
140
|
+
onNewPersonDetectedValue(newValue, source = enums_1.CommandSource.Automatic) {
|
|
137
141
|
this.log(enums_1.LogLevel.Debug, `Update for PersonDetected to value: ${newValue}`);
|
|
138
142
|
if (newValue) {
|
|
139
143
|
this.log(enums_1.LogLevel.Info, 'Person Detected');
|
|
@@ -141,7 +145,7 @@ class CameraDevice extends RoomBaseDevice_1.RoomBaseDevice {
|
|
|
141
145
|
}
|
|
142
146
|
this._personDetected = newValue;
|
|
143
147
|
if (this.settings.movementDetectionOnPersonOnly) {
|
|
144
|
-
this.updateMovement(newValue);
|
|
148
|
+
this.updateMovement(newValue, source);
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
onNewImageSnapshot(image) {
|
|
@@ -163,11 +167,11 @@ class CameraDevice extends RoomBaseDevice_1.RoomBaseDevice {
|
|
|
163
167
|
this.updateMovement(newDogDetectionVal);
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
|
-
updateMovement(newState) {
|
|
170
|
+
updateMovement(newState, source = enums_1.CommandSource.Automatic) {
|
|
167
171
|
if (!this._initialized && newState) {
|
|
168
172
|
this.log(enums_1.LogLevel.Trace, 'Movement recognized, but database initialization has not finished yet --> delay.');
|
|
169
173
|
utils_1.Utils.guardedTimeout(() => {
|
|
170
|
-
this.updateMovement(newState);
|
|
174
|
+
this.updateMovement(newState, source);
|
|
171
175
|
}, 1000, this);
|
|
172
176
|
return;
|
|
173
177
|
}
|
|
@@ -184,7 +188,7 @@ class CameraDevice extends RoomBaseDevice_1.RoomBaseDevice {
|
|
|
184
188
|
this.log(enums_1.LogLevel.Trace, `This is movement no. ${this.detectionsToday}`);
|
|
185
189
|
}
|
|
186
190
|
for (const c of this._movementDetectedCallback) {
|
|
187
|
-
c(new action_1.MotionSensorAction(this));
|
|
191
|
+
c(new action_1.MotionSensorAction(this, source));
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
resetPersonDetectFallbackTimer() {
|
|
@@ -47,4 +47,8 @@ export interface iCameraDevice extends iMotionSensor {
|
|
|
47
47
|
* @param block - Whether to block the alarm for the device or lift the block
|
|
48
48
|
*/
|
|
49
49
|
blockForDevice(device: iBaseDevice, block: boolean): void;
|
|
50
|
+
/**
|
|
51
|
+
* Externally trigger/set Person detected
|
|
52
|
+
*/
|
|
53
|
+
setPersonDetected(): void;
|
|
50
54
|
}
|