hoffmation-base 3.0.0-beta.9 → 3.0.0

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/README.md CHANGED
@@ -1,34 +1,60 @@
1
1
  # Hoffmation-Base
2
+
2
3
  [![DeepSource](https://deepsource.io/gh/theimo1221/Hoffmation-Base.svg/?label=active+issues&show_trend=true&token=Ec4T7omgYOMMc4ezxv_9bHk9)](https://deepsource.io/gh/theimo1221/Hoffmation-Base/?ref=repository-badge)
3
4
 
4
5
  A home automation library specialized for Zigbee and Homematic IP devices in combination with ioBroker.
6
+
5
7
  ## What does it do?
6
- This project serves as library for home automation projects. It provides services, models and utilities necessary to interact with rooms and smart devices via iobroker, but also to connect them to other services for textual/audio/visual notifications or really just any code or service you want the devices to connect to.
7
8
 
8
- Built on other open source projects that take care of the technical level, this project is made to provide a tool for the coding on the logical level. It is built as base to write automation code independent of the ioBroker user interface and currently provides support for the interaction with **devices** specified in [`src/server/devices`](src/server/devices) and **services** that can be found in [`src/server/services`](src/server/devices).
9
+ This project serves as library for home automation projects. It provides services, models and utilities necessary to
10
+ interact with rooms and smart devices via iobroker, but also to connect them to other services for textual/audio/visual
11
+ notifications or really just any code or service you want the devices to connect to.
12
+
13
+ Built on other open source projects that take care of the technical level, this project is made to provide a tool for
14
+ the coding on the logical level. It is built as base to write automation code independent of the ioBroker user interface
15
+ and currently provides support for the interaction with **devices** specified in [
16
+ `src/server/devices`](src/server/devices) and **services** that can be found in [
17
+ `src/server/services`](src/server/devices).
9
18
 
10
19
  Those include, but are not limited to:
11
20
 
12
- - **Devices**: Motion/Presence sensors, window handles, heating elements, lamps and dimmers, shutters, door contact sensors, physical buttons/switches, power sockets
21
+ - **Devices**: Motion/Presence sensors, window handles, heating elements, lamps and dimmers, shutters, door contact
22
+ sensors, physical buttons/switches, power sockets
13
23
  - **Services**: Interaction service for a telegram bot, weather, sonos control, waste calendar
14
24
 
25
+ ## Ecosystem Overview
26
+
27
+ ![Hoffmation.drawio.png](./Hoffmation.drawio.png)
28
+
15
29
  ## How can I use it?
16
- This library *can* be used in conjunction with or as addition to own base projects, but it's intended to be used with the configuration project [Hoffmation-Express](https://github.com/theimo1221/Hoffmation-Express) which uses this library via a [npm package](https://www.npmjs.com/package/hoffmation-base).
17
30
 
18
- Whether you use it with Hoffmation-Express or with your own controller code, make sure you pass a valid config file (see [`src/server/config/private`](src/server/config/private) for an example) and a valid ioBroker device tree (you can find more information about that in the Hoffmation-Express project).
31
+ This library *can* be used in conjunction with or as addition to own base projects, but it's intended to be used with
32
+ the configuration project [Hoffmation-Express](https://github.com/theimo1221/Hoffmation-Express) which uses this library
33
+ via a [npm package](https://www.npmjs.com/package/hoffmation-base).
34
+
35
+ Whether you use it with Hoffmation-Express or with your own controller code, make sure you pass a valid config file (
36
+ see [`src/server/config/private`](src/server/config/private) for an example) and a valid ioBroker device tree (you can
37
+ find more information about that in the Hoffmation-Express project).
19
38
 
20
39
  ### Base requirements
40
+
21
41
  In order to get the library running correctly, the following requirements should be met:
42
+
22
43
  * You use ioBroker for all devices that you want to control or read from
23
44
  Make sure you got the [socket.io](https://github.com/ioBroker/ioBroker.socketio) adapter installed
24
45
  * You use devices that are supported or are able to use one of the supported devices as base for yours.
25
- (If you use a Zigbee or Homematic IP device that is not currently supported, don't hesitate to create a pull request and add it!)
46
+ (If you use a Zigbee or Homematic IP device that is not currently supported, don't hesitate to create a pull request
47
+ and add it!)
26
48
  * You have a unix-based or windows device for the software you want to run this library with.
27
49
 
28
50
  ### Build
51
+
29
52
  To build the library, make sure [Node.js](https://nodejs.org/en/download/) is installed.
30
53
  Then, just run `npm run build`.
31
54
 
32
55
  ## Why would I use it?
33
- Even if it looks simple at first, automating your entire home with a user interface can sometimes be more difficult than just *coding* your home.
34
- Especially if you have a lot of specialized requirements that you want to satisfy, it can be simpler to just code your own rules and interfaces than to rely on user interfaces to do it for you.
56
+
57
+ Even if it looks simple at first, automating your entire home with a user interface can sometimes be more difficult than
58
+ just *coding* your home.
59
+ Especially if you have a lot of specialized requirements that you want to satisfy, it can be simpler to just code your
60
+ own rules and interfaces than to rely on user interfaces to do it for you.
@@ -16,6 +16,10 @@ export declare class CameraSettings extends MotionSensorSettings {
16
16
  * Whether the camera has audio.
17
17
  */
18
18
  hasAudio: boolean;
19
+ /**
20
+ * Whether the camera has a speaker.
21
+ */
22
+ hasSpeaker: boolean;
19
23
  fromPartialObject(data: Partial<CameraSettings>): void;
20
24
  protected toJSON(): Partial<MotionSensorSettings>;
21
25
  }
@@ -22,13 +22,18 @@ class CameraSettings extends motionSensorSettings_1.MotionSensorSettings {
22
22
  * Whether the camera has audio.
23
23
  */
24
24
  this.hasAudio = false;
25
+ /**
26
+ * Whether the camera has a speaker.
27
+ */
28
+ this.hasSpeaker = false;
25
29
  }
26
30
  fromPartialObject(data) {
27
- var _a, _b, _c, _d;
31
+ var _a, _b, _c, _d, _e;
28
32
  this.alertPersonOnTelegram = (_a = data.alertPersonOnTelegram) !== null && _a !== void 0 ? _a : this.alertPersonOnTelegram;
29
33
  this.movementDetectionOnPersonOnly = (_b = data.movementDetectionOnPersonOnly) !== null && _b !== void 0 ? _b : this.movementDetectionOnPersonOnly;
30
34
  this.movementDetectionOnDogsToo = (_c = data.movementDetectionOnDogsToo) !== null && _c !== void 0 ? _c : this.movementDetectionOnDogsToo;
31
35
  this.hasAudio = (_d = data.hasAudio) !== null && _d !== void 0 ? _d : this.hasAudio;
36
+ this.hasAudio = (_e = data.hasSpeaker) !== null && _e !== void 0 ? _e : this.hasSpeaker;
32
37
  super.fromPartialObject(data);
33
38
  }
34
39
  toJSON() {
@@ -12,6 +12,11 @@ export declare abstract class DeviceSettings extends ObjectSettings {
12
12
  * @default undefined
13
13
  */
14
14
  blockAutomaticSettings: BlockAutomaticSettings | undefined;
15
+ /**
16
+ * Whether to skip this device in Homebridge-Hoffmation
17
+ * @default false
18
+ */
19
+ skipInHomebridge: boolean;
15
20
  fromPartialObject(_obj: Partial<DeviceSettings>): void;
16
21
  protected toJSON(): Partial<DeviceSettings>;
17
22
  }
@@ -18,8 +18,14 @@ class DeviceSettings extends objectSettings_1.ObjectSettings {
18
18
  * @default undefined
19
19
  */
20
20
  this.blockAutomaticSettings = undefined;
21
+ /**
22
+ * Whether to skip this device in Homebridge-Hoffmation
23
+ * @default false
24
+ */
25
+ this.skipInHomebridge = false;
21
26
  }
22
27
  fromPartialObject(_obj) {
28
+ var _a;
23
29
  if (_obj.energySettings) {
24
30
  if (this.energySettings === undefined) {
25
31
  this.energySettings = new excessEnergyConsumerSettings_1.ExcessEnergyConsumerSettings();
@@ -32,6 +38,7 @@ class DeviceSettings extends objectSettings_1.ObjectSettings {
32
38
  }
33
39
  this.blockAutomaticSettings.fromPartialObject(_obj.blockAutomaticSettings);
34
40
  }
41
+ this.skipInHomebridge = (_a = _obj.skipInHomebridge) !== null && _a !== void 0 ? _a : this.skipInHomebridge;
35
42
  super.fromPartialObject(_obj);
36
43
  }
37
44
  toJSON() {
@@ -1,14 +1,10 @@
1
- import { iBaseDevice, iCameraDevice, iRoomDevice } from '../baseDeviceInterfaces';
2
- import { CameraSettings, LogLevel, MotionSensorAction, RoomBase } from '../../../models';
3
- import { LogDebugType } from '../../services';
4
- import { DeviceInfo } from '../DeviceInfo';
5
- import { DeviceCapability } from '../DeviceCapability';
6
- import { DeviceType } from '../deviceType';
7
- export declare class CameraDevice implements iCameraDevice {
8
- /**
9
- * The name of the camera in BlueIris
10
- */
11
- readonly blueIrisName: string;
1
+ import { iBaseDevice, iCameraDevice, iRoomDevice } from './baseDeviceInterfaces';
2
+ import { DeviceType } from './deviceType';
3
+ import { DeviceCapability } from './DeviceCapability';
4
+ import { CameraSettings, LogLevel, MotionSensorAction, RoomBase } from '../../models';
5
+ import { DeviceInfo } from './DeviceInfo';
6
+ import { LogDebugType } from '../services';
7
+ export declare abstract class CameraDevice implements iCameraDevice {
12
8
  /** @inheritDoc */
13
9
  settings: CameraSettings;
14
10
  /** @inheritDoc */
@@ -20,31 +16,28 @@ export declare class CameraDevice implements iCameraDevice {
20
16
  */
21
17
  readonly name: string;
22
18
  /** @inheritDoc */
23
- readonly mpegStreamLink: string;
19
+ abstract readonly mpegStreamLink: string;
24
20
  /** @inheritDoc */
25
- readonly h264IosStreamLink: string;
21
+ abstract readonly h264IosStreamLink: string;
26
22
  /** @inheritDoc */
27
- readonly rtspStreamLink: string;
23
+ abstract readonly rtspStreamLink: string;
28
24
  /** @inheritDoc */
29
- readonly currentImageLink: string;
25
+ abstract readonly currentImageLink: string;
30
26
  /** @inheritDoc */
31
27
  detectionsToday: number;
32
28
  protected _lastMotion: number;
29
+ protected _initialized: boolean;
30
+ protected _movementDetectedCallback: Array<(action: MotionSensorAction) => void>;
31
+ protected _lastImage: string;
32
+ protected _personDetected: boolean;
33
+ protected _dogDetected: boolean;
34
+ protected _devicesBlockingAlarmMap: Map<string, iBaseDevice>;
35
+ protected _movementDetected: boolean;
36
+ protected _info: DeviceInfo;
33
37
  private _personDetectFallbackTimeout;
34
38
  private _movementDetectFallbackTimeout;
35
39
  private _dogDetectFallbackTimeout;
36
- private _personDetectedStateId;
37
- private _dogDetectedStateId;
38
- private _movementDetectedStateId;
39
- private _initialized;
40
- private _movementDetectedCallback;
41
- private _lastImage;
42
- private _personDetected;
43
- private _dogDetected;
44
- private _devicesBlockingAlarmMap;
45
- private _movementDetected;
46
- private _info;
47
- constructor(mqttName: string, roomName: string, blueIrisName: string);
40
+ protected constructor(name: string, roomName: string);
48
41
  /** @inheritDoc */
49
42
  get lastImage(): string;
50
43
  /** @inheritDoc */
@@ -71,14 +64,19 @@ export declare class CameraDevice implements iCameraDevice {
71
64
  blockForDevice(device: iBaseDevice, block: boolean): void;
72
65
  /** @inheritDoc */
73
66
  persistMotionSensor(): void;
74
- /** @inheritDoc */
75
- update(idSplit: string[], state: ioBroker.State): void;
76
67
  log(level: LogLevel, message: string, debugType?: LogDebugType): void;
77
68
  toJSON(): Partial<iRoomDevice>;
78
69
  persistDeviceInfo(): void;
79
70
  loadDeviceSettings(): void;
71
+ protected onNewMotionDetectedValue(newValue: boolean): void;
72
+ protected onNewPersonDetectedValue(newValue: boolean): void;
73
+ protected onNewImageSnapshot(image: string): void;
74
+ protected onNewDogDetectionValue(newDogDetectionVal: boolean): void;
75
+ protected abstract resetPersonDetectedState(): void;
76
+ protected abstract resetDogDetectedState(): void;
77
+ protected abstract resetMovementDetectedState(): void;
80
78
  private updateMovement;
81
79
  private resetPersonDetectFallbackTimer;
82
- private resetDogDetectFallbackTimer;
83
80
  private resetMovementFallbackTimer;
81
+ private resetDogDetectFallbackTimer;
84
82
  }
@@ -4,17 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CameraDevice = void 0;
7
+ const deviceType_1 = require("./deviceType");
8
+ const DeviceCapability_1 = require("./DeviceCapability");
9
+ const models_1 = require("../../models");
10
+ const DeviceInfo_1 = require("./DeviceInfo");
11
+ const devices_1 = require("./devices");
12
+ const services_1 = require("../services");
7
13
  const lodash_1 = __importDefault(require("lodash"));
8
- const models_1 = require("../../../models");
9
- const blueIrisCoordinator_1 = require("./blueIrisCoordinator");
10
- const services_1 = require("../../services");
11
- const devices_1 = require("../devices");
12
- const DeviceInfo_1 = require("../DeviceInfo");
13
- const DeviceCapability_1 = require("../DeviceCapability");
14
- const deviceType_1 = require("../deviceType");
15
- const ioBroker_1 = require("../../ioBroker");
16
14
  class CameraDevice {
17
- constructor(mqttName, roomName, blueIrisName) {
15
+ constructor(name, roomName) {
18
16
  var _a;
19
17
  /** @inheritDoc */
20
18
  this.settings = new models_1.CameraSettings();
@@ -23,22 +21,8 @@ class CameraDevice {
23
21
  /** @inheritDoc */
24
22
  this.deviceType = deviceType_1.DeviceType.Camera;
25
23
  /** @inheritDoc */
26
- this.mpegStreamLink = '';
27
- /** @inheritDoc */
28
- this.h264IosStreamLink = '';
29
- /** @inheritDoc */
30
- this.rtspStreamLink = '';
31
- /** @inheritDoc */
32
- this.currentImageLink = '';
33
- /** @inheritDoc */
34
24
  this.detectionsToday = 0;
35
25
  this._lastMotion = 0;
36
- this._personDetectFallbackTimeout = null;
37
- this._movementDetectFallbackTimeout = null;
38
- this._dogDetectFallbackTimeout = null;
39
- this._personDetectedStateId = undefined;
40
- this._dogDetectedStateId = undefined;
41
- this._movementDetectedStateId = undefined;
42
26
  this._initialized = false;
43
27
  this._movementDetectedCallback = [];
44
28
  this._lastImage = '';
@@ -46,24 +30,18 @@ class CameraDevice {
46
30
  this._dogDetected = false;
47
31
  this._devicesBlockingAlarmMap = new Map();
48
32
  this._movementDetected = false;
49
- this.blueIrisName = blueIrisName;
50
- this.name = mqttName;
33
+ this._personDetectFallbackTimeout = null;
34
+ this._movementDetectFallbackTimeout = null;
35
+ this._dogDetectFallbackTimeout = null;
36
+ this.name = name;
51
37
  this._info = new DeviceInfo_1.DeviceInfo();
52
- this._info.fullName = `Camera ${roomName} ${mqttName}`;
53
- this._info.customName = `Camera ${mqttName}`;
38
+ this._info.fullName = `Camera ${roomName} ${name}`;
39
+ this._info.customName = `Camera ${name}`;
54
40
  this._info.room = roomName;
55
- this._info.allDevicesKey = `camera-${roomName}-${mqttName}`;
41
+ this._info.allDevicesKey = `camera-${roomName}-${name}`;
56
42
  devices_1.Devices.alLDevices[this._info.allDevicesKey] = this;
57
- blueIrisCoordinator_1.BlueIrisCoordinator.addDevice(this, mqttName);
58
43
  this.persistDeviceInfo();
59
44
  this.loadDeviceSettings();
60
- const blueIrisSettings = services_1.SettingsService.settings.blueIris;
61
- if (blueIrisSettings !== undefined) {
62
- this.mpegStreamLink = `${blueIrisSettings.serverAddress}/mjpg/${this.blueIrisName}/video.mjpg?user=${blueIrisSettings.username}&pw=${blueIrisSettings.password}`;
63
- this.h264IosStreamLink = `${blueIrisSettings.serverAddress}/h264/${this.blueIrisName}/temp.m?user=${blueIrisSettings.username}&pw=${blueIrisSettings.password}`;
64
- this.rtspStreamLink = `rtsp://${blueIrisSettings.username}:${blueIrisSettings.password}@${blueIrisSettings.serverAddress.replace('http://', '')}:80/${this.blueIrisName}`;
65
- this.currentImageLink = `${blueIrisSettings.serverAddress}/image/${this.blueIrisName}.jpg?q=100&s=100&user=${blueIrisSettings.username}&pw=${blueIrisSettings.password}`;
66
- }
67
45
  if (!services_1.Utils.anyDboActive) {
68
46
  this._initialized = true;
69
47
  }
@@ -139,58 +117,6 @@ class CameraDevice {
139
117
  var _a;
140
118
  (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistMotionSensor(this);
141
119
  }
142
- /** @inheritDoc */
143
- update(idSplit, state) {
144
- const stateName = idSplit[4];
145
- switch (stateName) {
146
- case 'MotionDetected':
147
- this._movementDetectedStateId = idSplit.join('.');
148
- if (this.settings.movementDetectionOnPersonOnly) {
149
- return;
150
- }
151
- this.log(models_1.LogLevel.Debug, `Update for "${stateName}" to value: ${state.val}`);
152
- const movementDetected = state.val === 1;
153
- this.updateMovement(movementDetected);
154
- if (movementDetected) {
155
- this.resetMovementFallbackTimer();
156
- }
157
- break;
158
- case 'PersonDetected':
159
- this._personDetectedStateId = idSplit.join('.');
160
- const newValue = state.val === 1;
161
- this.log(models_1.LogLevel.Debug, `Update for "${stateName}" to value: ${state.val}`);
162
- if (newValue) {
163
- this.log(models_1.LogLevel.Info, 'Person Detected');
164
- this.resetPersonDetectFallbackTimer();
165
- }
166
- this._personDetected = newValue;
167
- if (this.settings.movementDetectionOnPersonOnly) {
168
- this.updateMovement(newValue);
169
- }
170
- break;
171
- case 'DogDetected':
172
- this._dogDetectedStateId = idSplit.join('.');
173
- const newDogDetectionVal = state.val === 1;
174
- this.log(models_1.LogLevel.Debug, `Update for "${stateName}" to value: ${state.val}`);
175
- if (newDogDetectionVal) {
176
- this.log(models_1.LogLevel.Info, 'Dog Detected');
177
- this.resetDogDetectFallbackTimer();
178
- }
179
- this._dogDetected = newDogDetectionVal;
180
- if (this.settings.movementDetectionOnDogsToo) {
181
- this.updateMovement(newDogDetectionVal);
182
- }
183
- break;
184
- case 'MotionSnapshot':
185
- this._lastImage = state.val;
186
- services_1.Utils.guardedTimeout(() => {
187
- // Give Person Detected Update some time, as otherwise personDetected might still be false
188
- if (this.settings.alertPersonOnTelegram && this._personDetected && !this.alarmBlockedByDevices) {
189
- services_1.TelegramService.sendImage(`${this.name} detected Person`, new models_1.Base64Image(this._lastImage, 'person_alert'));
190
- }
191
- }, 1000);
192
- }
193
- }
194
120
  log(level, message, debugType = services_1.LogDebugType.None) {
195
121
  var _a, _b;
196
122
  services_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
@@ -216,6 +142,46 @@ class CameraDevice {
216
142
  var _a;
217
143
  (_a = this.settings) === null || _a === void 0 ? void 0 : _a.initializeFromDb(this);
218
144
  }
145
+ onNewMotionDetectedValue(newValue) {
146
+ if (this.settings.movementDetectionOnPersonOnly) {
147
+ return;
148
+ }
149
+ this.log(models_1.LogLevel.Debug, `Update for "Motion" to value: ${newValue}`);
150
+ this.updateMovement(newValue);
151
+ if (newValue) {
152
+ this.resetMovementFallbackTimer();
153
+ }
154
+ }
155
+ onNewPersonDetectedValue(newValue) {
156
+ this.log(models_1.LogLevel.Debug, `Update for PersonDetected to value: ${newValue}`);
157
+ if (newValue) {
158
+ this.log(models_1.LogLevel.Info, 'Person Detected');
159
+ this.resetPersonDetectFallbackTimer();
160
+ }
161
+ this._personDetected = newValue;
162
+ if (this.settings.movementDetectionOnPersonOnly) {
163
+ this.updateMovement(newValue);
164
+ }
165
+ }
166
+ onNewImageSnapshot(image) {
167
+ this._lastImage = image;
168
+ services_1.Utils.guardedTimeout(() => {
169
+ // Give Person Detected Update some time, as otherwise personDetected might still be false
170
+ if (this.settings.alertPersonOnTelegram && this._personDetected && !this.alarmBlockedByDevices) {
171
+ services_1.TelegramService.sendImage(`${this.name} detected Person`, new models_1.Base64Image(this._lastImage, 'person_alert'));
172
+ }
173
+ }, 1000);
174
+ }
175
+ onNewDogDetectionValue(newDogDetectionVal) {
176
+ if (newDogDetectionVal) {
177
+ this.log(models_1.LogLevel.Info, 'Dog Detected');
178
+ this.resetDogDetectFallbackTimer();
179
+ }
180
+ this._dogDetected = newDogDetectionVal;
181
+ if (this.settings.movementDetectionOnDogsToo) {
182
+ this.updateMovement(newDogDetectionVal);
183
+ }
184
+ }
219
185
  updateMovement(newState) {
220
186
  if (!this._initialized && newState) {
221
187
  this.log(models_1.LogLevel.Trace, 'Movement recognized, but database initialization has not finished yet --> delay.');
@@ -246,32 +212,12 @@ class CameraDevice {
246
212
  this._personDetectFallbackTimeout = null;
247
213
  }
248
214
  this._personDetectFallbackTimeout = services_1.Utils.guardedTimeout(() => {
249
- var _a;
250
215
  this._personDetectFallbackTimeout = null;
251
216
  this._personDetected = false;
252
217
  if (this.settings.movementDetectionOnPersonOnly) {
253
218
  this.updateMovement(false);
254
219
  }
255
- if (this._personDetectedStateId !== undefined) {
256
- (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._personDetectedStateId, { val: 0, ack: true });
257
- }
258
- }, 120000, this);
259
- }
260
- resetDogDetectFallbackTimer() {
261
- if (this._dogDetectFallbackTimeout !== null) {
262
- clearTimeout(this._dogDetectFallbackTimeout);
263
- this._dogDetectFallbackTimeout = null;
264
- }
265
- this._dogDetectFallbackTimeout = services_1.Utils.guardedTimeout(() => {
266
- var _a;
267
- this._dogDetectFallbackTimeout = null;
268
- this._dogDetected = false;
269
- if (this.settings.movementDetectionOnDogsToo) {
270
- this.updateMovement(false);
271
- }
272
- if (this._dogDetectedStateId !== undefined) {
273
- (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._dogDetectedStateId, { val: 0, ack: true });
274
- }
220
+ this.resetPersonDetectedState();
275
221
  }, 120000, this);
276
222
  }
277
223
  resetMovementFallbackTimer() {
@@ -280,7 +226,6 @@ class CameraDevice {
280
226
  this._movementDetectFallbackTimeout = null;
281
227
  }
282
228
  this._movementDetectFallbackTimeout = services_1.Utils.guardedTimeout(() => {
283
- var _a;
284
229
  this._movementDetectFallbackTimeout = null;
285
230
  if (!this._movementDetected) {
286
231
  // Der Fallback wird nicht benötigt, da bereits das Movement zurückgesetzt wurde
@@ -288,9 +233,21 @@ class CameraDevice {
288
233
  }
289
234
  this._movementDetected = false;
290
235
  this.updateMovement(false);
291
- if (this._movementDetectedStateId !== undefined) {
292
- (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._movementDetectedStateId, { val: 0, ack: true });
236
+ this.resetMovementDetectedState();
237
+ }, 120000, this);
238
+ }
239
+ resetDogDetectFallbackTimer() {
240
+ if (this._dogDetectFallbackTimeout !== null) {
241
+ clearTimeout(this._dogDetectFallbackTimeout);
242
+ this._dogDetectFallbackTimeout = null;
243
+ }
244
+ this._dogDetectFallbackTimeout = services_1.Utils.guardedTimeout(() => {
245
+ this._dogDetectFallbackTimeout = null;
246
+ this._dogDetected = false;
247
+ if (this.settings.movementDetectionOnDogsToo) {
248
+ this.updateMovement(false);
293
249
  }
250
+ this.resetDogDetectedState();
294
251
  }, 120000, this);
295
252
  }
296
253
  }
@@ -47,11 +47,4 @@ 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
- * Inform this camera of state updates within iOBroker
52
- * TODO: Make camera independent of iOBroker
53
- * @param idSplit - The id split of the state
54
- * @param state - The state that has been updated
55
- */
56
- update(idSplit: string[], state: ioBroker.State): void;
57
50
  }
@@ -4,6 +4,7 @@ export * from './iBaseDevice';
4
4
  export * from './iBatteryDevice';
5
5
  export * from './iButtonSwitch';
6
6
  export * from './iCameraDevice';
7
+ export * from './iDimmableLamp';
7
8
  export * from './iEnergyManager';
8
9
  export * from './iExcessEnergyConsumer';
9
10
  export * from './iGarageDoorOpener';
@@ -20,6 +20,7 @@ __exportStar(require("./iBaseDevice"), exports);
20
20
  __exportStar(require("./iBatteryDevice"), exports);
21
21
  __exportStar(require("./iButtonSwitch"), exports);
22
22
  __exportStar(require("./iCameraDevice"), exports);
23
+ __exportStar(require("./iDimmableLamp"), exports);
23
24
  __exportStar(require("./iEnergyManager"), exports);
24
25
  __exportStar(require("./iExcessEnergyConsumer"), exports);
25
26
  __exportStar(require("./iGarageDoorOpener"), exports);
@@ -0,0 +1,28 @@
1
+ import { CameraDevice } from '../CameraDevice';
2
+ export declare class BlueIrisCameraDevice extends CameraDevice {
3
+ /**
4
+ * The name of the camera in BlueIris
5
+ */
6
+ readonly blueIrisName: string;
7
+ /** @inheritDoc */
8
+ readonly mpegStreamLink: string;
9
+ /** @inheritDoc */
10
+ readonly h264IosStreamLink: string;
11
+ /** @inheritDoc */
12
+ readonly rtspStreamLink: string;
13
+ /** @inheritDoc */
14
+ readonly currentImageLink: string;
15
+ private _personDetectedStateId;
16
+ private _dogDetectedStateId;
17
+ private _movementDetectedStateId;
18
+ constructor(mqttName: string, roomName: string, blueIrisName: string);
19
+ /**
20
+ * Inform this camera of state updates within iOBroker
21
+ * @param idSplit - The id split of the state
22
+ * @param state - The state that has been updated
23
+ */
24
+ update(idSplit: string[], state: ioBroker.State): void;
25
+ protected resetPersonDetectedState(): void;
26
+ protected resetDogDetectedState(): void;
27
+ protected resetMovementDetectedState(): void;
28
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlueIrisCameraDevice = void 0;
4
+ const models_1 = require("../../../models");
5
+ const blueIrisCoordinator_1 = require("./blueIrisCoordinator");
6
+ const services_1 = require("../../services");
7
+ const ioBroker_1 = require("../../ioBroker");
8
+ const CameraDevice_1 = require("../CameraDevice");
9
+ class BlueIrisCameraDevice extends CameraDevice_1.CameraDevice {
10
+ constructor(mqttName, roomName, blueIrisName) {
11
+ super(mqttName, roomName);
12
+ /** @inheritDoc */
13
+ this.mpegStreamLink = '';
14
+ /** @inheritDoc */
15
+ this.h264IosStreamLink = '';
16
+ /** @inheritDoc */
17
+ this.rtspStreamLink = '';
18
+ /** @inheritDoc */
19
+ this.currentImageLink = '';
20
+ this._personDetectedStateId = undefined;
21
+ this._dogDetectedStateId = undefined;
22
+ this._movementDetectedStateId = undefined;
23
+ this.blueIrisName = blueIrisName;
24
+ blueIrisCoordinator_1.BlueIrisCoordinator.addDevice(this, mqttName);
25
+ const blueIrisSettings = services_1.SettingsService.settings.blueIris;
26
+ if (blueIrisSettings !== undefined) {
27
+ this.mpegStreamLink = `${blueIrisSettings.serverAddress}/mjpg/${this.blueIrisName}/video.mjpg?user=${blueIrisSettings.username}&pw=${blueIrisSettings.password}`;
28
+ this.h264IosStreamLink = `${blueIrisSettings.serverAddress}/h264/${this.blueIrisName}/temp.m?user=${blueIrisSettings.username}&pw=${blueIrisSettings.password}`;
29
+ this.rtspStreamLink = `rtsp://${blueIrisSettings.username}:${blueIrisSettings.password}@${blueIrisSettings.serverAddress.replace('http://', '')}:80/${this.blueIrisName}`;
30
+ this.currentImageLink = `${blueIrisSettings.serverAddress}/image/${this.blueIrisName}.jpg?q=100&s=100&user=${blueIrisSettings.username}&pw=${blueIrisSettings.password}`;
31
+ }
32
+ }
33
+ /**
34
+ * Inform this camera of state updates within iOBroker
35
+ * @param idSplit - The id split of the state
36
+ * @param state - The state that has been updated
37
+ */
38
+ update(idSplit, state) {
39
+ const stateName = idSplit[4];
40
+ switch (stateName) {
41
+ case 'MotionDetected':
42
+ this._movementDetectedStateId = idSplit.join('.');
43
+ this.onNewMotionDetectedValue(state.val === 1);
44
+ break;
45
+ case 'PersonDetected':
46
+ this._personDetectedStateId = idSplit.join('.');
47
+ const newValue = state.val === 1;
48
+ this.onNewPersonDetectedValue(newValue);
49
+ break;
50
+ case 'DogDetected':
51
+ this._dogDetectedStateId = idSplit.join('.');
52
+ const newDogDetectionVal = state.val === 1;
53
+ this.log(models_1.LogLevel.Debug, `Update for "${stateName}" to value: ${state.val}`);
54
+ this.onNewDogDetectionValue(newDogDetectionVal);
55
+ break;
56
+ case 'MotionSnapshot':
57
+ this.onNewImageSnapshot(state.val);
58
+ break;
59
+ }
60
+ }
61
+ resetPersonDetectedState() {
62
+ var _a;
63
+ if (this._personDetectedStateId !== undefined) {
64
+ (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._personDetectedStateId, { val: 0, ack: true });
65
+ }
66
+ }
67
+ resetDogDetectedState() {
68
+ var _a;
69
+ if (this._dogDetectedStateId !== undefined) {
70
+ (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._dogDetectedStateId, { val: 0, ack: true });
71
+ }
72
+ }
73
+ resetMovementDetectedState() {
74
+ var _a;
75
+ if (this._movementDetectedStateId !== undefined) {
76
+ (_a = ioBroker_1.ioBrokerMain.iOConnection) === null || _a === void 0 ? void 0 : _a.setState(this._movementDetectedStateId, { val: 0, ack: true });
77
+ }
78
+ }
79
+ }
80
+ exports.BlueIrisCameraDevice = BlueIrisCameraDevice;
@@ -1,2 +1,2 @@
1
1
  export * from './blueIrisCoordinator';
2
- export * from './cameraDevice';
2
+ export * from './blueIrisCameraDevice';
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./blueIrisCoordinator"), exports);
18
- __exportStar(require("./cameraDevice"), exports);
18
+ __exportStar(require("./blueIrisCameraDevice"), exports);
@@ -33,6 +33,8 @@ const _ = __importStar(require("lodash"));
33
33
  const keyTemplates_1 = __importDefault(require("./keyTemplates"));
34
34
  const services_1 = require("../../../services");
35
35
  const models_1 = require("../../../../models");
36
+ const http = __importStar(require("node:http"));
37
+ const https = __importStar(require("node:https"));
36
38
  /**
37
39
  * axios HTTP Client Class
38
40
  * - with some prepared fetch functions for data
@@ -47,6 +49,8 @@ class DachsHttpClient {
47
49
  this.options = options;
48
50
  //combine parameter to baseUrl
49
51
  //check http prefix
52
+ axios_1.default.defaults.httpsAgent = new https.Agent({ keepAlive: false });
53
+ axios_1.default.defaults.httpAgent = new http.Agent({ keepAlive: false });
50
54
  const protocol = options.protocol ? options.protocol : 'http';
51
55
  this.options.host = this.options.host.startsWith('http') ? this.options.host : `${protocol}://${this.options.host}`;
52
56
  //combine all parameter for url