hoffmation-base 1.2.4 → 1.2.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.
- package/lib/models/timeCallback.js +3 -6
- package/lib/server/devices/baseDeviceInterfaces/iBatteryDevice.d.ts +1 -0
- package/lib/server/devices/baseDeviceInterfaces/iScene.d.ts +1 -0
- package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +2 -0
- package/lib/server/devices/hmIPDevices/hmIpGriff.js +9 -0
- package/lib/server/devices/hmIPDevices/hmIpHeizung.d.ts +2 -0
- package/lib/server/devices/hmIPDevices/hmIpHeizung.js +9 -0
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +2 -0
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +9 -0
- package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +2 -0
- package/lib/server/devices/hmIPDevices/hmIpTaster.js +9 -0
- package/lib/server/devices/hmIPDevices/hmIpTherm.d.ts +2 -0
- package/lib/server/devices/hmIPDevices/hmIpTherm.js +9 -0
- package/lib/server/devices/scene/room-scene.d.ts +1 -0
- package/lib/server/devices/scene/room-scene.js +1 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.d.ts +2 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +9 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.d.ts +2 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.js +9 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +2 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +9 -0
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.d.ts +2 -0
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.js +9 -0
- package/lib/server/devices/zigbee/zigbeeAquaraWater.d.ts +2 -0
- package/lib/server/devices/zigbee/zigbeeAquaraWater.js +9 -0
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.d.ts +2 -0
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.js +9 -0
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.d.ts +2 -0
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +9 -0
- package/lib/server/services/time-callback-service.js +4 -2
- package/lib/server/services/utils/utils.d.ts +1 -0
- package/lib/server/services/utils/utils.js +14 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -35,18 +35,15 @@ class TimeCallback {
|
|
|
35
35
|
today.setHours(0, 0, 0, 0);
|
|
36
36
|
switch (this.type) {
|
|
37
37
|
case TimeCallbackType.TimeOfDay:
|
|
38
|
+
// !!WARNING!! Changing to winter time, that day has 25 hours.
|
|
38
39
|
if (this.hours === undefined) {
|
|
39
40
|
this.hours = 0;
|
|
40
41
|
}
|
|
41
42
|
if (this.minutes === undefined) {
|
|
42
43
|
this.minutes = 0;
|
|
43
44
|
}
|
|
44
|
-
this.nextToDo =
|
|
45
|
-
|
|
46
|
-
// Heute ist schon abgelaufen, also morgen festlegen
|
|
47
|
-
this.nextToDo = new Date(this.nextToDo.getTime() + 24 * 60 * 60 * 1000);
|
|
48
|
-
}
|
|
49
|
-
server_1.ServerLogService.writeLog(logLevel_1.LogLevel.Trace, `Nächste Zeitevent für "${this.name}" um ${this.nextToDo.toLocaleTimeString('de-DE')}`);
|
|
45
|
+
this.nextToDo = server_1.Utils.nextMatchingDate(this.hours, this.minutes + this.minuteOffset);
|
|
46
|
+
server_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Next Time event for "${this.name}" at ${this.nextToDo.toLocaleString('de-DE')}`);
|
|
50
47
|
break;
|
|
51
48
|
case TimeCallbackType.Sunrise:
|
|
52
49
|
if (this.cloudOffset === undefined) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { iRoomDevice } from './index';
|
|
3
3
|
import { SceneSettings } from '../../../models/deviceSettings/sceneSettings';
|
|
4
4
|
export interface iScene extends iRoomDevice {
|
|
5
|
+
description: string;
|
|
5
6
|
readonly onSceneStart: () => void;
|
|
6
7
|
readonly onSceneEnd: () => void;
|
|
7
8
|
readonly on: boolean;
|
|
@@ -8,6 +8,8 @@ import { HmIPDevice } from './hmIpDevice';
|
|
|
8
8
|
import { iBatteryDevice, iHandleSensor } from '../baseDeviceInterfaces';
|
|
9
9
|
export declare class HmIpGriff extends HmIPDevice implements iHandleSensor, iBatteryDevice, iDisposable {
|
|
10
10
|
private _battery;
|
|
11
|
+
private _lastBatteryPersist;
|
|
12
|
+
get lastBatteryPersist(): number;
|
|
11
13
|
get battery(): number;
|
|
12
14
|
position: WindowPosition;
|
|
13
15
|
private _kippCallback;
|
|
@@ -15,6 +15,7 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
|
15
15
|
constructor(pInfo) {
|
|
16
16
|
super(pInfo, deviceType_1.DeviceType.HmIpGriff);
|
|
17
17
|
this._battery = -99;
|
|
18
|
+
this._lastBatteryPersist = 0;
|
|
18
19
|
this.position = models_1.WindowPosition.geschlossen;
|
|
19
20
|
this._kippCallback = [];
|
|
20
21
|
this._closedCallback = [];
|
|
@@ -25,6 +26,9 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
|
25
26
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.handleSensor);
|
|
26
27
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
27
28
|
}
|
|
29
|
+
get lastBatteryPersist() {
|
|
30
|
+
return this._lastBatteryPersist;
|
|
31
|
+
}
|
|
28
32
|
get battery() {
|
|
29
33
|
return this._battery;
|
|
30
34
|
}
|
|
@@ -139,7 +143,12 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
|
139
143
|
}
|
|
140
144
|
persistBatteryDevice() {
|
|
141
145
|
var _a;
|
|
146
|
+
const now = services_1.Utils.nowMS();
|
|
147
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
142
150
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
151
|
+
this._lastBatteryPersist = now;
|
|
143
152
|
}
|
|
144
153
|
dispose() {
|
|
145
154
|
if (this._iOpenTimeout) {
|
|
@@ -7,6 +7,8 @@ export declare class HmIpHeizung extends HmIPDevice implements iBatteryDevice {
|
|
|
7
7
|
private _temperatur;
|
|
8
8
|
private _level;
|
|
9
9
|
private _adaptionState;
|
|
10
|
+
private _lastBatteryPersist;
|
|
11
|
+
get lastBatteryPersist(): number;
|
|
10
12
|
get battery(): number;
|
|
11
13
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
12
14
|
private _desiredTemperatur;
|
|
@@ -24,9 +24,13 @@ class HmIpHeizung extends hmIpDevice_1.HmIPDevice {
|
|
|
24
24
|
this._battery = -99;
|
|
25
25
|
this._temperatur = 0;
|
|
26
26
|
this._level = 0;
|
|
27
|
+
this._lastBatteryPersist = 0;
|
|
27
28
|
this._desiredTemperatur = 0;
|
|
28
29
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
29
30
|
}
|
|
31
|
+
get lastBatteryPersist() {
|
|
32
|
+
return this._lastBatteryPersist;
|
|
33
|
+
}
|
|
30
34
|
get battery() {
|
|
31
35
|
return this._battery;
|
|
32
36
|
}
|
|
@@ -79,7 +83,12 @@ class HmIpHeizung extends hmIpDevice_1.HmIPDevice {
|
|
|
79
83
|
}
|
|
80
84
|
persistBatteryDevice() {
|
|
81
85
|
var _a;
|
|
86
|
+
const now = services_1.Utils.nowMS();
|
|
87
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
82
90
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
91
|
+
this._lastBatteryPersist = now;
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
exports.HmIpHeizung = HmIpHeizung;
|
|
@@ -5,6 +5,8 @@ import { iBatteryDevice, iIlluminationSensor, iMotionSensor } from '../baseDevic
|
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
6
|
export declare class HmIpPraezenz extends HmIPDevice implements iIlluminationSensor, iBatteryDevice, iMotionSensor {
|
|
7
7
|
private _battery;
|
|
8
|
+
private _lastBatteryPersist;
|
|
9
|
+
get lastBatteryPersist(): number;
|
|
8
10
|
private static PRESENCE_DETECTION;
|
|
9
11
|
private static CURRENT_ILLUMINATION;
|
|
10
12
|
excludeFromNightAlarm: boolean;
|
|
@@ -11,6 +11,7 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
|
11
11
|
var _a;
|
|
12
12
|
super(pInfo, deviceType_1.DeviceType.HmIpPraezenz);
|
|
13
13
|
this._battery = -99;
|
|
14
|
+
this._lastBatteryPersist = 0;
|
|
14
15
|
this.excludeFromNightAlarm = false;
|
|
15
16
|
this.movementDetected = false;
|
|
16
17
|
this.settings = new models_1.MotionSensorSettings();
|
|
@@ -38,6 +39,9 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
get lastBatteryPersist() {
|
|
43
|
+
return this._lastBatteryPersist;
|
|
44
|
+
}
|
|
41
45
|
get battery() {
|
|
42
46
|
return this._battery;
|
|
43
47
|
}
|
|
@@ -115,7 +119,12 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
|
115
119
|
}
|
|
116
120
|
persistBatteryDevice() {
|
|
117
121
|
var _a;
|
|
122
|
+
const now = services_1.Utils.nowMS();
|
|
123
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
118
126
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
127
|
+
this._lastBatteryPersist = now;
|
|
119
128
|
}
|
|
120
129
|
}
|
|
121
130
|
exports.HmIpPraezenz = HmIpPraezenz;
|
|
@@ -5,6 +5,8 @@ import { Button, ButtonPressType } from '../button';
|
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
6
|
export declare class HmIpTaster extends HmIPDevice implements iButtonSwitch, iBatteryDevice {
|
|
7
7
|
private _battery;
|
|
8
|
+
private _lastBatteryPersist;
|
|
9
|
+
get lastBatteryPersist(): number;
|
|
8
10
|
private static readonly BUTTON_CAPABILLITIES;
|
|
9
11
|
buttonTopLeft: Button;
|
|
10
12
|
buttonMidLeft: Button;
|
|
@@ -11,6 +11,7 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
11
11
|
constructor(pInfo) {
|
|
12
12
|
super(pInfo, deviceType_1.DeviceType.HmIpTaster);
|
|
13
13
|
this._battery = -99;
|
|
14
|
+
this._lastBatteryPersist = 0;
|
|
14
15
|
this.buttonBot = undefined;
|
|
15
16
|
this.buttonTop = undefined;
|
|
16
17
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.buttonSwitch);
|
|
@@ -22,6 +23,9 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
22
23
|
this.buttonMidRight = new button_1.Button('MidRight', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
23
24
|
this.buttonBotRight = new button_1.Button('BotRight', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
24
25
|
}
|
|
26
|
+
get lastBatteryPersist() {
|
|
27
|
+
return this._lastBatteryPersist;
|
|
28
|
+
}
|
|
25
29
|
get battery() {
|
|
26
30
|
return this._battery;
|
|
27
31
|
}
|
|
@@ -111,7 +115,12 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
111
115
|
}
|
|
112
116
|
persistBatteryDevice() {
|
|
113
117
|
var _a;
|
|
118
|
+
const now = services_1.Utils.nowMS();
|
|
119
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
114
122
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
123
|
+
this._lastBatteryPersist = now;
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
126
|
exports.HmIpTaster = HmIpTaster;
|
|
@@ -4,6 +4,8 @@ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
|
4
4
|
import { iBatteryDevice } from '../baseDeviceInterfaces';
|
|
5
5
|
export declare class HmIpTherm extends HmIPDevice implements iBatteryDevice {
|
|
6
6
|
private _battery;
|
|
7
|
+
private _lastBatteryPersist;
|
|
8
|
+
get lastBatteryPersist(): number;
|
|
7
9
|
get battery(): number;
|
|
8
10
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
9
11
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
@@ -10,8 +10,12 @@ class HmIpTherm extends hmIpDevice_1.HmIPDevice {
|
|
|
10
10
|
constructor(pInfo) {
|
|
11
11
|
super(pInfo, deviceType_1.DeviceType.HmIpTherm);
|
|
12
12
|
this._battery = -99;
|
|
13
|
+
this._lastBatteryPersist = 0;
|
|
13
14
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
14
15
|
}
|
|
16
|
+
get lastBatteryPersist() {
|
|
17
|
+
return this._lastBatteryPersist;
|
|
18
|
+
}
|
|
15
19
|
get battery() {
|
|
16
20
|
return this._battery;
|
|
17
21
|
}
|
|
@@ -31,7 +35,12 @@ class HmIpTherm extends hmIpDevice_1.HmIPDevice {
|
|
|
31
35
|
}
|
|
32
36
|
persistBatteryDevice() {
|
|
33
37
|
var _a;
|
|
38
|
+
const now = services_1.Utils.nowMS();
|
|
39
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
34
42
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
43
|
+
this._lastBatteryPersist = now;
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
exports.HmIpTherm = HmIpTherm;
|
|
@@ -8,6 +8,7 @@ import { DeviceCapability } from '../DeviceCapability';
|
|
|
8
8
|
import { DeviceType } from '../deviceType';
|
|
9
9
|
import { SceneSettings } from '../../../models/deviceSettings/sceneSettings';
|
|
10
10
|
export declare class RoomScene implements iScene {
|
|
11
|
+
description: string;
|
|
11
12
|
room: RoomBase | undefined;
|
|
12
13
|
settings: SceneSettings;
|
|
13
14
|
private readonly _onSceneStart;
|
|
@@ -14,6 +14,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
14
14
|
const sceneSettings_1 = require("../../../models/deviceSettings/sceneSettings");
|
|
15
15
|
class RoomScene {
|
|
16
16
|
constructor(name, room, onSceneStart, onSceneEnd, turnOffTimeout) {
|
|
17
|
+
this.description = '';
|
|
17
18
|
this.settings = new sceneSettings_1.SceneSettings();
|
|
18
19
|
this._automaticEndTimeout = null;
|
|
19
20
|
this._deviceCapabilities = [DeviceCapability_1.DeviceCapability.scene];
|
|
@@ -8,6 +8,8 @@ import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
|
8
8
|
import { PIDController } from '../../../../liquid-pid';
|
|
9
9
|
export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatteryDevice {
|
|
10
10
|
protected _battery: number;
|
|
11
|
+
private _lastBatteryPersist;
|
|
12
|
+
get lastBatteryPersist(): number;
|
|
11
13
|
readonly persistHeaterInterval: NodeJS.Timeout;
|
|
12
14
|
settings: HeaterSettings;
|
|
13
15
|
get battery(): number;
|
|
@@ -11,6 +11,7 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
11
11
|
constructor(pInfo, pType) {
|
|
12
12
|
super(pInfo, pType);
|
|
13
13
|
this._battery = -99;
|
|
14
|
+
this._lastBatteryPersist = 0;
|
|
14
15
|
this.persistHeaterInterval = services_1.Utils.guardedInterval(() => {
|
|
15
16
|
this.persistHeater();
|
|
16
17
|
}, 5 * 60 * 1000, this, false);
|
|
@@ -41,6 +42,9 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
41
42
|
this.checkSeasonTurnOff();
|
|
42
43
|
}, 0, 2, 0));
|
|
43
44
|
}
|
|
45
|
+
get lastBatteryPersist() {
|
|
46
|
+
return this._lastBatteryPersist;
|
|
47
|
+
}
|
|
44
48
|
get battery() {
|
|
45
49
|
return this._battery;
|
|
46
50
|
}
|
|
@@ -156,7 +160,12 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
156
160
|
}
|
|
157
161
|
persistBatteryDevice() {
|
|
158
162
|
var _a;
|
|
163
|
+
const now = services_1.Utils.nowMS();
|
|
164
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
159
167
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
168
|
+
this._lastBatteryPersist = now;
|
|
160
169
|
}
|
|
161
170
|
dispose() {
|
|
162
171
|
if (this.persistHeaterInterval) {
|
|
@@ -6,6 +6,8 @@ import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
|
6
6
|
import { iBatteryDevice } from '../../baseDeviceInterfaces';
|
|
7
7
|
export declare class ZigbeeMagnetContact extends ZigbeeDevice implements iBatteryDevice {
|
|
8
8
|
protected _battery: number;
|
|
9
|
+
private _lastBatteryPersist;
|
|
10
|
+
get lastBatteryPersist(): number;
|
|
9
11
|
get battery(): number;
|
|
10
12
|
position: MagnetPosition;
|
|
11
13
|
telegramOnOpen: boolean;
|
|
@@ -9,6 +9,7 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
9
9
|
constructor(pInfo, deviceType) {
|
|
10
10
|
super(pInfo, deviceType);
|
|
11
11
|
this._battery = -99;
|
|
12
|
+
this._lastBatteryPersist = 0;
|
|
12
13
|
this.position = models_2.MagnetPosition.closed;
|
|
13
14
|
this.telegramOnOpen = false;
|
|
14
15
|
this.speakOnOpen = false;
|
|
@@ -16,6 +17,9 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
16
17
|
this._openCallback = [];
|
|
17
18
|
this.minutesOpen = 0;
|
|
18
19
|
}
|
|
20
|
+
get lastBatteryPersist() {
|
|
21
|
+
return this._lastBatteryPersist;
|
|
22
|
+
}
|
|
19
23
|
get battery() {
|
|
20
24
|
return this._battery;
|
|
21
25
|
}
|
|
@@ -103,7 +107,12 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
103
107
|
}
|
|
104
108
|
persistBatteryDevice() {
|
|
105
109
|
var _a;
|
|
110
|
+
const now = services_1.Utils.nowMS();
|
|
111
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
106
114
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
115
|
+
this._lastBatteryPersist = now;
|
|
107
116
|
}
|
|
108
117
|
}
|
|
109
118
|
exports.ZigbeeMagnetContact = ZigbeeMagnetContact;
|
|
@@ -7,6 +7,8 @@ import { iBatteryDevice, iMotionSensor } from '../../baseDeviceInterfaces';
|
|
|
7
7
|
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
8
8
|
export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionSensor, iBatteryDevice {
|
|
9
9
|
private _battery;
|
|
10
|
+
private _lastBatteryPersist;
|
|
11
|
+
get lastBatteryPersist(): number;
|
|
10
12
|
settings: MotionSensorSettings;
|
|
11
13
|
movementDetected: boolean;
|
|
12
14
|
get battery(): number;
|
|
@@ -10,6 +10,7 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
10
10
|
var _a;
|
|
11
11
|
super(pInfo, type);
|
|
12
12
|
this._battery = -99;
|
|
13
|
+
this._lastBatteryPersist = 0;
|
|
13
14
|
this.settings = new models_1.MotionSensorSettings();
|
|
14
15
|
this.movementDetected = false;
|
|
15
16
|
this._initialized = false;
|
|
@@ -34,6 +35,9 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
}
|
|
38
|
+
get lastBatteryPersist() {
|
|
39
|
+
return this._lastBatteryPersist;
|
|
40
|
+
}
|
|
37
41
|
get battery() {
|
|
38
42
|
return this._battery;
|
|
39
43
|
}
|
|
@@ -127,7 +131,12 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
127
131
|
}
|
|
128
132
|
persistBatteryDevice() {
|
|
129
133
|
var _a;
|
|
134
|
+
const now = services_1.Utils.nowMS();
|
|
135
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
130
138
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
139
|
+
this._lastBatteryPersist = now;
|
|
131
140
|
}
|
|
132
141
|
}
|
|
133
142
|
exports.ZigbeeMotionSensor = ZigbeeMotionSensor;
|
|
@@ -4,6 +4,8 @@ import { ZigbeeDevice } from './BaseDevices';
|
|
|
4
4
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
5
5
|
export declare class ZigbeeAquaraVibra extends ZigbeeDevice implements iVibrationSensor, iBatteryDevice {
|
|
6
6
|
private _battery;
|
|
7
|
+
private _lastBatteryPersist;
|
|
8
|
+
get lastBatteryPersist(): number;
|
|
7
9
|
get battery(): number;
|
|
8
10
|
sensitivity: string;
|
|
9
11
|
tiltAngle: number;
|
|
@@ -10,6 +10,7 @@ class ZigbeeAquaraVibra extends BaseDevices_1.ZigbeeDevice {
|
|
|
10
10
|
constructor(pInfo) {
|
|
11
11
|
super(pInfo, deviceType_1.DeviceType.ZigbeeAquaraVibra);
|
|
12
12
|
this._battery = -99;
|
|
13
|
+
this._lastBatteryPersist = 0;
|
|
13
14
|
this.sensitivity = '';
|
|
14
15
|
this.tiltAngle = 0;
|
|
15
16
|
this.tiltAngleX = 0;
|
|
@@ -31,6 +32,9 @@ class ZigbeeAquaraVibra extends BaseDevices_1.ZigbeeDevice {
|
|
|
31
32
|
services_1.PollyService.preloadTTS(this._alarmMessage);
|
|
32
33
|
this._idSensitivity = `${this.info.fullID}.sensitivity`;
|
|
33
34
|
}
|
|
35
|
+
get lastBatteryPersist() {
|
|
36
|
+
return this._lastBatteryPersist;
|
|
37
|
+
}
|
|
34
38
|
get battery() {
|
|
35
39
|
return this._battery;
|
|
36
40
|
}
|
|
@@ -143,7 +147,12 @@ class ZigbeeAquaraVibra extends BaseDevices_1.ZigbeeDevice {
|
|
|
143
147
|
}
|
|
144
148
|
persistBatteryDevice() {
|
|
145
149
|
var _a;
|
|
150
|
+
const now = services_1.Utils.nowMS();
|
|
151
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
146
154
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
155
|
+
this._lastBatteryPersist = now;
|
|
147
156
|
}
|
|
148
157
|
}
|
|
149
158
|
exports.ZigbeeAquaraVibra = ZigbeeAquaraVibra;
|
|
@@ -5,6 +5,8 @@ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
|
5
5
|
import { iBatteryDevice } from '../baseDeviceInterfaces';
|
|
6
6
|
export declare class ZigbeeAquaraWater extends ZigbeeDevice implements iBatteryDevice {
|
|
7
7
|
private _battery;
|
|
8
|
+
private _lastBatteryPersist;
|
|
9
|
+
get lastBatteryPersist(): number;
|
|
8
10
|
get battery(): number;
|
|
9
11
|
water: boolean;
|
|
10
12
|
iAlarmTimeout: NodeJS.Timeout | undefined;
|
|
@@ -10,6 +10,7 @@ class ZigbeeAquaraWater extends BaseDevices_1.ZigbeeDevice {
|
|
|
10
10
|
constructor(pInfo) {
|
|
11
11
|
super(pInfo, deviceType_1.DeviceType.ZigbeeAquaraWater);
|
|
12
12
|
this._battery = -99;
|
|
13
|
+
this._lastBatteryPersist = 0;
|
|
13
14
|
this.water = false;
|
|
14
15
|
this.iAlarmTimeout = undefined;
|
|
15
16
|
this._messageAlarmFirst = '';
|
|
@@ -22,6 +23,9 @@ class ZigbeeAquaraWater extends BaseDevices_1.ZigbeeDevice {
|
|
|
22
23
|
this._messageAlarm = services_1.Res.waterAlarmRepeat(this.info.customName, this._roomName);
|
|
23
24
|
this._messageAlarmEnd = services_1.Res.waterAlarmEnd(this._roomName);
|
|
24
25
|
}
|
|
26
|
+
get lastBatteryPersist() {
|
|
27
|
+
return this._lastBatteryPersist;
|
|
28
|
+
}
|
|
25
29
|
get battery() {
|
|
26
30
|
return this._battery;
|
|
27
31
|
}
|
|
@@ -100,7 +104,12 @@ class ZigbeeAquaraWater extends BaseDevices_1.ZigbeeDevice {
|
|
|
100
104
|
}
|
|
101
105
|
persistBatteryDevice() {
|
|
102
106
|
var _a;
|
|
107
|
+
const now = services_1.Utils.nowMS();
|
|
108
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
103
111
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
112
|
+
this._lastBatteryPersist = now;
|
|
104
113
|
}
|
|
105
114
|
dispose() {
|
|
106
115
|
if (this.iAlarmTimeout) {
|
|
@@ -5,6 +5,8 @@ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
|
5
5
|
import { iBatteryDevice } from '../baseDeviceInterfaces';
|
|
6
6
|
export declare class ZigbeeHeimanSmoke extends ZigbeeDevice implements iBatteryDevice {
|
|
7
7
|
private _battery;
|
|
8
|
+
private _lastBatteryPersist;
|
|
9
|
+
get lastBatteryPersist(): number;
|
|
8
10
|
get battery(): number;
|
|
9
11
|
smoke: boolean;
|
|
10
12
|
iAlarmTimeout: NodeJS.Timeout | undefined;
|
|
@@ -10,6 +10,7 @@ class ZigbeeHeimanSmoke extends BaseDevices_1.ZigbeeDevice {
|
|
|
10
10
|
constructor(pInfo) {
|
|
11
11
|
super(pInfo, deviceType_1.DeviceType.ZigbeeHeimanSmoke);
|
|
12
12
|
this._battery = -99;
|
|
13
|
+
this._lastBatteryPersist = 0;
|
|
13
14
|
this.smoke = false;
|
|
14
15
|
this.iAlarmTimeout = undefined;
|
|
15
16
|
this._messageAlarmFirst = '';
|
|
@@ -21,6 +22,9 @@ class ZigbeeHeimanSmoke extends BaseDevices_1.ZigbeeDevice {
|
|
|
21
22
|
this._messageAlarm = services_1.Res.fireAlarmRepeat(this._roomName, this.info.customName);
|
|
22
23
|
this._messageAlarmEnd = services_1.Res.fireAlarmEnd(this._roomName);
|
|
23
24
|
}
|
|
25
|
+
get lastBatteryPersist() {
|
|
26
|
+
return this._lastBatteryPersist;
|
|
27
|
+
}
|
|
24
28
|
get battery() {
|
|
25
29
|
return this._battery;
|
|
26
30
|
}
|
|
@@ -96,7 +100,12 @@ class ZigbeeHeimanSmoke extends BaseDevices_1.ZigbeeDevice {
|
|
|
96
100
|
}
|
|
97
101
|
persistBatteryDevice() {
|
|
98
102
|
var _a;
|
|
103
|
+
const now = services_1.Utils.nowMS();
|
|
104
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
99
107
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
108
|
+
this._lastBatteryPersist = now;
|
|
100
109
|
}
|
|
101
110
|
dispose() {
|
|
102
111
|
if (this.iAlarmTimeout) {
|
|
@@ -5,6 +5,8 @@ import { iBatteryDevice, iHumiditySensor, iTemperatureSensor } from '../baseDevi
|
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
6
|
export declare class ZigbeeSonoffTemp extends ZigbeeDevice implements iTemperatureSensor, iHumiditySensor, iBatteryDevice {
|
|
7
7
|
private _battery;
|
|
8
|
+
private _lastBatteryPersist;
|
|
9
|
+
get lastBatteryPersist(): number;
|
|
8
10
|
readonly persistTemperatureSensorInterval: NodeJS.Timeout;
|
|
9
11
|
readonly persistHumiditySensorInterval: NodeJS.Timeout;
|
|
10
12
|
get battery(): number;
|
|
@@ -11,6 +11,7 @@ class ZigbeeSonoffTemp extends BaseDevices_1.ZigbeeDevice {
|
|
|
11
11
|
constructor(pInfo) {
|
|
12
12
|
super(pInfo, deviceType_1.DeviceType.ZigbeeSonoffTemp);
|
|
13
13
|
this._battery = -99;
|
|
14
|
+
this._lastBatteryPersist = 0;
|
|
14
15
|
this.persistTemperatureSensorInterval = services_1.Utils.guardedInterval(() => {
|
|
15
16
|
this.persistTemperaturSensor();
|
|
16
17
|
}, 5 * 60 * 1000, this, false);
|
|
@@ -26,6 +27,9 @@ class ZigbeeSonoffTemp extends BaseDevices_1.ZigbeeDevice {
|
|
|
26
27
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.humiditySensor);
|
|
27
28
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
28
29
|
}
|
|
30
|
+
get lastBatteryPersist() {
|
|
31
|
+
return this._lastBatteryPersist;
|
|
32
|
+
}
|
|
29
33
|
get battery() {
|
|
30
34
|
return this._battery;
|
|
31
35
|
}
|
|
@@ -99,7 +103,12 @@ class ZigbeeSonoffTemp extends BaseDevices_1.ZigbeeDevice {
|
|
|
99
103
|
}
|
|
100
104
|
persistBatteryDevice() {
|
|
101
105
|
var _a;
|
|
106
|
+
const now = services_1.Utils.nowMS();
|
|
107
|
+
if (this._lastBatteryPersist + 60000 < now) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
102
110
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
111
|
+
this._lastBatteryPersist = now;
|
|
103
112
|
}
|
|
104
113
|
dispose() {
|
|
105
114
|
if (this.persistTemperatureSensorInterval) {
|
|
@@ -150,8 +150,10 @@ class TimeCallbackService {
|
|
|
150
150
|
TimeCallbackService._todaySunSet = (0, sunrise_sunset_js_1.getSunset)(settings_service_1.SettingsService.latitude, settings_service_1.SettingsService.longitude, calculationDate);
|
|
151
151
|
TimeCallbackService.updateSunSet();
|
|
152
152
|
TimeCallbackService.updateSunRise();
|
|
153
|
-
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `
|
|
154
|
-
|
|
153
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Today Sunrise: ${TimeCallbackService._todaySunRise.toLocaleString('de-DE')}
|
|
154
|
+
Today Sunset: ${TimeCallbackService._todaySunSet.toLocaleString('de-DE')}
|
|
155
|
+
Next Sunrise: ${TimeCallbackService._nextSunRise.toLocaleString('de-DE')}
|
|
156
|
+
Next Sunset: ${TimeCallbackService._nextSunSet.toLocaleString('de-DE')}`);
|
|
155
157
|
}
|
|
156
158
|
static removeCallback(pCallback) {
|
|
157
159
|
for (let i = 0; i < TimeCallbackService._callbacks.length; i++) {
|
|
@@ -30,4 +30,5 @@ export declare class Utils {
|
|
|
30
30
|
static positiveMod(number: number, mod: number): number;
|
|
31
31
|
static degreeInBetween(minDegree: number, maxDegree: number, degreeToCheck: number): boolean;
|
|
32
32
|
private static deepOmit;
|
|
33
|
+
static nextMatchingDate(hours?: number, minutes?: number, now?: Date): Date;
|
|
33
34
|
}
|
|
@@ -194,5 +194,19 @@ class Utils {
|
|
|
194
194
|
result[key] = lodash_1.default.isObject(value) ? this.deepOmit(value, keysToOmit) : value;
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
|
+
static nextMatchingDate(hours = 0, minutes = 0, now = new Date()) {
|
|
198
|
+
const todayOption = new Date(now.getTime());
|
|
199
|
+
todayOption.setHours(hours, minutes, 0, 0);
|
|
200
|
+
if (todayOption > now) {
|
|
201
|
+
// Today Option is in the future --> valid
|
|
202
|
+
return todayOption;
|
|
203
|
+
}
|
|
204
|
+
const todayMidnight = new Date(now.getTime());
|
|
205
|
+
todayMidnight.setHours(0, 0, 0, 0);
|
|
206
|
+
// 26 to guarantee matching next day even with time changes
|
|
207
|
+
const tomorowOption = new Date(todayMidnight.getTime() + 26 * 60 * 60 * 1000);
|
|
208
|
+
tomorowOption.setHours(hours, minutes, 0, 0);
|
|
209
|
+
return tomorowOption;
|
|
210
|
+
}
|
|
197
211
|
}
|
|
198
212
|
exports.Utils = Utils;
|