hoffmation-base 2.15.5 → 2.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,4 +8,5 @@ export interface iLogSettings {
8
8
  debugUnchangedActuator?: boolean;
9
9
  debugDaikinSuccessfullControlInfo?: boolean;
10
10
  debugEuroHeaterValve?: boolean;
11
+ debugTrilateration?: boolean;
11
12
  }
@@ -4,6 +4,7 @@ exports.DetectedBluetoothDevice = void 0;
4
4
  const DeviceInfo_1 = require("../DeviceInfo");
5
5
  const DeviceCapability_1 = require("../DeviceCapability");
6
6
  const deviceType_1 = require("../deviceType");
7
+ const models_1 = require("../../../models");
7
8
  const services_1 = require("../../services");
8
9
  const devices_1 = require("../devices");
9
10
  const trackedDistanceData_1 = require("./trackedDistanceData");
@@ -105,15 +106,16 @@ class DetectedBluetoothDevice {
105
106
  const distances = [];
106
107
  for (const key of this.distanceMap.keys()) {
107
108
  const tracker = services_1.API.getDevice(key);
108
- if (tracker === undefined) {
109
+ if (tracker === undefined || tracker.position === undefined) {
109
110
  continue;
110
111
  }
111
- const distance = this.getDistance(key);
112
+ const distance = this.getDistance(key, 60);
112
113
  if ((distance === null || distance === void 0 ? void 0 : distance.distance) === undefined) {
113
114
  continue;
114
115
  }
115
116
  distances.push(new trilaterationPointDistance_1.TrilaterationPointDistance(tracker.position.ownPoint.coordinateName, distance.distance));
116
117
  }
118
+ this.log(models_1.LogLevel.Debug, `Guessing room from ${distances.length} distance(s).`, services_1.LogDebugType.Trilateration);
117
119
  this.lastRoom = trilateration_1.Trilateration.checkRoom(distances);
118
120
  }
119
121
  }
@@ -19,6 +19,9 @@ class Trilateration {
19
19
  static getBestMatches(distances) {
20
20
  const bestRatedCoordinates = this.getBestRatedCoordinates(distances);
21
21
  if (bestRatedCoordinates.length === 0) {
22
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `No best rated coordinates found for ${distances.length} distances.`, {
23
+ debugType: services_1.LogDebugType.Trilateration,
24
+ });
22
25
  return [];
23
26
  }
24
27
  const bestMatches = [];
@@ -36,6 +39,11 @@ class Trilateration {
36
39
  for (const dist of distances) {
37
40
  const point = this.basePoints.find((basePoint) => basePoint.ownPoint.coordinateName === dist.pointName);
38
41
  if (point === undefined) {
42
+ const possiblePoints = [];
43
+ for (const basePoint of this.basePoints) {
44
+ possiblePoints.push(basePoint.ownPoint.coordinateName);
45
+ }
46
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Could not find base point for ${dist.pointName}, possible points: ${possiblePoints.join(', ')}`);
39
47
  continue;
40
48
  }
41
49
  const ratedCoordinates = point.getRatedCoordinates(dist.distance);
@@ -54,6 +62,7 @@ class Trilateration {
54
62
  static checkRoom(distances) {
55
63
  var _a;
56
64
  const bestMatches = this.getBestMatches(distances);
65
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `Found ${bestMatches.length} best matches for ${distances.length} distances.`, { debugType: services_1.LogDebugType.Trilateration });
57
66
  if (bestMatches.length === 0) {
58
67
  return undefined;
59
68
  }
@@ -76,6 +85,9 @@ class Trilateration {
76
85
  }
77
86
  return b.rating - a.rating;
78
87
  });
88
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `First sorted coordinate: ${JSON.stringify(sortedCoordinates[0])}`, {
89
+ debugType: services_1.LogDebugType.Trilateration,
90
+ });
79
91
  const possibleWinner = [];
80
92
  for (const coordinate of sortedCoordinates) {
81
93
  if (possibleWinner.length === 0) {
@@ -3,10 +3,9 @@ export declare class TrilaterationPoint {
3
3
  y: number;
4
4
  z: number;
5
5
  roomName: string;
6
- matchPoints: number;
7
6
  static getPointsInRange(a: TrilaterationPoint, b: TrilaterationPoint, roomName?: string): TrilaterationPoint[];
8
7
  readonly coordinateName: string;
9
- constructor(x: number, y: number, z: number, roomName: string, matchPoints?: number);
8
+ constructor(x: number, y: number, z: number, roomName: string);
10
9
  getDistance(other: TrilaterationPoint): number;
11
10
  getDot5Distance(other: TrilaterationPoint): number;
12
11
  }
@@ -17,12 +17,11 @@ class TrilaterationPoint {
17
17
  }
18
18
  return points;
19
19
  }
20
- constructor(x, y, z, roomName, matchPoints = 0) {
20
+ constructor(x, y, z, roomName) {
21
21
  this.x = x;
22
22
  this.y = y;
23
23
  this.z = z;
24
24
  this.roomName = roomName;
25
- this.matchPoints = matchPoints;
26
25
  this.coordinateName = `${this.x}-${this.y}-${this.z}`;
27
26
  }
28
27
  getDistance(other) {
@@ -8,7 +8,8 @@ export declare enum LogDebugType {
8
8
  NewMovementState = 5,
9
9
  SkipUnchangedMovementState = 6,
10
10
  DaikinSuccessfullControlInfo = 7,
11
- EuroHeaterValveLogging = 8
11
+ EuroHeaterValveLogging = 8,
12
+ Trilateration = 9
12
13
  }
13
14
  export declare class LogFilterData {
14
15
  room?: string;
@@ -12,6 +12,7 @@ var LogDebugType;
12
12
  LogDebugType[LogDebugType["SkipUnchangedMovementState"] = 6] = "SkipUnchangedMovementState";
13
13
  LogDebugType[LogDebugType["DaikinSuccessfullControlInfo"] = 7] = "DaikinSuccessfullControlInfo";
14
14
  LogDebugType[LogDebugType["EuroHeaterValveLogging"] = 8] = "EuroHeaterValveLogging";
15
+ LogDebugType[LogDebugType["Trilateration"] = 9] = "Trilateration";
15
16
  })(LogDebugType || (exports.LogDebugType = LogDebugType = {}));
16
17
  class LogFilterData {
17
18
  constructor() {
@@ -64,7 +64,7 @@ class ServerLogService {
64
64
  * @returns {boolean} If the Message should be skipped
65
65
  */
66
66
  static checkDebugLogSkip(debugType) {
67
- var _a, _b, _c, _d, _e, _f, _g, _h;
67
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
68
68
  switch (debugType) {
69
69
  case log_filter_data_1.LogDebugType.None:
70
70
  return false;
@@ -108,6 +108,11 @@ class ServerLogService {
108
108
  return false;
109
109
  }
110
110
  break;
111
+ case log_filter_data_1.LogDebugType.Trilateration:
112
+ if (((_j = settings_service_1.SettingsService.settings.logSettings) === null || _j === void 0 ? void 0 : _j.debugTrilateration) === true) {
113
+ return false;
114
+ }
115
+ break;
111
116
  }
112
117
  return true;
113
118
  }