hoffmation-base 3.2.28 → 3.2.30
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/devices/espresense/trilateration.d.ts +2 -3
- package/lib/devices/espresense/trilateration.js +2 -0
- package/lib/devices/espresense/trilaterationPoint.d.ts +3 -1
- package/lib/devices/espresense/trilaterationPoint.js +10 -0
- package/lib/interfaces/iRoomBase.d.ts +9 -0
- package/lib/interfaces/iRoomSettings.d.ts +9 -0
- package/lib/interfaces/iTrilaterationPoint.d.ts +4 -0
- package/lib/models/rooms/RoomSettings/RoomSettingsController.d.ts +2 -2
- package/lib/models/rooms/RoomSettings/RoomSettingsController.js +13 -3
- package/lib/models/rooms/RoomSettings/roomSettings.d.ts +5 -1
- package/lib/models/rooms/RoomSettings/roomSettings.js +4 -2
- package/lib/services/RoomBase.js +1 -4
- package/lib/settingsObjects/objectSettings.d.ts +4 -0
- package/lib/settingsObjects/objectSettings.js +2 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { iTrilaterationBasePoint, iTrilaterationPoint, iTrilaterationPointDistance } from '../../interfaces';
|
|
1
|
+
import { iRoomBase, iTrilaterationBasePoint, iTrilaterationPoint, iTrilaterationPointDistance } from '../../interfaces';
|
|
3
2
|
export declare class Trilateration {
|
|
4
3
|
/**
|
|
5
4
|
* A list of all reference points for trilateration (e.g. Rooms, {@link iBluetoothDetector}s)
|
|
@@ -10,7 +9,7 @@ export declare class Trilateration {
|
|
|
10
9
|
* This list is filled mostly by {@link Trilateration.addRoom} thus resulting in the air outside the house not being included
|
|
11
10
|
*/
|
|
12
11
|
static possiblePoints: iTrilaterationPoint[];
|
|
13
|
-
static addRoom(room:
|
|
12
|
+
static addRoom(room: iRoomBase, startPoint: iTrilaterationPoint, endPoint: iTrilaterationPoint): void;
|
|
14
13
|
static initialize(): void;
|
|
15
14
|
static getBestMatches(distances: iTrilaterationPointDistance[]): iTrilaterationPoint[];
|
|
16
15
|
static checkRoom(distances: iTrilaterationPointDistance[]): string | undefined;
|
|
@@ -8,6 +8,8 @@ class Trilateration {
|
|
|
8
8
|
static addRoom(room, startPoint, endPoint) {
|
|
9
9
|
const points = trilaterationPoint_1.TrilaterationPoint.getPointsInRange(startPoint, endPoint, room.roomName);
|
|
10
10
|
logging_1.ServerLogService.writeLog(enums_1.LogLevel.Debug, `Adding ${points.length} trilateration points for room ${room.roomName} from ${startPoint.coordinateName} to ${endPoint.coordinateName}`);
|
|
11
|
+
// Remove all points from this room
|
|
12
|
+
this.possiblePoints = this.possiblePoints.filter((point) => point.roomName !== room.roomName);
|
|
11
13
|
this.possiblePoints.push(...points);
|
|
12
14
|
}
|
|
13
15
|
static initialize() {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { iTrilaterationPoint } from '../../interfaces';
|
|
1
|
+
import { iTrilaterationCoordinate, iTrilaterationPoint } from '../../interfaces';
|
|
2
2
|
export declare class TrilaterationPoint implements iTrilaterationPoint {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
5
5
|
z: number;
|
|
6
6
|
roomName: string;
|
|
7
|
+
static byCoordinate(coordinate: iTrilaterationCoordinate, roomName: string): TrilaterationPoint;
|
|
7
8
|
static getPointsInRange(a: iTrilaterationPoint, b: iTrilaterationPoint, roomName?: string): TrilaterationPoint[];
|
|
8
9
|
constructor(x: number, y: number, z: number, roomName: string);
|
|
9
10
|
get coordinateName(): string;
|
|
10
11
|
getDistance(other: iTrilaterationPoint): number;
|
|
11
12
|
getDot5Distance(other: iTrilaterationPoint): number;
|
|
13
|
+
getCoordinate(): iTrilaterationCoordinate;
|
|
12
14
|
}
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TrilaterationPoint = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
class TrilaterationPoint {
|
|
6
|
+
static byCoordinate(coordinate, roomName) {
|
|
7
|
+
return new TrilaterationPoint(coordinate.x, coordinate.y, coordinate.z, roomName);
|
|
8
|
+
}
|
|
6
9
|
static getPointsInRange(a, b, roomName = '') {
|
|
7
10
|
const points = [];
|
|
8
11
|
if (a.x > b.x || a.y > b.y || a.z > b.z) {
|
|
@@ -32,5 +35,12 @@ class TrilaterationPoint {
|
|
|
32
35
|
getDot5Distance(other) {
|
|
33
36
|
return utils_1.Utils.roundDot5(this.getDistance(other));
|
|
34
37
|
}
|
|
38
|
+
getCoordinate() {
|
|
39
|
+
return {
|
|
40
|
+
x: this.x,
|
|
41
|
+
y: this.y,
|
|
42
|
+
z: this.z,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
35
45
|
}
|
|
36
46
|
exports.TrilaterationPoint = TrilaterationPoint;
|
|
@@ -5,6 +5,7 @@ import { iRoomSettingsController } from './iRoomSettingsController';
|
|
|
5
5
|
import { iIdHolder } from './iIdHolder';
|
|
6
6
|
import { iDeviceCluster } from './iDevicecluster';
|
|
7
7
|
import { ITimeCallback } from './ITimeCallback';
|
|
8
|
+
import { iTrilaterationPoint } from './iTrilaterationPoint';
|
|
8
9
|
/**
|
|
9
10
|
* This interface represents a room with it's base functionality.
|
|
10
11
|
* Whilst accessing the custom rooms can be beneficial for direct device interaction, this provides interactions to e.g. device groups.
|
|
@@ -66,6 +67,14 @@ export interface iRoomBase extends iIdHolder {
|
|
|
66
67
|
* The time-callback for controlling light at sunset
|
|
67
68
|
*/
|
|
68
69
|
sonnenUntergangLichtCallback: ITimeCallback | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The bot-left corner of the room in 2D/3D Map
|
|
72
|
+
*/
|
|
73
|
+
startPoint?: iTrilaterationPoint;
|
|
74
|
+
/**
|
|
75
|
+
* The top-right corner of the room in 2D/3D Map
|
|
76
|
+
*/
|
|
77
|
+
endPoint?: iTrilaterationPoint;
|
|
69
78
|
/**
|
|
70
79
|
*
|
|
71
80
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { iObjectSettings } from './settings';
|
|
2
2
|
import { iTimePair } from './iTimePair';
|
|
3
|
+
import { iTrilaterationCoordinate } from './iTrilaterationCoordinate';
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
*/
|
|
@@ -76,6 +77,14 @@ export interface iRoomSettings extends iObjectSettings {
|
|
|
76
77
|
*
|
|
77
78
|
*/
|
|
78
79
|
includeLampsInNormalMovementLightning: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Die Startkoordinate des Raums
|
|
82
|
+
*/
|
|
83
|
+
trilaterationStartPoint?: iTrilaterationCoordinate;
|
|
84
|
+
/**
|
|
85
|
+
* Die Endkoordinate des Raums
|
|
86
|
+
*/
|
|
87
|
+
trilaterationEndPoint?: iTrilaterationCoordinate;
|
|
79
88
|
/**
|
|
80
89
|
*
|
|
81
90
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { iRoomBase, iRoomSettingsController, iTimePair } from '../../../interfaces';
|
|
1
|
+
import { iRoomBase, iRoomSettingsController, iTimePair, iTrilaterationPoint } from '../../../interfaces';
|
|
2
2
|
import { SunTimeOffsets } from '../../sun-time-offsets';
|
|
3
3
|
import { RoomSettings } from './roomSettings';
|
|
4
4
|
import { RoomBase } from '../../../services';
|
|
@@ -16,7 +16,7 @@ export declare class RoomSettingsController {
|
|
|
16
16
|
*/
|
|
17
17
|
lampOffset: SunTimeOffsets;
|
|
18
18
|
private _settingsContainer;
|
|
19
|
-
constructor(room: RoomBase);
|
|
19
|
+
constructor(room: RoomBase, startPoint?: iTrilaterationPoint, endPoint?: iTrilaterationPoint);
|
|
20
20
|
get settingsContainer(): RoomSettings;
|
|
21
21
|
get lichtSonnenAufgangAus(): boolean;
|
|
22
22
|
get ambientLightAfterSunset(): boolean;
|
|
@@ -7,20 +7,23 @@ exports.RoomSettingsController = void 0;
|
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const sun_time_offsets_1 = require("../../sun-time-offsets");
|
|
9
9
|
const roomSettings_1 = require("./roomSettings");
|
|
10
|
-
const
|
|
10
|
+
const services_1 = require("../../../services");
|
|
11
11
|
const api_1 = require("../../../api");
|
|
12
12
|
const utils_1 = require("../../../utils");
|
|
13
13
|
const logging_1 = require("../../../logging");
|
|
14
14
|
const enums_1 = require("../../../enums");
|
|
15
|
+
const devices_1 = require("../../../devices");
|
|
15
16
|
class RoomSettingsController {
|
|
16
|
-
constructor(room) {
|
|
17
|
+
constructor(room, startPoint, endPoint) {
|
|
17
18
|
this._settingsContainer = new roomSettings_1.RoomSettings();
|
|
18
19
|
this.roomName = room.roomName;
|
|
19
20
|
this.rolloOffset = new sun_time_offsets_1.SunTimeOffsets(this.sonnenAufgangRolloDelay, this.sonnenUntergangRolloDelay, this.sonnenAufgangRolloMinTime.hours, this.sonnenAufgangRolloMinTime.minutes, this.sonnenUntergangRolloMaxTime.hours, this.sonnenUntergangRolloMaxTime.minutes);
|
|
21
|
+
this._settingsContainer.trilaterationStartPoint = startPoint === null || startPoint === void 0 ? void 0 : startPoint.getCoordinate();
|
|
22
|
+
this._settingsContainer.trilaterationEndPoint = endPoint === null || endPoint === void 0 ? void 0 : endPoint.getCoordinate();
|
|
20
23
|
this.lampOffset = new sun_time_offsets_1.SunTimeOffsets(this.sonnenAufgangLampenDelay, this.sonnenUntergangLampenDelay);
|
|
21
24
|
this._settingsContainer.onChangeCb = this.onSettingChange.bind(this);
|
|
22
25
|
this._settingsContainer.initializeFromDb(room);
|
|
23
|
-
|
|
26
|
+
services_1.WeatherService.addWeatherUpdateCb(`ShutterWeatherUpdate${this.roomName}`, () => {
|
|
24
27
|
var _a;
|
|
25
28
|
if (this.sonnenUntergangRolloAdditionalOffsetPerCloudiness > 0) {
|
|
26
29
|
(_a = this.room) === null || _a === void 0 ? void 0 : _a.recalcTimeCallbacks();
|
|
@@ -98,6 +101,13 @@ class RoomSettingsController {
|
|
|
98
101
|
logging_1.ServerLogService.writeLog(enums_1.LogLevel.Info, `${this.roomName} RoomSettingsController.onSettingChange`);
|
|
99
102
|
this.recalcLampOffset();
|
|
100
103
|
this.recalcRolloOffset();
|
|
104
|
+
if (this.room !== undefined &&
|
|
105
|
+
this._settingsContainer.trilaterationStartPoint !== undefined &&
|
|
106
|
+
this._settingsContainer.trilaterationEndPoint !== undefined) {
|
|
107
|
+
this.room.startPoint = devices_1.TrilaterationPoint.byCoordinate(this._settingsContainer.trilaterationStartPoint, this.roomName);
|
|
108
|
+
this.room.endPoint = devices_1.TrilaterationPoint.byCoordinate(this._settingsContainer.trilaterationEndPoint, this.roomName);
|
|
109
|
+
devices_1.Trilateration.addRoom(this.room, this.room.startPoint, this.room.endPoint);
|
|
110
|
+
}
|
|
101
111
|
}
|
|
102
112
|
recalcRolloOffset() {
|
|
103
113
|
var _a;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { iRoomSettings, iTimePair } from '../../../interfaces';
|
|
1
|
+
import { iRoomSettings, iTimePair, iTrilaterationCoordinate } from '../../../interfaces';
|
|
2
2
|
import { ObjectSettings } from '../../../settingsObjects';
|
|
3
3
|
export declare class RoomSettings extends ObjectSettings implements iRoomSettings {
|
|
4
4
|
/**
|
|
@@ -74,5 +74,9 @@ export declare class RoomSettings extends ObjectSettings implements iRoomSetting
|
|
|
74
74
|
* Whether normal ceiling lights should also be turned on by movement, even if there are LEDs and outlets
|
|
75
75
|
*/
|
|
76
76
|
includeLampsInNormalMovementLightning: boolean;
|
|
77
|
+
/** @inheritDoc */
|
|
78
|
+
trilaterationStartPoint?: iTrilaterationCoordinate;
|
|
79
|
+
/** @inheritDoc */
|
|
80
|
+
trilaterationEndPoint?: iTrilaterationCoordinate;
|
|
77
81
|
fromPartialObject(_obj: Partial<RoomSettings>): void;
|
|
78
82
|
}
|
|
@@ -82,7 +82,7 @@ class RoomSettings extends settingsObjects_1.ObjectSettings {
|
|
|
82
82
|
this.includeLampsInNormalMovementLightning = settings_service_1.SettingsService.settings.roomDefault.includeLampsInNormalMovementLightning;
|
|
83
83
|
}
|
|
84
84
|
fromPartialObject(_obj) {
|
|
85
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
86
86
|
this.ambientLightAfterSunset = (_a = _obj.ambientLightAfterSunset) !== null && _a !== void 0 ? _a : this.ambientLightAfterSunset;
|
|
87
87
|
this.lichtSonnenAufgangAus = (_b = _obj.lichtSonnenAufgangAus) !== null && _b !== void 0 ? _b : this.lichtSonnenAufgangAus;
|
|
88
88
|
this.radioUrl = (_c = _obj.radioUrl) !== null && _c !== void 0 ? _c : this.radioUrl;
|
|
@@ -101,8 +101,10 @@ class RoomSettings extends settingsObjects_1.ObjectSettings {
|
|
|
101
101
|
this.sonnenUntergangRolloDelay = (_q = _obj.sonnenUntergangRolloDelay) !== null && _q !== void 0 ? _q : this.sonnenUntergangRolloDelay;
|
|
102
102
|
this.sonnenUntergangLampenDelay = (_r = _obj.sonnenUntergangLampenDelay) !== null && _r !== void 0 ? _r : this.sonnenUntergangLampenDelay;
|
|
103
103
|
this.sonnenUntergangRollos = (_s = _obj.sonnenUntergangRollos) !== null && _s !== void 0 ? _s : this.sonnenUntergangRollos;
|
|
104
|
+
this.trilaterationEndPoint = (_t = _obj.trilaterationEndPoint) !== null && _t !== void 0 ? _t : this.trilaterationEndPoint;
|
|
105
|
+
this.trilaterationStartPoint = (_u = _obj.trilaterationStartPoint) !== null && _u !== void 0 ? _u : this.trilaterationStartPoint;
|
|
104
106
|
this.includeLampsInNormalMovementLightning =
|
|
105
|
-
(
|
|
107
|
+
(_v = _obj.includeLampsInNormalMovementLightning) !== null && _v !== void 0 ? _v : this.includeLampsInNormalMovementLightning;
|
|
106
108
|
super.fromPartialObject(_obj);
|
|
107
109
|
}
|
|
108
110
|
}
|
package/lib/services/RoomBase.js
CHANGED
|
@@ -23,11 +23,8 @@ class RoomBase {
|
|
|
23
23
|
this.skipNextRolloUp = false;
|
|
24
24
|
this._deviceCluster = new devices_1.DeviceCluster();
|
|
25
25
|
this.info = new models_1.RoomInfo(roomName, etage);
|
|
26
|
-
this.settings = new models_1.RoomSettingsController(this);
|
|
26
|
+
this.settings = new models_1.RoomSettingsController(this, startPoint, endPoint);
|
|
27
27
|
room_service_1.RoomService.addToRoomList(this);
|
|
28
|
-
if (startPoint !== undefined && endPoint !== undefined) {
|
|
29
|
-
devices_1.Trilateration.addRoom(this, startPoint, endPoint);
|
|
30
|
-
}
|
|
31
28
|
}
|
|
32
29
|
get sonnenUntergangLichtCallback() {
|
|
33
30
|
var _a;
|
|
@@ -4,6 +4,10 @@ export declare abstract class ObjectSettings implements iObjectSettings {
|
|
|
4
4
|
* Callback to be fired when the settings change
|
|
5
5
|
*/
|
|
6
6
|
onChangeCb?: () => void;
|
|
7
|
+
/**
|
|
8
|
+
* An optional JSON string containing custom settings, primary used for debug/prototyping.
|
|
9
|
+
*/
|
|
10
|
+
customSettingsJson?: string;
|
|
7
11
|
persist(holder: iIdHolder): void;
|
|
8
12
|
/**
|
|
9
13
|
* Loads the settings from the database
|
|
@@ -43,9 +43,11 @@ class ObjectSettings {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
fromPartialObject(_obj) {
|
|
46
|
+
var _a;
|
|
46
47
|
if (this.onChangeCb) {
|
|
47
48
|
this.onChangeCb();
|
|
48
49
|
}
|
|
50
|
+
this.customSettingsJson = (_a = _obj.customSettingsJson) !== null && _a !== void 0 ? _a : this.customSettingsJson;
|
|
49
51
|
}
|
|
50
52
|
toJSON() {
|
|
51
53
|
return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['onChangeCb']));
|