hoffmation-base 3.0.0-alpha.89 → 3.0.0-alpha.90
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/action/batteryLevelChangeAction.js +2 -2
- package/lib/models/iJsonOmitKeys.d.ts +9 -0
- package/lib/models/iJsonOmitKeys.js +2 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/server/devices/IoBrokerBaseDevice.d.ts +4 -2
- package/lib/server/devices/IoBrokerBaseDevice.js +3 -1
- package/lib/server/devices/baseDeviceInterfaces/iBatteryDevice.d.ts +4 -13
- package/lib/server/devices/baseDeviceInterfaces/iHandleSensor.d.ts +10 -0
- package/lib/server/devices/baseDeviceInterfaces/iHumiditySensor.d.ts +3 -7
- package/lib/server/devices/baseDeviceInterfaces/iTemperatureSensor.d.ts +3 -7
- package/lib/server/devices/dachs/dachs.js +2 -5
- package/lib/server/devices/dachs/dachsTemperatureSensor.d.ts +2 -7
- package/lib/server/devices/dachs/dachsTemperatureSensor.js +9 -31
- package/lib/server/devices/deviceType.d.ts +1 -0
- package/lib/server/devices/deviceType.js +1 -0
- package/lib/server/devices/devices.js +5 -2
- package/lib/server/devices/groups/Window.d.ts +2 -3
- package/lib/server/devices/groups/Window.js +3 -3
- package/lib/server/devices/groups/windowGroup.js +2 -2
- package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +9 -35
- package/lib/server/devices/hmIPDevices/hmIpGriff.js +27 -171
- package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.d.ts +5 -13
- package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.js +30 -66
- package/lib/server/devices/hmIPDevices/hmIpHeizung.d.ts +4 -14
- package/lib/server/devices/hmIPDevices/hmIpHeizung.js +6 -39
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +5 -14
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +6 -38
- package/lib/server/devices/hmIPDevices/hmIpRoll.js +2 -2
- package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +4 -14
- package/lib/server/devices/hmIPDevices/hmIpTaster.js +6 -38
- package/lib/server/devices/hmIPDevices/hmIpTherm.d.ts +4 -14
- package/lib/server/devices/hmIPDevices/hmIpTherm.js +6 -39
- package/lib/server/devices/models/WindowPosition.d.ts +3 -3
- package/lib/server/devices/models/WindowPosition.js +3 -3
- package/lib/server/devices/sharedFunctions/battery.d.ts +31 -0
- package/lib/server/devices/sharedFunctions/battery.js +65 -0
- package/lib/server/devices/sharedFunctions/handleSensor.d.ts +45 -0
- package/lib/server/devices/sharedFunctions/handleSensor.js +150 -0
- package/lib/server/devices/sharedFunctions/humiditySensor.d.ts +18 -0
- package/lib/server/devices/sharedFunctions/humiditySensor.js +46 -0
- package/lib/server/devices/sharedFunctions/index.d.ts +4 -0
- package/lib/server/devices/sharedFunctions/index.js +4 -0
- package/lib/server/devices/sharedFunctions/temperatureSensor.d.ts +31 -0
- package/lib/server/devices/sharedFunctions/temperatureSensor.js +57 -0
- package/lib/server/devices/shelly/shellyTrv.d.ts +5 -16
- package/lib/server/devices/shelly/shellyTrv.js +7 -41
- package/lib/server/devices/smartGarden/smartGardenDevice.d.ts +4 -16
- package/lib/server/devices/smartGarden/smartGardenDevice.js +7 -42
- package/lib/server/devices/smartGarden/smartGardenSensor.d.ts +3 -13
- package/lib/server/devices/smartGarden/smartGardenSensor.js +14 -57
- package/lib/server/devices/velux/veluxShutter.js +2 -2
- package/lib/server/devices/zigbee/BaseDevices/index.d.ts +1 -0
- package/lib/server/devices/zigbee/BaseDevices/index.js +3 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.d.ts +5 -15
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +7 -40
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.d.ts +4 -15
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.js +7 -40
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +5 -16
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +7 -41
- package/lib/server/devices/zigbee/BaseDevices/zigbeeShutter.js +2 -2
- package/lib/server/devices/zigbee/BaseDevices/zigbeeWindowHandle.d.ts +36 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeWindowHandle.js +82 -0
- package/lib/server/devices/zigbee/index.d.ts +1 -0
- package/lib/server/devices/zigbee/index.js +1 -0
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.d.ts +4 -16
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.js +7 -41
- package/lib/server/devices/zigbee/zigbeeAquaraWater.d.ts +4 -16
- package/lib/server/devices/zigbee/zigbeeAquaraWater.js +7 -41
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.d.ts +4 -16
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.js +7 -41
- package/lib/server/devices/zigbee/zigbeeSodaHandle.d.ts +34 -0
- package/lib/server/devices/zigbee/zigbeeSodaHandle.js +96 -0
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.d.ts +7 -27
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +21 -94
- package/lib/server/services/dbo/postgreSqlPersist.js +1 -1
- package/lib/server/services/utils/utils.js +5 -1
- package/lib/server/services/victron/victron-device.d.ts +8 -15
- package/lib/server/services/victron/victron-device.js +22 -51
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ZigbeeDevice } from './zigbeeDevice';
|
|
2
2
|
import { iBatteryDevice, iHeater } from '../../baseDeviceInterfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { HeaterSettings } from '../../../../models';
|
|
4
4
|
import { DeviceType } from '../../deviceType';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
6
6
|
import { PIDController } from '../../../../liquid-pid';
|
|
7
|
+
import { Battery } from '../../sharedFunctions';
|
|
7
8
|
export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatteryDevice {
|
|
9
|
+
/** @inheritDoc */
|
|
10
|
+
readonly battery: Battery;
|
|
8
11
|
/** @inheritDoc */
|
|
9
12
|
readonly persistHeaterInterval: NodeJS.Timeout;
|
|
10
13
|
/** @inheritDoc */
|
|
@@ -19,14 +22,9 @@ export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatt
|
|
|
19
22
|
protected _pidController: PIDController;
|
|
20
23
|
protected _seasonTurnOff: boolean;
|
|
21
24
|
protected _roomTemperature: number;
|
|
22
|
-
private _lastBatteryPersist;
|
|
23
|
-
private _lastBatteryLevel;
|
|
24
|
-
private _batteryLevelCallbacks;
|
|
25
25
|
constructor(pInfo: IoBrokerDeviceInfo, pType: DeviceType);
|
|
26
26
|
/** @inheritDoc */
|
|
27
|
-
get
|
|
28
|
-
/** @inheritDoc */
|
|
29
|
-
get battery(): number;
|
|
27
|
+
get batteryLevel(): number;
|
|
30
28
|
/** @inheritDoc */
|
|
31
29
|
get seasonTurnOff(): boolean;
|
|
32
30
|
/** @inheritDoc */
|
|
@@ -45,8 +43,6 @@ export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatt
|
|
|
45
43
|
get roomTemperature(): number;
|
|
46
44
|
protected set roomTemperatur(val: number);
|
|
47
45
|
/** @inheritDoc */
|
|
48
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
49
|
-
/** @inheritDoc */
|
|
50
46
|
checkAutomaticChange(): void;
|
|
51
47
|
/** @inheritDoc */
|
|
52
48
|
onTemperaturChange(newTemperatur: number): void;
|
|
@@ -54,13 +50,7 @@ export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatt
|
|
|
54
50
|
/** @inheritDoc */
|
|
55
51
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
|
|
56
52
|
/** @inheritDoc */
|
|
57
|
-
persistBatteryDevice(): void;
|
|
58
|
-
/** @inheritDoc */
|
|
59
53
|
dispose(): void;
|
|
60
54
|
protected getNextPidLevel(): number;
|
|
61
55
|
private checkSeasonTurnOff;
|
|
62
|
-
/**
|
|
63
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
64
|
-
*/
|
|
65
|
-
private checkForBatteryChange;
|
|
66
56
|
}
|
|
@@ -7,10 +7,13 @@ const models_1 = require("../../../../models");
|
|
|
7
7
|
const services_1 = require("../../../services");
|
|
8
8
|
const DeviceCapability_1 = require("../../DeviceCapability");
|
|
9
9
|
const liquid_pid_1 = require("../../../../liquid-pid");
|
|
10
|
+
const sharedFunctions_1 = require("../../sharedFunctions");
|
|
10
11
|
class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
11
12
|
constructor(pInfo, pType) {
|
|
12
13
|
super(pInfo, pType);
|
|
13
14
|
/** @inheritDoc */
|
|
15
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
16
|
+
/** @inheritDoc */
|
|
14
17
|
this.persistHeaterInterval = services_1.Utils.guardedInterval(() => {
|
|
15
18
|
this.persistHeater();
|
|
16
19
|
}, 5 * 60 * 1000, this, false);
|
|
@@ -34,9 +37,6 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
34
37
|
});
|
|
35
38
|
this._seasonTurnOff = false;
|
|
36
39
|
this._roomTemperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
|
|
37
|
-
this._lastBatteryPersist = 0;
|
|
38
|
-
this._lastBatteryLevel = -1;
|
|
39
|
-
this._batteryLevelCallbacks = [];
|
|
40
40
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.heater);
|
|
41
41
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
42
42
|
this._iAutomaticInterval = services_1.Utils.guardedInterval(this.checkAutomaticChange, 300000, this); // Alle 5 Minuten prüfen
|
|
@@ -45,12 +45,8 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
45
45
|
}, 0, 2, 0));
|
|
46
46
|
}
|
|
47
47
|
/** @inheritDoc */
|
|
48
|
-
get
|
|
49
|
-
return this.
|
|
50
|
-
}
|
|
51
|
-
/** @inheritDoc */
|
|
52
|
-
get battery() {
|
|
53
|
-
return this._battery;
|
|
48
|
+
get batteryLevel() {
|
|
49
|
+
return this.battery.level;
|
|
54
50
|
}
|
|
55
51
|
/** @inheritDoc */
|
|
56
52
|
get seasonTurnOff() {
|
|
@@ -100,10 +96,6 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
100
96
|
this._roomTemperature = val;
|
|
101
97
|
}
|
|
102
98
|
/** @inheritDoc */
|
|
103
|
-
addBatteryLevelCallback(pCallback) {
|
|
104
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
105
|
-
}
|
|
106
|
-
/** @inheritDoc */
|
|
107
99
|
checkAutomaticChange() {
|
|
108
100
|
var _a;
|
|
109
101
|
if (!this._initialSeasonCheckDone) {
|
|
@@ -139,10 +131,8 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
139
131
|
update(idSplit, state, initial = false, pOverride = false) {
|
|
140
132
|
switch (idSplit[3]) {
|
|
141
133
|
case 'battery':
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
144
|
-
this.persistBatteryDevice();
|
|
145
|
-
if (this._battery < 20) {
|
|
134
|
+
this.battery.level = state.val;
|
|
135
|
+
if (this.batteryLevel < 20) {
|
|
146
136
|
this.log(models_1.LogLevel.Warn, 'Das Zigbee Gerät hat unter 20% Batterie.');
|
|
147
137
|
}
|
|
148
138
|
break;
|
|
@@ -150,16 +140,6 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
150
140
|
super.update(idSplit, state, initial, pOverride);
|
|
151
141
|
}
|
|
152
142
|
/** @inheritDoc */
|
|
153
|
-
persistBatteryDevice() {
|
|
154
|
-
var _a;
|
|
155
|
-
const now = services_1.Utils.nowMS();
|
|
156
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
160
|
-
this._lastBatteryPersist = now;
|
|
161
|
-
}
|
|
162
|
-
/** @inheritDoc */
|
|
163
143
|
dispose() {
|
|
164
144
|
if (this.persistHeaterInterval) {
|
|
165
145
|
clearInterval(this.persistHeaterInterval);
|
|
@@ -187,18 +167,5 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
187
167
|
}
|
|
188
168
|
this._initialSeasonCheckDone = true;
|
|
189
169
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
192
|
-
*/
|
|
193
|
-
checkForBatteryChange() {
|
|
194
|
-
const newLevel = this.battery;
|
|
195
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
199
|
-
cb(new models_1.BatteryLevelChangeAction(this));
|
|
200
|
-
}
|
|
201
|
-
this._lastBatteryLevel = newLevel;
|
|
202
|
-
}
|
|
203
170
|
}
|
|
204
171
|
exports.ZigbeeHeater = ZigbeeHeater;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DeviceType } from '../../deviceType';
|
|
2
|
-
import { BatteryLevelChangeAction } from '../../../../models';
|
|
3
2
|
import { ZigbeeDevice } from './zigbeeDevice';
|
|
4
3
|
import { MagnetPosition } from '../../models';
|
|
5
4
|
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
6
5
|
import { iBatteryDevice, iMagnetSensor } from '../../baseDeviceInterfaces';
|
|
6
|
+
import { Battery } from '../../sharedFunctions';
|
|
7
7
|
export declare class ZigbeeMagnetContact extends ZigbeeDevice implements iBatteryDevice, iMagnetSensor {
|
|
8
|
+
/** @inheritDoc */
|
|
9
|
+
readonly battery: Battery;
|
|
8
10
|
/** @inheritDoc */
|
|
9
11
|
position: MagnetPosition;
|
|
10
12
|
/** @inheritDoc */
|
|
@@ -12,33 +14,20 @@ export declare class ZigbeeMagnetContact extends ZigbeeDevice implements iBatter
|
|
|
12
14
|
/** @inheritDoc */
|
|
13
15
|
speakOnOpen: boolean;
|
|
14
16
|
protected _battery: number;
|
|
15
|
-
private _lastBatteryPersist;
|
|
16
|
-
private _lastBatteryLevel;
|
|
17
|
-
private _batteryLevelCallbacks;
|
|
18
17
|
private _closedCallback;
|
|
19
18
|
private _openCallback;
|
|
20
19
|
private _iOpenTimeout;
|
|
21
20
|
private minutesOpen;
|
|
22
21
|
constructor(pInfo: IoBrokerDeviceInfo, deviceType: DeviceType);
|
|
23
22
|
/** @inheritDoc */
|
|
24
|
-
get
|
|
25
|
-
/** @inheritDoc */
|
|
26
|
-
get battery(): number;
|
|
23
|
+
get batteryLevel(): number;
|
|
27
24
|
/** @inheritDoc */
|
|
28
25
|
addOpenCallback(pCallback: (pValue: boolean) => void): void;
|
|
29
26
|
/** @inheritDoc */
|
|
30
27
|
addClosedCallback(pCallback: (pValue: boolean) => void): void;
|
|
31
28
|
/** @inheritDoc */
|
|
32
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
33
|
-
/** @inheritDoc */
|
|
34
29
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverrride?: boolean): void;
|
|
35
30
|
/** @inheritDoc */
|
|
36
31
|
dispose(): void;
|
|
37
|
-
/** @inheritDoc */
|
|
38
|
-
persistBatteryDevice(): void;
|
|
39
32
|
protected updatePosition(pValue: MagnetPosition): void;
|
|
40
|
-
/**
|
|
41
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
42
|
-
*/
|
|
43
|
-
private checkForBatteryChange;
|
|
44
33
|
}
|
|
@@ -5,30 +5,26 @@ const services_1 = require("../../../services");
|
|
|
5
5
|
const models_1 = require("../../../../models");
|
|
6
6
|
const zigbeeDevice_1 = require("./zigbeeDevice");
|
|
7
7
|
const models_2 = require("../../models");
|
|
8
|
+
const sharedFunctions_1 = require("../../sharedFunctions");
|
|
8
9
|
class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
|
|
9
10
|
constructor(pInfo, deviceType) {
|
|
10
11
|
super(pInfo, deviceType);
|
|
11
12
|
/** @inheritDoc */
|
|
13
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
14
|
+
/** @inheritDoc */
|
|
12
15
|
this.position = models_2.MagnetPosition.closed;
|
|
13
16
|
/** @inheritDoc */
|
|
14
17
|
this.telegramOnOpen = false;
|
|
15
18
|
/** @inheritDoc */
|
|
16
19
|
this.speakOnOpen = false;
|
|
17
20
|
this._battery = -99;
|
|
18
|
-
this._lastBatteryPersist = 0;
|
|
19
|
-
this._lastBatteryLevel = -1;
|
|
20
|
-
this._batteryLevelCallbacks = [];
|
|
21
21
|
this._closedCallback = [];
|
|
22
22
|
this._openCallback = [];
|
|
23
23
|
this.minutesOpen = 0;
|
|
24
24
|
}
|
|
25
25
|
/** @inheritDoc */
|
|
26
|
-
get
|
|
27
|
-
return this.
|
|
28
|
-
}
|
|
29
|
-
/** @inheritDoc */
|
|
30
|
-
get battery() {
|
|
31
|
-
return this._battery;
|
|
26
|
+
get batteryLevel() {
|
|
27
|
+
return this.battery.level;
|
|
32
28
|
}
|
|
33
29
|
/** @inheritDoc */
|
|
34
30
|
addOpenCallback(pCallback) {
|
|
@@ -39,18 +35,12 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
39
35
|
this._closedCallback.push(pCallback);
|
|
40
36
|
}
|
|
41
37
|
/** @inheritDoc */
|
|
42
|
-
addBatteryLevelCallback(pCallback) {
|
|
43
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
44
|
-
}
|
|
45
|
-
/** @inheritDoc */
|
|
46
38
|
update(idSplit, state, initial = false, pOverrride = false) {
|
|
47
39
|
super.update(idSplit, state, initial, pOverrride);
|
|
48
40
|
switch (idSplit[3]) {
|
|
49
41
|
case 'battery':
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.persistBatteryDevice();
|
|
53
|
-
if (this._battery < 20) {
|
|
42
|
+
this.battery.level = state.val;
|
|
43
|
+
if (this.batteryLevel < 20) {
|
|
54
44
|
this.log(models_1.LogLevel.Warn, 'Das Zigbee Gerät hat unter 20% Batterie.');
|
|
55
45
|
}
|
|
56
46
|
break;
|
|
@@ -64,16 +54,6 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
64
54
|
}
|
|
65
55
|
super.dispose();
|
|
66
56
|
}
|
|
67
|
-
/** @inheritDoc */
|
|
68
|
-
persistBatteryDevice() {
|
|
69
|
-
var _a;
|
|
70
|
-
const now = services_1.Utils.nowMS();
|
|
71
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
75
|
-
this._lastBatteryPersist = now;
|
|
76
|
-
}
|
|
77
57
|
updatePosition(pValue) {
|
|
78
58
|
if (pValue === this.position) {
|
|
79
59
|
return;
|
|
@@ -131,18 +111,5 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
131
111
|
}, 60000, this);
|
|
132
112
|
}
|
|
133
113
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
136
|
-
*/
|
|
137
|
-
checkForBatteryChange() {
|
|
138
|
-
const newLevel = this.battery;
|
|
139
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
143
|
-
cb(new models_1.BatteryLevelChangeAction(this));
|
|
144
|
-
}
|
|
145
|
-
this._lastBatteryLevel = newLevel;
|
|
146
|
-
}
|
|
147
114
|
}
|
|
148
115
|
exports.ZigbeeMagnetContact = ZigbeeMagnetContact;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { DeviceType } from '../../deviceType';
|
|
2
2
|
import { ZigbeeDevice } from './index';
|
|
3
|
-
import {
|
|
3
|
+
import { MotionSensorAction, MotionSensorSettings } from '../../../../models';
|
|
4
4
|
import { iBatteryDevice, iMotionSensor } from '../../baseDeviceInterfaces';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
6
|
+
import { Battery } from '../../sharedFunctions';
|
|
6
7
|
export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionSensor, iBatteryDevice {
|
|
8
|
+
/** @inheritDoc */
|
|
9
|
+
readonly battery: Battery;
|
|
7
10
|
/** @inheritDoc */
|
|
8
11
|
settings: MotionSensorSettings;
|
|
9
12
|
/** @inheritDoc */
|
|
@@ -14,21 +17,13 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
|
|
|
14
17
|
protected _fallBackTimeout: NodeJS.Timeout | undefined;
|
|
15
18
|
protected _timeSinceLastMotion: number;
|
|
16
19
|
private _movementDetected;
|
|
17
|
-
private _battery;
|
|
18
|
-
private _lastBatteryPersist;
|
|
19
|
-
private _lastBatteryLevel;
|
|
20
|
-
private _batteryLevelCallbacks;
|
|
21
20
|
constructor(pInfo: IoBrokerDeviceInfo, type: DeviceType);
|
|
22
21
|
/** @inheritDoc */
|
|
23
|
-
get lastBatteryPersist(): number;
|
|
24
|
-
/** @inheritDoc */
|
|
25
22
|
get movementDetected(): boolean;
|
|
26
23
|
/** @inheritDoc */
|
|
27
|
-
get
|
|
24
|
+
get batteryLevel(): number;
|
|
28
25
|
/** @inheritDoc */
|
|
29
26
|
get timeSinceLastMotion(): number;
|
|
30
|
-
/** @inheritDoc */
|
|
31
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
32
27
|
/**
|
|
33
28
|
* Adds a callback for when a motion state has changed.
|
|
34
29
|
* @param pCallback - Function that accepts the new state as parameter
|
|
@@ -40,12 +35,6 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
|
|
|
40
35
|
updateMovement(newState: boolean): void;
|
|
41
36
|
/** @inheritDoc */
|
|
42
37
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
|
|
43
|
-
/** @inheritDoc */
|
|
44
|
-
persistBatteryDevice(): void;
|
|
45
38
|
private resetFallbackTimeout;
|
|
46
39
|
private startFallbackTimeout;
|
|
47
|
-
/**
|
|
48
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
49
|
-
*/
|
|
50
|
-
private checkForBatteryChange;
|
|
51
40
|
}
|
|
@@ -5,11 +5,14 @@ const index_1 = require("./index");
|
|
|
5
5
|
const models_1 = require("../../../../models");
|
|
6
6
|
const services_1 = require("../../../services");
|
|
7
7
|
const DeviceCapability_1 = require("../../DeviceCapability");
|
|
8
|
+
const sharedFunctions_1 = require("../../sharedFunctions");
|
|
8
9
|
class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
9
10
|
constructor(pInfo, type) {
|
|
10
11
|
var _a;
|
|
11
12
|
super(pInfo, type);
|
|
12
13
|
/** @inheritDoc */
|
|
14
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
15
|
+
/** @inheritDoc */
|
|
13
16
|
this.settings = new models_1.MotionSensorSettings();
|
|
14
17
|
/** @inheritDoc */
|
|
15
18
|
this.detectionsToday = 0;
|
|
@@ -18,10 +21,6 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
18
21
|
this._needsMovementResetFallback = true;
|
|
19
22
|
this._timeSinceLastMotion = 0;
|
|
20
23
|
this._movementDetected = false;
|
|
21
|
-
this._battery = -99;
|
|
22
|
-
this._lastBatteryPersist = 0;
|
|
23
|
-
this._lastBatteryLevel = -1;
|
|
24
|
-
this._batteryLevelCallbacks = [];
|
|
25
24
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.motionSensor);
|
|
26
25
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
27
26
|
if (!services_1.Utils.anyDboActive) {
|
|
@@ -40,10 +39,6 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
/** @inheritDoc */
|
|
43
|
-
get lastBatteryPersist() {
|
|
44
|
-
return this._lastBatteryPersist;
|
|
45
|
-
}
|
|
46
|
-
/** @inheritDoc */
|
|
47
42
|
get movementDetected() {
|
|
48
43
|
if (!this.available) {
|
|
49
44
|
// If the device is not available, there is no active movement
|
|
@@ -56,18 +51,14 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
56
51
|
return this._movementDetected;
|
|
57
52
|
}
|
|
58
53
|
/** @inheritDoc */
|
|
59
|
-
get
|
|
60
|
-
return this.
|
|
54
|
+
get batteryLevel() {
|
|
55
|
+
return this.battery.level;
|
|
61
56
|
}
|
|
62
57
|
// Time since last motion in seconds
|
|
63
58
|
/** @inheritDoc */
|
|
64
59
|
get timeSinceLastMotion() {
|
|
65
60
|
return this._timeSinceLastMotion;
|
|
66
61
|
}
|
|
67
|
-
/** @inheritDoc */
|
|
68
|
-
addBatteryLevelCallback(pCallback) {
|
|
69
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
70
|
-
}
|
|
71
62
|
/**
|
|
72
63
|
* Adds a callback for when a motion state has changed.
|
|
73
64
|
* @param pCallback - Function that accepts the new state as parameter
|
|
@@ -117,10 +108,8 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
117
108
|
super.update(idSplit, state, initial, pOverride);
|
|
118
109
|
switch (idSplit[3]) {
|
|
119
110
|
case 'battery':
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
122
|
-
this.persistBatteryDevice();
|
|
123
|
-
if (this._battery < 20) {
|
|
111
|
+
this.battery.level = state.val;
|
|
112
|
+
if (this.batteryLevel < 20) {
|
|
124
113
|
this.log(models_1.LogLevel.Warn, 'Das Zigbee Gerät hat unter 20% Batterie.');
|
|
125
114
|
}
|
|
126
115
|
break;
|
|
@@ -134,16 +123,6 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
134
123
|
break;
|
|
135
124
|
}
|
|
136
125
|
}
|
|
137
|
-
/** @inheritDoc */
|
|
138
|
-
persistBatteryDevice() {
|
|
139
|
-
var _a;
|
|
140
|
-
const now = services_1.Utils.nowMS();
|
|
141
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
145
|
-
this._lastBatteryPersist = now;
|
|
146
|
-
}
|
|
147
126
|
resetFallbackTimeout() {
|
|
148
127
|
if (this._fallBackTimeout) {
|
|
149
128
|
this.log(models_1.LogLevel.Trace, 'Fallback Timeout zurücksetzen');
|
|
@@ -160,18 +139,5 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
160
139
|
this.updateMovement(false);
|
|
161
140
|
}, 270000, this);
|
|
162
141
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
165
|
-
*/
|
|
166
|
-
checkForBatteryChange() {
|
|
167
|
-
const newLevel = this.battery;
|
|
168
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
172
|
-
cb(new models_1.BatteryLevelChangeAction(this));
|
|
173
|
-
}
|
|
174
|
-
this._lastBatteryLevel = newLevel;
|
|
175
|
-
}
|
|
176
142
|
}
|
|
177
143
|
exports.ZigbeeMotionSensor = ZigbeeMotionSensor;
|
|
@@ -84,13 +84,13 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
84
84
|
}
|
|
85
85
|
this.log(models_1.LogLevel.Debug, c.logMessage);
|
|
86
86
|
if (this._window !== undefined) {
|
|
87
|
-
if (this._window.griffeInPosition(models_2.WindowPosition.
|
|
87
|
+
if (this._window.griffeInPosition(models_2.WindowPosition.open) > 0 && pPosition < 100) {
|
|
88
88
|
if (!c.skipOpenWarning) {
|
|
89
89
|
this.log(models_1.LogLevel.Alert, 'Not closing the shutter, as the window is open!');
|
|
90
90
|
}
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
if (this._window.griffeInPosition(models_2.WindowPosition.
|
|
93
|
+
if (this._window.griffeInPosition(models_2.WindowPosition.tilted) > 0 && pPosition < 50) {
|
|
94
94
|
pPosition = 50;
|
|
95
95
|
if (!c.skipOpenWarning) {
|
|
96
96
|
this.log(models_1.LogLevel.Alert, 'Not closing the shutter, as the window is half open!');
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ZigbeeDevice } from './index';
|
|
2
|
+
import { Battery, HandleSensor } from '../../sharedFunctions';
|
|
3
|
+
import { iBatteryDevice, iHandleSensor } from '../../baseDeviceInterfaces';
|
|
4
|
+
import { DeviceType } from '../../deviceType';
|
|
5
|
+
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
6
|
+
import { WindowPosition } from '../../models';
|
|
7
|
+
import { Window } from '../../groups';
|
|
8
|
+
import { HandleSettings } from '../../../../models/deviceSettings/handleSettings';
|
|
9
|
+
export declare class ZigbeeWindowHandle extends ZigbeeDevice implements iHandleSensor, iBatteryDevice {
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
readonly battery: Battery;
|
|
12
|
+
/** @inheritDoc */
|
|
13
|
+
readonly handleSensor: HandleSensor;
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
settings: HandleSettings;
|
|
16
|
+
constructor(pInfo: IoBrokerDeviceInfo, deviceType: DeviceType);
|
|
17
|
+
/** @inheritDoc */
|
|
18
|
+
get position(): WindowPosition;
|
|
19
|
+
/** @inheritDoc */
|
|
20
|
+
get minutesOpen(): number;
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
get batteryLevel(): number;
|
|
23
|
+
/** @inheritDoc */
|
|
24
|
+
get window(): Window | undefined;
|
|
25
|
+
/** @inheritDoc */
|
|
26
|
+
set window(value: Window);
|
|
27
|
+
/** @inheritDoc */
|
|
28
|
+
addOffenCallback(pCallback: (pValue: boolean) => void): void;
|
|
29
|
+
/** @inheritDoc */
|
|
30
|
+
addKippCallback(pCallback: (pValue: boolean) => void): void;
|
|
31
|
+
/** @inheritDoc */
|
|
32
|
+
addClosedCallback(pCallback: (pValue: boolean) => void): void;
|
|
33
|
+
/** @inheritDoc */
|
|
34
|
+
update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
|
|
35
|
+
private toWindowPosition;
|
|
36
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZigbeeWindowHandle = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const sharedFunctions_1 = require("../../sharedFunctions");
|
|
6
|
+
const DeviceCapability_1 = require("../../DeviceCapability");
|
|
7
|
+
const models_1 = require("../../models");
|
|
8
|
+
const models_2 = require("../../../../models");
|
|
9
|
+
const handleSettings_1 = require("../../../../models/deviceSettings/handleSettings");
|
|
10
|
+
class ZigbeeWindowHandle extends index_1.ZigbeeDevice {
|
|
11
|
+
constructor(pInfo, deviceType) {
|
|
12
|
+
super(pInfo, deviceType);
|
|
13
|
+
/** @inheritDoc */
|
|
14
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
15
|
+
/** @inheritDoc */
|
|
16
|
+
this.handleSensor = new sharedFunctions_1.HandleSensor(this);
|
|
17
|
+
/** @inheritDoc */
|
|
18
|
+
this.settings = new handleSettings_1.HandleSettings();
|
|
19
|
+
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.handleSensor);
|
|
20
|
+
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
21
|
+
}
|
|
22
|
+
/** @inheritDoc */
|
|
23
|
+
get position() {
|
|
24
|
+
return this.handleSensor.position;
|
|
25
|
+
}
|
|
26
|
+
/** @inheritDoc */
|
|
27
|
+
get minutesOpen() {
|
|
28
|
+
return this.handleSensor.minutesOpen;
|
|
29
|
+
}
|
|
30
|
+
/** @inheritDoc */
|
|
31
|
+
get batteryLevel() {
|
|
32
|
+
return this.battery.level;
|
|
33
|
+
}
|
|
34
|
+
/** @inheritDoc */
|
|
35
|
+
get window() {
|
|
36
|
+
return this.handleSensor.window;
|
|
37
|
+
}
|
|
38
|
+
/** @inheritDoc */
|
|
39
|
+
set window(value) {
|
|
40
|
+
this.handleSensor.window = value;
|
|
41
|
+
}
|
|
42
|
+
/** @inheritDoc */
|
|
43
|
+
addOffenCallback(pCallback) {
|
|
44
|
+
this.handleSensor.addOffenCallback(pCallback);
|
|
45
|
+
}
|
|
46
|
+
/** @inheritDoc */
|
|
47
|
+
addKippCallback(pCallback) {
|
|
48
|
+
this.handleSensor.addKippCallback(pCallback);
|
|
49
|
+
}
|
|
50
|
+
/** @inheritDoc */
|
|
51
|
+
addClosedCallback(pCallback) {
|
|
52
|
+
this.handleSensor.addClosedCallback(pCallback);
|
|
53
|
+
}
|
|
54
|
+
/** @inheritDoc */
|
|
55
|
+
update(idSplit, state, initial = false, pOverride = false) {
|
|
56
|
+
super.update(idSplit, state, initial, pOverride);
|
|
57
|
+
switch (idSplit[3]) {
|
|
58
|
+
case 'position':
|
|
59
|
+
this.handleSensor.position = this.toWindowPosition(state.val);
|
|
60
|
+
break;
|
|
61
|
+
case 'battery':
|
|
62
|
+
this.battery.level = state.val;
|
|
63
|
+
if (this.batteryLevel < 20) {
|
|
64
|
+
this.log(models_2.LogLevel.Warn, 'Das Zigbee Gerät hat unter 20% Batterie.');
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
toWindowPosition(val) {
|
|
70
|
+
switch (val) {
|
|
71
|
+
case 'up':
|
|
72
|
+
return models_1.WindowPosition.tilted;
|
|
73
|
+
case 'right':
|
|
74
|
+
case 'left':
|
|
75
|
+
return models_1.WindowPosition.open;
|
|
76
|
+
case 'down':
|
|
77
|
+
return models_1.WindowPosition.closed;
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`Unknown window position ${val}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.ZigbeeWindowHandle = ZigbeeWindowHandle;
|
|
@@ -18,6 +18,7 @@ export * from './zigbeeInnr142C';
|
|
|
18
18
|
export * from './zigbeeLinkindLedRgbCct';
|
|
19
19
|
export * from './zigbeeOsramDimmer';
|
|
20
20
|
export * from './zigbeeSMaBiTMagnetContact';
|
|
21
|
+
export * from './zigbeeSodaHandle';
|
|
21
22
|
export * from './zigbeeSonoffMotion';
|
|
22
23
|
export * from './zigbeeSonoffTemp';
|
|
23
24
|
export * from './zigbeeTuyaValve';
|
|
@@ -34,6 +34,7 @@ __exportStar(require("./zigbeeInnr142C"), exports);
|
|
|
34
34
|
__exportStar(require("./zigbeeLinkindLedRgbCct"), exports);
|
|
35
35
|
__exportStar(require("./zigbeeOsramDimmer"), exports);
|
|
36
36
|
__exportStar(require("./zigbeeSMaBiTMagnetContact"), exports);
|
|
37
|
+
__exportStar(require("./zigbeeSodaHandle"), exports);
|
|
37
38
|
__exportStar(require("./zigbeeSonoffMotion"), exports);
|
|
38
39
|
__exportStar(require("./zigbeeSonoffTemp"), exports);
|
|
39
40
|
__exportStar(require("./zigbeeTuyaValve"), exports);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { BatteryLevelChangeAction } from '../../../models';
|
|
2
1
|
import { iBatteryDevice, iVibrationSensor } from '../baseDeviceInterfaces';
|
|
3
2
|
import { ZigbeeDevice } from './BaseDevices';
|
|
4
3
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
4
|
+
import { Battery } from '../sharedFunctions';
|
|
5
5
|
export declare class ZigbeeAquaraVibra extends ZigbeeDevice implements iVibrationSensor, iBatteryDevice {
|
|
6
|
+
/** @inheritDoc */
|
|
7
|
+
readonly battery: Battery;
|
|
6
8
|
/**
|
|
7
9
|
* The sensitivity of the vibration sensor
|
|
8
10
|
*/
|
|
@@ -35,8 +37,6 @@ export declare class ZigbeeAquaraVibra extends ZigbeeDevice implements iVibratio
|
|
|
35
37
|
* Whether the vibration sensor is tilted
|
|
36
38
|
*/
|
|
37
39
|
tilt: boolean;
|
|
38
|
-
private _battery;
|
|
39
|
-
private _lastBatteryPersist;
|
|
40
40
|
private _vibration;
|
|
41
41
|
private _vibrationBlockedByHandleTimeStamp;
|
|
42
42
|
private _vibrationBlockedByMotionTimeStamp;
|
|
@@ -44,8 +44,6 @@ export declare class ZigbeeAquaraVibra extends ZigbeeDevice implements iVibratio
|
|
|
44
44
|
private _alarmMessage;
|
|
45
45
|
private _vibrationBlockedByGriff;
|
|
46
46
|
private _vibrationBlockedByMotion;
|
|
47
|
-
private _lastBatteryLevel;
|
|
48
|
-
private _batteryLevelCallbacks;
|
|
49
47
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
50
48
|
/** @inheritDoc */
|
|
51
49
|
get vibration(): boolean;
|
|
@@ -54,9 +52,7 @@ export declare class ZigbeeAquaraVibra extends ZigbeeDevice implements iVibratio
|
|
|
54
52
|
/** @inheritDoc */
|
|
55
53
|
get vibrationBlockedByHandleTimeStamp(): number;
|
|
56
54
|
/** @inheritDoc */
|
|
57
|
-
get
|
|
58
|
-
/** @inheritDoc */
|
|
59
|
-
get battery(): number;
|
|
55
|
+
get batteryLevel(): number;
|
|
60
56
|
/** @inheritDoc */
|
|
61
57
|
get vibrationBlockedByHandle(): boolean;
|
|
62
58
|
/** @inheritDoc */
|
|
@@ -66,15 +62,7 @@ export declare class ZigbeeAquaraVibra extends ZigbeeDevice implements iVibratio
|
|
|
66
62
|
/** @inheritDoc */
|
|
67
63
|
set vibrationBlockedByMotion(pVal: boolean);
|
|
68
64
|
/** @inheritDoc */
|
|
69
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
70
|
-
/** @inheritDoc */
|
|
71
65
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
72
66
|
setSensitivity(pVal: number): void;
|
|
73
|
-
/** @inheritDoc */
|
|
74
|
-
persistBatteryDevice(): void;
|
|
75
67
|
private alarmCheck;
|
|
76
|
-
/**
|
|
77
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
78
|
-
*/
|
|
79
|
-
private checkForBatteryChange;
|
|
80
68
|
}
|