hoffmation-base 3.0.0-beta.8 → 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 +34 -8
- package/lib/models/action/handleChangeAction.d.ts +12 -0
- package/lib/models/action/handleChangeAction.js +15 -0
- package/lib/models/action/index.d.ts +1 -0
- package/lib/models/action/index.js +3 -1
- package/lib/models/command/commandType.d.ts +1 -0
- package/lib/models/command/commandType.js +1 -0
- package/lib/models/deviceSettings/cameraSettings.d.ts +4 -0
- package/lib/models/deviceSettings/cameraSettings.js +6 -1
- package/lib/models/deviceSettings/deviceSettings.d.ts +5 -0
- package/lib/models/deviceSettings/deviceSettings.js +7 -0
- package/lib/server/devices/{blueIris/cameraDevice.d.ts → CameraDevice.d.ts} +28 -30
- package/lib/server/devices/{blueIris/cameraDevice.js → CameraDevice.js} +69 -112
- package/lib/server/devices/baseDeviceInterfaces/iCameraDevice.d.ts +0 -7
- package/lib/server/devices/baseDeviceInterfaces/iHandleSensor.d.ts +6 -0
- package/lib/server/devices/baseDeviceInterfaces/iHeater.d.ts +10 -1
- package/lib/server/devices/baseDeviceInterfaces/index.d.ts +1 -0
- package/lib/server/devices/baseDeviceInterfaces/index.js +1 -0
- package/lib/server/devices/blueIris/blueIrisCameraDevice.d.ts +28 -0
- package/lib/server/devices/blueIris/blueIrisCameraDevice.js +80 -0
- package/lib/server/devices/blueIris/index.d.ts +1 -1
- package/lib/server/devices/blueIris/index.js +1 -1
- package/lib/server/devices/dachs/lib/dachsHttpClient.js +4 -0
- package/lib/server/devices/groups/Window.d.ts +7 -1
- package/lib/server/devices/groups/Window.js +15 -1
- package/lib/server/devices/groups/heatGroup.js +6 -0
- package/lib/server/devices/groups/windowGroup.d.ts +11 -1
- package/lib/server/devices/groups/windowGroup.js +18 -0
- package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +3 -0
- package/lib/server/devices/hmIPDevices/hmIpGriff.js +4 -0
- package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.d.ts +7 -1
- package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.js +24 -0
- package/lib/server/devices/index.d.ts +1 -0
- package/lib/server/devices/index.js +1 -0
- package/lib/server/devices/sharedFunctions/handleSensor.d.ts +3 -2
- package/lib/server/devices/sharedFunctions/handleSensor.js +8 -0
- package/lib/server/devices/shelly/shellyTrv.d.ts +7 -1
- package/lib/server/devices/shelly/shellyTrv.js +24 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.d.ts +7 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +24 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeWindowHandle.d.ts +3 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeWindowHandle.js +4 -0
- package/lib/server/services/dbo/postgreSqlPersist.js +82 -64
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,34 +1,60 @@
|
|
|
1
1
|
# Hoffmation-Base
|
|
2
|
+
|
|
2
3
|
[](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
|
-
|
|
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
|
|
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
|
+

|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
34
|
-
|
|
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.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseAction } from './baseAction';
|
|
2
|
+
import { CommandType } from '../command';
|
|
3
|
+
import { iHandleSensor } from '../../server';
|
|
4
|
+
export declare class HandleChangeAction extends BaseAction {
|
|
5
|
+
/** @inheritDoc */
|
|
6
|
+
type: CommandType;
|
|
7
|
+
/**
|
|
8
|
+
* The window-handle that triggered the action
|
|
9
|
+
*/
|
|
10
|
+
readonly handle: iHandleSensor;
|
|
11
|
+
constructor(handle: iHandleSensor);
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandleChangeAction = void 0;
|
|
4
|
+
const baseAction_1 = require("./baseAction");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const server_1 = require("../../server");
|
|
7
|
+
class HandleChangeAction extends baseAction_1.BaseAction {
|
|
8
|
+
constructor(handle) {
|
|
9
|
+
super(undefined, `${handle.customName} ${handle.position === server_1.WindowPosition.closed ? 'opened' : 'closed'}`);
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
this.type = command_1.CommandType.HandleChangedAction;
|
|
12
|
+
this.handle = handle;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.HandleChangeAction = HandleChangeAction;
|
|
@@ -8,3 +8,4 @@ export * from './temperatureSensorChangeAction';
|
|
|
8
8
|
export { ActuatorChangeAction } from './actuatorChangeAction';
|
|
9
9
|
export { BatteryLevelChangeAction } from './batteryLevelChangeAction';
|
|
10
10
|
export { PresenceGroupAnyMovementAction } from './presenceGroupAnyMovementAction';
|
|
11
|
+
export { HandleChangeAction } from './handleChangeAction';
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PresenceGroupAnyMovementAction = exports.BatteryLevelChangeAction = exports.ActuatorChangeAction = exports.BaseAction = void 0;
|
|
17
|
+
exports.HandleChangeAction = exports.PresenceGroupAnyMovementAction = exports.BatteryLevelChangeAction = exports.ActuatorChangeAction = exports.BaseAction = void 0;
|
|
18
18
|
var baseAction_1 = require("./baseAction");
|
|
19
19
|
Object.defineProperty(exports, "BaseAction", { enumerable: true, get: function () { return baseAction_1.BaseAction; } });
|
|
20
20
|
__exportStar(require("./humiditySensorChangeAction"), exports);
|
|
@@ -29,3 +29,5 @@ var batteryLevelChangeAction_1 = require("./batteryLevelChangeAction");
|
|
|
29
29
|
Object.defineProperty(exports, "BatteryLevelChangeAction", { enumerable: true, get: function () { return batteryLevelChangeAction_1.BatteryLevelChangeAction; } });
|
|
30
30
|
var presenceGroupAnyMovementAction_1 = require("./presenceGroupAnyMovementAction");
|
|
31
31
|
Object.defineProperty(exports, "PresenceGroupAnyMovementAction", { enumerable: true, get: function () { return presenceGroupAnyMovementAction_1.PresenceGroupAnyMovementAction; } });
|
|
32
|
+
var handleChangeAction_1 = require("./handleChangeAction");
|
|
33
|
+
Object.defineProperty(exports, "HandleChangeAction", { enumerable: true, get: function () { return handleChangeAction_1.HandleChangeAction; } });
|
|
@@ -28,6 +28,7 @@ export declare enum CommandType {
|
|
|
28
28
|
ShutterSunriseUpCommand = "ShutterSunriseUpCommand",
|
|
29
29
|
SunsetDownCommand = "SunsetDownCommand",
|
|
30
30
|
TemperatureSensorChangeAction = "TemperatureSensorChangeAction",
|
|
31
|
+
HandleChangedAction = "HandleChangedAction",
|
|
31
32
|
WindowRestoreDesiredPositionCommand = "WindowRestoreDesiredPositionCommand",
|
|
32
33
|
WindowSetDesiredPositionCommand = "WindowSetDesiredPositionCommand",
|
|
33
34
|
WindowSetRolloByWeatherStatusCommand = "WindowSetRolloByWeatherStatusCommand",
|
|
@@ -32,6 +32,7 @@ var CommandType;
|
|
|
32
32
|
CommandType["ShutterSunriseUpCommand"] = "ShutterSunriseUpCommand";
|
|
33
33
|
CommandType["SunsetDownCommand"] = "SunsetDownCommand";
|
|
34
34
|
CommandType["TemperatureSensorChangeAction"] = "TemperatureSensorChangeAction";
|
|
35
|
+
CommandType["HandleChangedAction"] = "HandleChangedAction";
|
|
35
36
|
CommandType["WindowRestoreDesiredPositionCommand"] = "WindowRestoreDesiredPositionCommand";
|
|
36
37
|
CommandType["WindowSetDesiredPositionCommand"] = "WindowSetDesiredPositionCommand";
|
|
37
38
|
CommandType["WindowSetRolloByWeatherStatusCommand"] = "WindowSetRolloByWeatherStatusCommand";
|
|
@@ -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 '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
-
|
|
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(
|
|
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.
|
|
50
|
-
this.
|
|
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} ${
|
|
53
|
-
this._info.customName = `Camera ${
|
|
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}-${
|
|
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
|
-
|
|
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
|
-
|
|
292
|
-
|
|
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
|
}
|
|
@@ -2,6 +2,7 @@ import { WindowPosition } from '../models';
|
|
|
2
2
|
import { iRoomDevice } from './iRoomDevice';
|
|
3
3
|
import { HandleSensor } from '../sharedFunctions';
|
|
4
4
|
import { Window } from '../groups';
|
|
5
|
+
import { HandleChangeAction } from '../../../models';
|
|
5
6
|
/**
|
|
6
7
|
* Interface for Handle Sensors.
|
|
7
8
|
* A handle sensor can be any device that is capable of detecting the position of a window handle e.g. a sensor, a window handle, etc.
|
|
@@ -40,4 +41,9 @@ export interface iHandleSensor extends iRoomDevice {
|
|
|
40
41
|
* @param pCallback - The callback to fire
|
|
41
42
|
*/
|
|
42
43
|
addClosedCallback(pCallback: (pValue: boolean) => void): void;
|
|
44
|
+
/**
|
|
45
|
+
* Add a callback that is called when the handle is changed to any position
|
|
46
|
+
* @param cb - The callback to fire
|
|
47
|
+
*/
|
|
48
|
+
addHandleChangeCallback(cb: (handleChangeAction: HandleChangeAction) => void): void;
|
|
43
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HeaterSettings } from '../../../models';
|
|
1
|
+
import { HandleChangeAction, HeaterSettings } from '../../../models';
|
|
2
2
|
import { iRoomDevice } from './iRoomDevice';
|
|
3
3
|
import { iDisposable } from '../../services';
|
|
4
4
|
import { iTemperatureSensor } from './iTemperatureSensor';
|
|
@@ -29,6 +29,10 @@ export interface iHeater extends iTemperatureSensor, iRoomDevice, iDisposable {
|
|
|
29
29
|
* Whether the heater is currently in a season turnoff state (no heating in summer)
|
|
30
30
|
*/
|
|
31
31
|
seasonTurnOff: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether any window in the room is open.
|
|
34
|
+
*/
|
|
35
|
+
readonly windowOpen: boolean;
|
|
32
36
|
/**
|
|
33
37
|
* Perform a check to calculate the new desired heater state
|
|
34
38
|
*/
|
|
@@ -37,4 +41,9 @@ export interface iHeater extends iTemperatureSensor, iRoomDevice, iDisposable {
|
|
|
37
41
|
* Persists the current heater information to the database
|
|
38
42
|
*/
|
|
39
43
|
persistHeater(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Called when a window handle in the room changes its state
|
|
46
|
+
* @param action
|
|
47
|
+
*/
|
|
48
|
+
onHandleChange(action: HandleChangeAction): void;
|
|
40
49
|
}
|
|
@@ -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);
|