hoffmation-base 3.2.29 → 3.2.31

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.
@@ -14,9 +14,8 @@ export declare abstract class BaseDevice implements iBaseDevice {
14
14
  readonly deviceCapabilities: DeviceCapability[];
15
15
  /**
16
16
  * @inheritDoc
17
- * @default undefined (no Settings)
18
17
  */
19
- settings: iDeviceSettings | undefined;
18
+ settings: iDeviceSettings;
20
19
  /**
21
20
  * The last actions this device performed
22
21
  */
@@ -9,6 +9,7 @@ const utils_1 = require("../utils");
9
9
  const logging_1 = require("../logging");
10
10
  const services_1 = require("../services");
11
11
  const lodash_1 = __importDefault(require("lodash"));
12
+ const settingsObjects_1 = require("../settingsObjects");
12
13
  class BaseDevice {
13
14
  constructor(_info, deviceType) {
14
15
  this._info = _info;
@@ -21,9 +22,8 @@ class BaseDevice {
21
22
  this.deviceCapabilities = [];
22
23
  /**
23
24
  * @inheritDoc
24
- * @default undefined (no Settings)
25
25
  */
26
- this.settings = undefined;
26
+ this.settings = new settingsObjects_1.DeviceSettings();
27
27
  /**
28
28
  * The last actions this device performed
29
29
  */
@@ -1,11 +1,8 @@
1
1
  import { iTemperatureCollector } from '../../interfaces';
2
- import { DeviceSettings } from '../../settingsObjects';
3
2
  import { TemperatureSensor } from '../sharedFunctions';
4
3
  import { TemperatureSensorChangeAction } from '../../action';
5
4
  import { RoomBaseDevice } from '../RoomBaseDevice';
6
5
  export declare class DachsTemperatureSensor extends RoomBaseDevice implements iTemperatureCollector {
7
- /** @inheritDoc */
8
- settings: DeviceSettings | undefined;
9
6
  /** @inheritDoc */
10
7
  temperatureSensor: TemperatureSensor;
11
8
  constructor(roomName: string, shortKey: string, longKey: string);
@@ -16,8 +16,6 @@ class DachsTemperatureSensor extends RoomBaseDevice_1.RoomBaseDevice {
16
16
  info.room = roomName;
17
17
  super(info, enums_1.DeviceType.DachsWarmWaterTemperature);
18
18
  /** @inheritDoc */
19
- this.settings = undefined;
20
- /** @inheritDoc */
21
19
  this.temperatureSensor = new sharedFunctions_1.TemperatureSensor(this);
22
20
  this.deviceCapabilities.push(enums_1.DeviceCapability.temperatureSensor);
23
21
  this.jsonOmitKeys.push(...['client', 'config', '_influxClient']);
@@ -5,8 +5,6 @@ import { iBluetoothDetector } from '../../interfaces/baseDevices/iBluetoothDetec
5
5
  import { BaseDevice } from '../BaseDevice';
6
6
  export declare class DetectedBluetoothDevice extends BaseDevice {
7
7
  trackedDeviceId: string;
8
- /** @inheritDoc */
9
- settings: undefined;
10
8
  /**
11
9
  * A Map matching the distances to the trackers identified by {@link iBluetoothDetector.id}
12
10
  */
@@ -21,8 +21,6 @@ class DetectedBluetoothDevice extends BaseDevice_1.BaseDevice {
21
21
  info.allDevicesKey = allDevicesKey;
22
22
  super(info, enums_1.DeviceType.TrackableDevice);
23
23
  this.trackedDeviceId = trackedDeviceId;
24
- /** @inheritDoc */
25
- this.settings = undefined;
26
24
  /**
27
25
  * A Map matching the distances to the trackers identified by {@link iBluetoothDetector.id}
28
26
  */
@@ -5,8 +5,6 @@ import { RoomBaseDevice } from '../RoomBaseDevice';
5
5
  export declare class EspresenseDevice extends RoomBaseDevice implements iBluetoothDetector {
6
6
  /** @inheritDoc */
7
7
  readonly position: iTrilaterationBasePoint;
8
- /** @inheritDoc */
9
- settings: undefined;
10
8
  /**
11
9
  * The name of this device
12
10
  */
@@ -26,8 +26,6 @@ class EspresenseDevice extends RoomBaseDevice_1.RoomBaseDevice {
26
26
  const allDevicesKey = `espresense-${roomName}-${name}`;
27
27
  info.allDevicesKey = allDevicesKey;
28
28
  super(info, enums_1.DeviceType.Espresense);
29
- /** @inheritDoc */
30
- this.settings = undefined;
31
29
  this.deviceMap = new Map();
32
30
  this.proximityCallbackMap = new Map();
33
31
  this.deviceCapabilities.push(enums_1.DeviceCapability.bluetoothDetector);
@@ -1,5 +1,4 @@
1
- import { RoomBase } from '../../services';
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: RoomBase, startPoint: iTrilaterationPoint, endPoint: iTrilaterationPoint): void;
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;
@@ -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
  */
@@ -19,4 +19,8 @@ export interface iTrilaterationPoint extends iTrilaterationCoordinate {
19
19
  *
20
20
  */
21
21
  getDot5Distance(other: iTrilaterationPoint): number;
22
+ /**
23
+ *
24
+ */
25
+ getCoordinate(): iTrilaterationCoordinate;
22
26
  }
@@ -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 weather_1 = require("../../../services/weather");
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
- weather_1.WeatherService.addWeatherUpdateCb(`ShutterWeatherUpdate${this.roomName}`, () => {
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
- (_t = _obj.includeLampsInNormalMovementLightning) !== null && _t !== void 0 ? _t : this.includeLampsInNormalMovementLightning;
107
+ (_v = _obj.includeLampsInNormalMovementLightning) !== null && _v !== void 0 ? _v : this.includeLampsInNormalMovementLightning;
106
108
  super.fromPartialObject(_obj);
107
109
  }
108
110
  }
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import { iBlockAutomaticSettings, iDeviceSettings, iExcessEnergyConsumerSettings, iTrilaterationCoordinate } from '../../interfaces';
2
2
  import { ObjectSettings } from '../objectSettings';
3
3
  import { BlockAutomaticCommand, iBaseCommand } from '../../command';
4
- export declare abstract class DeviceSettings extends ObjectSettings implements iDeviceSettings {
4
+ export declare class DeviceSettings extends ObjectSettings implements iDeviceSettings {
5
5
  buildBlockAutomaticCommand(c: iBaseCommand): BlockAutomaticCommand | null | undefined;
6
6
  /**
7
7
  * The position of the device in the room in meters
@@ -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']));