hoffmation-base 0.1.1 → 0.1.5

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.
Files changed (113) hide show
  1. package/.eslintrc.js +27 -27
  2. package/.github/workflows/npm-publish.yml +50 -0
  3. package/.prettierrc.js +9 -9
  4. package/LICENSE +21 -21
  5. package/index.js +1 -1
  6. package/models/connectionCallbacks.ts +13 -13
  7. package/models/daytime.ts +3 -3
  8. package/models/deviceConfig.ts +8 -8
  9. package/models/dimmerSettings.ts +5 -5
  10. package/models/iTemperaturDataPoint.ts +9 -9
  11. package/models/lampSettings.ts +5 -5
  12. package/models/ledSettings.ts +19 -19
  13. package/models/logLevel.ts +9 -9
  14. package/models/persistence/BasicRoomInfo.ts +3 -3
  15. package/models/persistence/DailyMovementCount.ts +3 -3
  16. package/models/persistence/RoomDetailInfo.ts +4 -4
  17. package/models/persistence/temperaturDataPoint.ts +12 -12
  18. package/models/persistence/todaysCount.ts +3 -3
  19. package/models/rooms/RoomBase.ts +357 -357
  20. package/models/rooms/RoomSettings/RoomSettings.ts +159 -159
  21. package/models/rooms/RoomSettings/hmIPRoomSettings.ts +53 -53
  22. package/models/rooms/RoomSettings/iRoomDefaultSettings.ts +17 -17
  23. package/models/rooms/RoomSettings/readme.md +17 -17
  24. package/models/rooms/RoomSettings/zigbeeRoomSettings.ts +51 -51
  25. package/models/rooms/iRoomImportEnforcer.ts +3 -3
  26. package/models/rooms/readme.md +11 -11
  27. package/models/temperaturSettings.ts +22 -22
  28. package/models/timeCallback.ts +90 -90
  29. package/package.json +1 -1
  30. package/server/config/config-readme.md +19 -19
  31. package/server/config/iConfig.ts +53 -53
  32. package/server/config/private/mainConfig.json +64 -64
  33. package/server/devices/DeviceInfo.ts +66 -66
  34. package/server/devices/Griffe.ts +31 -31
  35. package/server/devices/Heizgruppen.ts +91 -91
  36. package/server/devices/Rollos.ts +48 -48
  37. package/server/devices/deviceUpdater.ts +72 -72
  38. package/server/devices/devices.ts +189 -189
  39. package/server/devices/groups/fensterGroup.ts +175 -175
  40. package/server/devices/groups/heatGroup.ts +32 -32
  41. package/server/devices/groups/lampenGroup.ts +88 -88
  42. package/server/devices/groups/praesenzGroup.ts +182 -182
  43. package/server/devices/groups/smokeGroup.ts +16 -16
  44. package/server/devices/groups/sonosGroup.ts +33 -33
  45. package/server/devices/groups/tasterGroup.ts +48 -48
  46. package/server/devices/groups/waterGroup.ts +16 -16
  47. package/server/devices/hmIPDevices/Fenster.ts +114 -114
  48. package/server/devices/hmIPDevices/FensterPosition.ts +5 -5
  49. package/server/devices/hmIPDevices/TuerPosition.ts +4 -4
  50. package/server/devices/hmIPDevices/hmIpBewegung.ts +126 -126
  51. package/server/devices/hmIPDevices/hmIpDevice.ts +90 -90
  52. package/server/devices/hmIPDevices/hmIpDeviceType.ts +14 -14
  53. package/server/devices/hmIPDevices/hmIpGriff.ts +143 -143
  54. package/server/devices/hmIPDevices/hmIpHeizgruppe.ts +172 -172
  55. package/server/devices/hmIPDevices/hmIpHeizung.ts +69 -69
  56. package/server/devices/hmIPDevices/hmIpLampe.ts +119 -119
  57. package/server/devices/hmIPDevices/hmIpPraezenz.ts +99 -99
  58. package/server/devices/hmIPDevices/hmIpRoll.ts +133 -133
  59. package/server/devices/hmIPDevices/hmIpTaster.ts +82 -73
  60. package/server/devices/hmIPDevices/hmIpTherm.ts +19 -19
  61. package/server/devices/hmIPDevices/hmIpTuer.ts +115 -115
  62. package/server/devices/hmIPDevices/hmIpWippe.ts +55 -55
  63. package/server/devices/iDeviceUpdater.ts +4 -4
  64. package/server/devices/iIoBrokerDevice.ts +44 -44
  65. package/server/devices/iTaster.ts +6 -0
  66. package/server/devices/{hmIPDevices/hmIpTaste.ts → taste.ts} +84 -72
  67. package/server/devices/wledDevice.ts +124 -124
  68. package/server/devices/zigbee/ZigbeeActuator.ts +113 -113
  69. package/server/devices/zigbee/zigbeeAquaraVibra.ts +171 -171
  70. package/server/devices/zigbee/zigbeeAquaraWater.ts +94 -94
  71. package/server/devices/zigbee/zigbeeBlitzShp.ts +77 -77
  72. package/server/devices/zigbee/zigbeeDevice.ts +115 -115
  73. package/server/devices/zigbee/zigbeeDeviceType.ts +13 -13
  74. package/server/devices/zigbee/zigbeeHeimanSmoke.ts +99 -99
  75. package/server/devices/zigbee/zigbeeIkeaSteckdose.ts +31 -31
  76. package/server/devices/zigbee/zigbeeIlluActuator.ts +37 -37
  77. package/server/devices/zigbee/zigbeeIlluDimmer.ts +165 -165
  78. package/server/devices/zigbee/zigbeeIlluLampe.ts +33 -33
  79. package/server/devices/zigbee/zigbeeIlluLedRGBCCT.ts +137 -137
  80. package/server/ioBroker/connection.ts +1655 -1655
  81. package/server/ioBroker/ioBroker.main.ts +99 -99
  82. package/server/ioBroker/socketIOAuthInfo.ts +5 -5
  83. package/server/ioBroker/socketIOConnectOptions.ts +6 -6
  84. package/server/ioBroker/socketIOLogging.ts +29 -29
  85. package/server/ioBroker/socketIOVisCommand.ts +11 -11
  86. package/server/services/HTTPSOptions.ts +14 -14
  87. package/server/services/Sonos/OwnSonosDevices.ts +9 -0
  88. package/server/services/Sonos/mp3-server.ts +75 -75
  89. package/server/services/Sonos/polly-service.ts +100 -100
  90. package/server/services/Sonos/sonos-service.ts +194 -199
  91. package/server/services/Telegram/telegram-Commands.ts +237 -215
  92. package/server/services/Telegram/telegram-service.ts +171 -171
  93. package/server/services/Telegram/telegramMessageCalback.ts +11 -11
  94. package/server/services/calendar/muell-tonne.ts +82 -83
  95. package/server/services/calendar/m/303/274ll-service.ts +147 -146
  96. package/server/services/dbo/persist.ts +125 -125
  97. package/server/services/https-service.ts +71 -71
  98. package/server/services/log-service.ts +69 -69
  99. package/server/services/news-service.ts +81 -81
  100. package/server/services/settings-service.ts +15 -15
  101. package/server/services/time-callback-service.ts +223 -223
  102. package/server/services/utils/ringstorage.ts +24 -24
  103. package/server/services/utils/utils.ts +52 -52
  104. package/server/services/weather/weather-alert.ts +7 -7
  105. package/server/services/weather/weather-current.ts +26 -26
  106. package/server/services/weather/weather-daily.ts +22 -22
  107. package/server/services/weather/weather-feelsLike.ts +6 -6
  108. package/server/services/weather/weather-hourly.ts +17 -17
  109. package/server/services/weather/weather-item.ts +6 -6
  110. package/server/services/weather/weather-minutes.ts +4 -4
  111. package/server/services/weather/weather-service.ts +277 -277
  112. package/server/services/weather/weather-temp.ts +8 -8
  113. package/tsconfig.json +58 -58
@@ -1,114 +1,114 @@
1
- import { LogLevel } from '../../../models/logLevel';
2
- import { ZigbeeAquaraVibra } from '../zigbee/zigbeeAquaraVibra';
3
- import { FensterPosition } from './FensterPosition';
4
- import { HmIpGriff } from './hmIpGriff';
5
- import { HmIpRoll } from './hmIpRoll';
6
- import { ServerLogService } from '../../services/log-service';
7
- import { TimeCallbackService, TimeOfDay } from '../../services/time-callback-service';
8
- import { Utils } from '../../services/utils/utils';
9
- import { RoomBase } from '../../../models/rooms/RoomBase';
10
-
11
- export class Fenster {
12
- public desiredPosition: number = 0;
13
-
14
- /**
15
- * sets the desired Pos and moves rollo to this level
16
- * @param {number} value
17
- */
18
- public setDesiredPosition(value: number) {
19
- this.desiredPosition = value;
20
- this.restoreDesiredPosition();
21
- }
22
-
23
- public constructor(
24
- public room: RoomBase,
25
- public griffe: HmIpGriff[],
26
- public vibration: ZigbeeAquaraVibra[],
27
- public rollo: HmIpRoll | undefined = undefined,
28
- public noRolloOnSunrise: boolean = false,
29
- ) {
30
- for (const griff of griffe) {
31
- griff.addKippCallback((kipp: boolean) => {
32
- if (kipp && this.griffeInPosition(FensterPosition.offen) === 0) {
33
- this.vibration.forEach((element) => {
34
- element.vibrationBlocked = true;
35
- });
36
- const timeOfDay: TimeOfDay = TimeCallbackService.dayType(this.room.Einstellungen.rolloOffset);
37
- if (TimeCallbackService.darkOutsideOrNight(timeOfDay)) {
38
- this.rollo?.setLevel(50);
39
- } else {
40
- this.rollo?.up();
41
- }
42
- }
43
- });
44
-
45
- griff.addOffenCallback((offen: boolean) => {
46
- if (offen) {
47
- this.vibration.forEach((element) => {
48
- element.vibrationBlocked = true;
49
- });
50
- this.rollo?.up();
51
- return;
52
- }
53
- });
54
-
55
- griff.addClosedCallback((geschlossen: boolean) => {
56
- if (
57
- geschlossen &&
58
- this.griffeInPosition(FensterPosition.offen) === 0 &&
59
- this.griffeInPosition(FensterPosition.kipp) === 0
60
- ) {
61
- const now = new Date().getTime();
62
- this.vibration.forEach((element) => {
63
- ServerLogService.writeLog(
64
- LogLevel.Debug,
65
- `Starte Timeout für Vibrationsdeaktivierung für ${element.info.customName}`,
66
- );
67
- Utils.guardedTimeout(() => {
68
- if (element.vibrationBlockedTimeStamp < now) {
69
- element.vibrationBlocked = false;
70
- }
71
- }, 12000);
72
- });
73
- this.restoreDesiredPosition();
74
- }
75
- });
76
- }
77
- Utils.guardedTimeout(
78
- () => {
79
- if (this.rollo) this.rollo.Fenster = this;
80
- for (const g of this.griffe) {
81
- g.Fenster = this;
82
- }
83
- },
84
- 5,
85
- this,
86
- );
87
- }
88
-
89
- public griffeInPosition(pPosition: FensterPosition): number {
90
- let count = 0;
91
- for (const griff of this.griffe) {
92
- if (griff.position === pPosition) {
93
- count++;
94
- }
95
- }
96
- return count;
97
- }
98
-
99
- public rolloPositionChange(pValue: number): void {
100
- if (!this.room) {
101
- ServerLogService.writeLog(LogLevel.Error, `Fenster Rollo Update, but this one is not connected to any room!`);
102
- return;
103
- }
104
- ServerLogService.writeLog(LogLevel.Debug, `Rollo Position Change in ${this.room.roomName} to ${pValue}`);
105
-
106
- if (pValue === 0 || pValue === 100) {
107
- this.room.setLightTimeBased(true);
108
- }
109
- }
110
-
111
- public restoreDesiredPosition() {
112
- this.rollo?.setLevel(this.desiredPosition);
113
- }
114
- }
1
+ import { LogLevel } from '../../../models/logLevel';
2
+ import { ZigbeeAquaraVibra } from '../zigbee/zigbeeAquaraVibra';
3
+ import { FensterPosition } from './FensterPosition';
4
+ import { HmIpGriff } from './hmIpGriff';
5
+ import { HmIpRoll } from './hmIpRoll';
6
+ import { ServerLogService } from '../../services/log-service';
7
+ import { TimeCallbackService, TimeOfDay } from '../../services/time-callback-service';
8
+ import { Utils } from '../../services/utils/utils';
9
+ import { RoomBase } from '../../../models/rooms/RoomBase';
10
+
11
+ export class Fenster {
12
+ public desiredPosition: number = 0;
13
+
14
+ /**
15
+ * sets the desired Pos and moves rollo to this level
16
+ * @param {number} value
17
+ */
18
+ public setDesiredPosition(value: number) {
19
+ this.desiredPosition = value;
20
+ this.restoreDesiredPosition();
21
+ }
22
+
23
+ public constructor(
24
+ public room: RoomBase,
25
+ public griffe: HmIpGriff[],
26
+ public vibration: ZigbeeAquaraVibra[],
27
+ public rollo: HmIpRoll | undefined = undefined,
28
+ public noRolloOnSunrise: boolean = false,
29
+ ) {
30
+ for (const griff of griffe) {
31
+ griff.addKippCallback((kipp: boolean) => {
32
+ if (kipp && this.griffeInPosition(FensterPosition.offen) === 0) {
33
+ this.vibration.forEach((element) => {
34
+ element.vibrationBlocked = true;
35
+ });
36
+ const timeOfDay: TimeOfDay = TimeCallbackService.dayType(this.room.Einstellungen.rolloOffset);
37
+ if (TimeCallbackService.darkOutsideOrNight(timeOfDay)) {
38
+ this.rollo?.setLevel(50);
39
+ } else {
40
+ this.rollo?.up();
41
+ }
42
+ }
43
+ });
44
+
45
+ griff.addOffenCallback((offen: boolean) => {
46
+ if (offen) {
47
+ this.vibration.forEach((element) => {
48
+ element.vibrationBlocked = true;
49
+ });
50
+ this.rollo?.up();
51
+ return;
52
+ }
53
+ });
54
+
55
+ griff.addClosedCallback((geschlossen: boolean) => {
56
+ if (
57
+ geschlossen &&
58
+ this.griffeInPosition(FensterPosition.offen) === 0 &&
59
+ this.griffeInPosition(FensterPosition.kipp) === 0
60
+ ) {
61
+ const now = new Date().getTime();
62
+ this.vibration.forEach((element) => {
63
+ ServerLogService.writeLog(
64
+ LogLevel.Debug,
65
+ `Starte Timeout für Vibrationsdeaktivierung für ${element.info.customName}`,
66
+ );
67
+ Utils.guardedTimeout(() => {
68
+ if (element.vibrationBlockedTimeStamp < now) {
69
+ element.vibrationBlocked = false;
70
+ }
71
+ }, 12000);
72
+ });
73
+ this.restoreDesiredPosition();
74
+ }
75
+ });
76
+ }
77
+ Utils.guardedTimeout(
78
+ () => {
79
+ if (this.rollo) this.rollo.Fenster = this;
80
+ for (const g of this.griffe) {
81
+ g.Fenster = this;
82
+ }
83
+ },
84
+ 5,
85
+ this,
86
+ );
87
+ }
88
+
89
+ public griffeInPosition(pPosition: FensterPosition): number {
90
+ let count = 0;
91
+ for (const griff of this.griffe) {
92
+ if (griff.position === pPosition) {
93
+ count++;
94
+ }
95
+ }
96
+ return count;
97
+ }
98
+
99
+ public rolloPositionChange(pValue: number): void {
100
+ if (!this.room) {
101
+ ServerLogService.writeLog(LogLevel.Error, `Fenster Rollo Update, but this one is not connected to any room!`);
102
+ return;
103
+ }
104
+ ServerLogService.writeLog(LogLevel.Debug, `Rollo Position Change in ${this.room.roomName} to ${pValue}`);
105
+
106
+ if (pValue === 0 || pValue === 100) {
107
+ this.room.setLightTimeBased(true);
108
+ }
109
+ }
110
+
111
+ public restoreDesiredPosition() {
112
+ this.rollo?.setLevel(this.desiredPosition);
113
+ }
114
+ }
@@ -1,5 +1,5 @@
1
- export enum FensterPosition {
2
- geschlossen = 0,
3
- kipp = 1,
4
- offen = 2,
5
- }
1
+ export enum FensterPosition {
2
+ geschlossen = 0,
3
+ kipp = 1,
4
+ offen = 2,
5
+ }
@@ -1,4 +1,4 @@
1
- export enum TuerPosition {
2
- geschlossen = 0,
3
- offen = 1,
4
- }
1
+ export enum TuerPosition {
2
+ geschlossen = 0,
3
+ offen = 1,
4
+ }
@@ -1,126 +1,126 @@
1
- import { LogLevel } from '../../../models/logLevel';
2
- import { HmIPDevice } from './hmIpDevice';
3
- import { HmIpDeviceType } from './hmIpDeviceType';
4
- import { DeviceInfo } from '../DeviceInfo';
5
- import { ServerLogService } from '../../services/log-service';
6
- import { Persist } from '../../services/dbo/persist';
7
- import { CountToday } from '../../../models/persistence/todaysCount';
8
- import { Utils } from '../../services/utils/utils';
9
-
10
- export class HmIpBewegung extends HmIPDevice {
11
- public excludeFromNightAlarm: boolean = false;
12
- public movementDetected: boolean = false;
13
- private _detectionsToday: number = 0;
14
- private _movementDetectedCallback: Array<(pValue: boolean) => void> = [];
15
- private static MOVEMENT_DETECTION: string = 'MOTION';
16
- private initialized: boolean = false;
17
- private fallBackTimeout: NodeJS.Timeout | undefined;
18
-
19
- public get detectionsToday(): number {
20
- return this._detectionsToday;
21
- }
22
-
23
- public set detectionsToday(pVal: number) {
24
- const oldVal: number = this._detectionsToday;
25
- this._detectionsToday = pVal;
26
- Persist.persistTodayCount(this, pVal, oldVal);
27
- }
28
-
29
- public constructor(pInfo: DeviceInfo) {
30
- super(pInfo, HmIpDeviceType.HmIpBewegung);
31
- Persist.getCount(this).then((todayCount: CountToday) => {
32
- this.detectionsToday = todayCount.counter;
33
- ServerLogService.writeLog(
34
- LogLevel.Debug,
35
- `Bewegungscounter "${this.info.customName}" vorinitialisiert mit ${this.detectionsToday}`,
36
- );
37
- this.initialized = true;
38
- });
39
- }
40
-
41
- public addMovementCallback(pCallback: (pValue: boolean) => void): void {
42
- this._movementDetectedCallback.push(pCallback);
43
- }
44
-
45
- public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
46
- ServerLogService.writeLog(
47
- LogLevel.Trace,
48
- `Bewegungs Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`,
49
- );
50
- super.update(idSplit, state, initial, true);
51
-
52
- if (idSplit[3] !== '3') {
53
- // Nur die Infos in Kanal 1 sind relevant
54
- return;
55
- }
56
-
57
- switch (idSplit[4]) {
58
- case HmIpBewegung.MOVEMENT_DETECTION:
59
- this.updateMovement(state.val as boolean);
60
- break;
61
- }
62
- }
63
-
64
- public updateMovement(pVal: boolean): void {
65
- if (!this.initialized && pVal) {
66
- ServerLogService.writeLog(
67
- LogLevel.Trace,
68
- `Bewegung für "${this.info.customName}" erkannt aber die Initialisierung aus der DB ist noch nicht erfolgt --> verzögern`,
69
- );
70
- Utils.guardedTimeout(
71
- () => {
72
- this.updateMovement(pVal);
73
- },
74
- 1000,
75
- this,
76
- );
77
- return;
78
- }
79
- if (pVal === this.movementDetected) {
80
- ServerLogService.writeLog(
81
- LogLevel.Debug,
82
- `Überspringe Bewegung für "${this.info.customName}" da bereits der Wert ${pVal} vorliegt`,
83
- );
84
- if (pVal) {
85
- this.resetFallbackTimeout();
86
- this.startFallbackTimeout();
87
- }
88
- return;
89
- }
90
-
91
- this.resetFallbackTimeout();
92
- this.movementDetected = pVal;
93
- ServerLogService.writeLog(LogLevel.Debug, `Neuer Bewegunsstatus Wert für "${this.info.customName}": ${pVal}`);
94
- if (pVal) {
95
- this.startFallbackTimeout();
96
- this.detectionsToday++;
97
- ServerLogService.writeLog(
98
- LogLevel.Trace,
99
- `Dies ist die ${this.detectionsToday} Bewegung für "${this.info.customName}"`,
100
- );
101
- }
102
-
103
- for (const c of this._movementDetectedCallback) {
104
- c(pVal);
105
- }
106
- }
107
-
108
- private resetFallbackTimeout(): void {
109
- if (this.fallBackTimeout) {
110
- ServerLogService.writeLog(LogLevel.Trace, `Fallback Timeout für "${this.info.customName}" zurücksetzen`);
111
- clearTimeout(this.fallBackTimeout);
112
- }
113
- }
114
-
115
- private startFallbackTimeout(): void {
116
- this.fallBackTimeout = Utils.guardedTimeout(
117
- () => {
118
- ServerLogService.writeLog(LogLevel.Debug, `Benötige Fallback Bewegungs Reset für "${this.info.customName}"`);
119
- this.fallBackTimeout = undefined;
120
- this.updateMovement(false);
121
- },
122
- 270000,
123
- this,
124
- );
125
- }
126
- }
1
+ import { LogLevel } from '../../../models/logLevel';
2
+ import { HmIPDevice } from './hmIpDevice';
3
+ import { HmIpDeviceType } from './hmIpDeviceType';
4
+ import { DeviceInfo } from '../DeviceInfo';
5
+ import { ServerLogService } from '../../services/log-service';
6
+ import { Persist } from '../../services/dbo/persist';
7
+ import { CountToday } from '../../../models/persistence/todaysCount';
8
+ import { Utils } from '../../services/utils/utils';
9
+
10
+ export class HmIpBewegung extends HmIPDevice {
11
+ public excludeFromNightAlarm: boolean = false;
12
+ public movementDetected: boolean = false;
13
+ private _detectionsToday: number = 0;
14
+ private _movementDetectedCallback: Array<(pValue: boolean) => void> = [];
15
+ private static MOVEMENT_DETECTION: string = 'MOTION';
16
+ private initialized: boolean = false;
17
+ private fallBackTimeout: NodeJS.Timeout | undefined;
18
+
19
+ public get detectionsToday(): number {
20
+ return this._detectionsToday;
21
+ }
22
+
23
+ public set detectionsToday(pVal: number) {
24
+ const oldVal: number = this._detectionsToday;
25
+ this._detectionsToday = pVal;
26
+ Persist.persistTodayCount(this, pVal, oldVal);
27
+ }
28
+
29
+ public constructor(pInfo: DeviceInfo) {
30
+ super(pInfo, HmIpDeviceType.HmIpBewegung);
31
+ Persist.getCount(this).then((todayCount: CountToday) => {
32
+ this.detectionsToday = todayCount.counter;
33
+ ServerLogService.writeLog(
34
+ LogLevel.Debug,
35
+ `Bewegungscounter "${this.info.customName}" vorinitialisiert mit ${this.detectionsToday}`,
36
+ );
37
+ this.initialized = true;
38
+ });
39
+ }
40
+
41
+ public addMovementCallback(pCallback: (pValue: boolean) => void): void {
42
+ this._movementDetectedCallback.push(pCallback);
43
+ }
44
+
45
+ public update(idSplit: string[], state: ioBroker.State, initial: boolean = false): void {
46
+ ServerLogService.writeLog(
47
+ LogLevel.Trace,
48
+ `Bewegungs Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`,
49
+ );
50
+ super.update(idSplit, state, initial, true);
51
+
52
+ if (idSplit[3] !== '3') {
53
+ // Nur die Infos in Kanal 1 sind relevant
54
+ return;
55
+ }
56
+
57
+ switch (idSplit[4]) {
58
+ case HmIpBewegung.MOVEMENT_DETECTION:
59
+ this.updateMovement(state.val as boolean);
60
+ break;
61
+ }
62
+ }
63
+
64
+ public updateMovement(pVal: boolean): void {
65
+ if (!this.initialized && pVal) {
66
+ ServerLogService.writeLog(
67
+ LogLevel.Trace,
68
+ `Bewegung für "${this.info.customName}" erkannt aber die Initialisierung aus der DB ist noch nicht erfolgt --> verzögern`,
69
+ );
70
+ Utils.guardedTimeout(
71
+ () => {
72
+ this.updateMovement(pVal);
73
+ },
74
+ 1000,
75
+ this,
76
+ );
77
+ return;
78
+ }
79
+ if (pVal === this.movementDetected) {
80
+ ServerLogService.writeLog(
81
+ LogLevel.Debug,
82
+ `Überspringe Bewegung für "${this.info.customName}" da bereits der Wert ${pVal} vorliegt`,
83
+ );
84
+ if (pVal) {
85
+ this.resetFallbackTimeout();
86
+ this.startFallbackTimeout();
87
+ }
88
+ return;
89
+ }
90
+
91
+ this.resetFallbackTimeout();
92
+ this.movementDetected = pVal;
93
+ ServerLogService.writeLog(LogLevel.Debug, `Neuer Bewegunsstatus Wert für "${this.info.customName}": ${pVal}`);
94
+ if (pVal) {
95
+ this.startFallbackTimeout();
96
+ this.detectionsToday++;
97
+ ServerLogService.writeLog(
98
+ LogLevel.Trace,
99
+ `Dies ist die ${this.detectionsToday} Bewegung für "${this.info.customName}"`,
100
+ );
101
+ }
102
+
103
+ for (const c of this._movementDetectedCallback) {
104
+ c(pVal);
105
+ }
106
+ }
107
+
108
+ private resetFallbackTimeout(): void {
109
+ if (this.fallBackTimeout) {
110
+ ServerLogService.writeLog(LogLevel.Trace, `Fallback Timeout für "${this.info.customName}" zurücksetzen`);
111
+ clearTimeout(this.fallBackTimeout);
112
+ }
113
+ }
114
+
115
+ private startFallbackTimeout(): void {
116
+ this.fallBackTimeout = Utils.guardedTimeout(
117
+ () => {
118
+ ServerLogService.writeLog(LogLevel.Debug, `Benötige Fallback Bewegungs Reset für "${this.info.customName}"`);
119
+ this.fallBackTimeout = undefined;
120
+ this.updateMovement(false);
121
+ },
122
+ 270000,
123
+ this,
124
+ );
125
+ }
126
+ }