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
|
@@ -6,24 +6,23 @@ const deviceType_1 = require("../deviceType");
|
|
|
6
6
|
const models_1 = require("../../../models");
|
|
7
7
|
const services_1 = require("../../services");
|
|
8
8
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
9
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
9
10
|
class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
10
11
|
constructor(pInfo) {
|
|
11
12
|
var _a;
|
|
12
13
|
super(pInfo, deviceType_1.DeviceType.HmIpPraezenz);
|
|
13
14
|
/** @inheritDoc */
|
|
15
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
16
|
+
/** @inheritDoc */
|
|
14
17
|
this.movementDetected = false;
|
|
15
18
|
/** @inheritDoc */
|
|
16
19
|
this.settings = new models_1.MotionSensorSettings();
|
|
17
|
-
this._battery = -99;
|
|
18
|
-
this._lastBatteryPersist = 0;
|
|
19
20
|
this._movementDetectedCallback = [];
|
|
20
21
|
// private presenceStateID: string;
|
|
21
22
|
this.initialized = false;
|
|
22
23
|
this._lastMotionTime = 0;
|
|
23
24
|
this._detectionsToday = 0;
|
|
24
25
|
this._currentIllumination = -1;
|
|
25
|
-
this._lastBatteryLevel = -1;
|
|
26
|
-
this._batteryLevelCallbacks = [];
|
|
27
26
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.illuminationSensor);
|
|
28
27
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
29
28
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.motionSensor);
|
|
@@ -42,11 +41,8 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
|
-
get
|
|
46
|
-
return this.
|
|
47
|
-
}
|
|
48
|
-
get battery() {
|
|
49
|
-
return this._battery;
|
|
44
|
+
get batteryLevel() {
|
|
45
|
+
return this.battery.level;
|
|
50
46
|
}
|
|
51
47
|
get timeSinceLastMotion() {
|
|
52
48
|
return Math.floor((services_1.Utils.nowMS() - this._lastMotionTime) / 1000);
|
|
@@ -65,10 +61,6 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
|
65
61
|
this._currentIllumination = value;
|
|
66
62
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistIlluminationSensor(this);
|
|
67
63
|
}
|
|
68
|
-
/** @inheritDoc */
|
|
69
|
-
addBatteryLevelCallback(pCallback) {
|
|
70
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
71
|
-
}
|
|
72
64
|
addMovementCallback(pCallback) {
|
|
73
65
|
this._movementDetectedCallback.push(pCallback);
|
|
74
66
|
}
|
|
@@ -80,9 +72,7 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
|
80
72
|
case '0':
|
|
81
73
|
switch (idSplit[4]) {
|
|
82
74
|
case 'OPERATING_VOLTAGE':
|
|
83
|
-
this.
|
|
84
|
-
this.checkForBatteryChange();
|
|
85
|
-
this.persistBatteryDevice();
|
|
75
|
+
this.battery.level = 100 * ((state.val - 1.8) / 1.2);
|
|
86
76
|
break;
|
|
87
77
|
}
|
|
88
78
|
break;
|
|
@@ -126,28 +116,6 @@ class HmIpPraezenz extends hmIpDevice_1.HmIPDevice {
|
|
|
126
116
|
var _a;
|
|
127
117
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistMotionSensor(this);
|
|
128
118
|
}
|
|
129
|
-
persistBatteryDevice() {
|
|
130
|
-
var _a;
|
|
131
|
-
const now = services_1.Utils.nowMS();
|
|
132
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
136
|
-
this._lastBatteryPersist = now;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
140
|
-
*/
|
|
141
|
-
checkForBatteryChange() {
|
|
142
|
-
const newLevel = this.battery;
|
|
143
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
147
|
-
cb(new models_1.BatteryLevelChangeAction(this));
|
|
148
|
-
}
|
|
149
|
-
this._lastBatteryLevel = newLevel;
|
|
150
|
-
}
|
|
151
119
|
}
|
|
152
120
|
exports.HmIpPraezenz = HmIpPraezenz;
|
|
153
121
|
// TODO: Add iPresenceSensor
|
|
@@ -100,13 +100,13 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
|
|
|
100
100
|
}
|
|
101
101
|
this.log(models_2.LogLevel.Debug, command.logMessage);
|
|
102
102
|
if (this._window !== undefined) {
|
|
103
|
-
if (this._window.griffeInPosition(models_1.WindowPosition.
|
|
103
|
+
if (this._window.griffeInPosition(models_1.WindowPosition.open) > 0 && command.level < 100) {
|
|
104
104
|
if (!command.skipOpenWarning) {
|
|
105
105
|
this.log(models_2.LogLevel.Alert, 'Not closing the shutter, as the window is open!');
|
|
106
106
|
}
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
if (this._window.griffeInPosition(models_1.WindowPosition.
|
|
109
|
+
if (this._window.griffeInPosition(models_1.WindowPosition.tilted) > 0 && targetLevel < 50) {
|
|
110
110
|
targetLevel = 50;
|
|
111
111
|
if (!command.skipOpenWarning) {
|
|
112
112
|
this.log(models_2.LogLevel.Alert, 'Not closing the shutter, as the window is half open!');
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { HmIPDevice } from './hmIpDevice';
|
|
2
2
|
import { iBatteryDevice, iButtonSwitch } from '../baseDeviceInterfaces';
|
|
3
3
|
import { Button, ButtonPosition, ButtonPressType } from '../button';
|
|
4
|
-
import { BatteryLevelChangeAction } from '../../../models';
|
|
5
4
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
5
|
+
import { Battery } from '../sharedFunctions';
|
|
6
6
|
export declare class HmIpTaster extends HmIPDevice implements iButtonSwitch, iBatteryDevice {
|
|
7
|
+
/** @inheritDoc */
|
|
8
|
+
readonly battery: Battery;
|
|
7
9
|
private static readonly BUTTON_CAPABILLITIES;
|
|
8
10
|
/** @inheritDoc */
|
|
9
11
|
buttonTopLeft: Button;
|
|
@@ -27,23 +29,11 @@ export declare class HmIpTaster extends HmIPDevice implements iButtonSwitch, iBa
|
|
|
27
29
|
* @inheritDoc
|
|
28
30
|
*/
|
|
29
31
|
buttonTop: undefined;
|
|
30
|
-
private _battery;
|
|
31
|
-
private _lastBatteryPersist;
|
|
32
|
-
private _lastBatteryLevel;
|
|
33
|
-
private _batteryLevelCallbacks;
|
|
34
32
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
35
|
-
get
|
|
36
|
-
get battery(): number;
|
|
37
|
-
/** @inheritDoc */
|
|
38
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
33
|
+
get batteryLevel(): number;
|
|
39
34
|
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
40
35
|
/** @inheritDoc */
|
|
41
36
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
42
37
|
getButtonAssignment(): string;
|
|
43
|
-
persistBatteryDevice(): void;
|
|
44
38
|
pressButton(position: ButtonPosition, pressType: ButtonPressType): Error | null;
|
|
45
|
-
/**
|
|
46
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
47
|
-
*/
|
|
48
|
-
private checkForBatteryChange;
|
|
49
39
|
}
|
|
@@ -7,9 +7,12 @@ const button_1 = require("../button");
|
|
|
7
7
|
const models_1 = require("../../../models");
|
|
8
8
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
9
9
|
const services_1 = require("../../services");
|
|
10
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
10
11
|
class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
11
12
|
constructor(pInfo) {
|
|
12
13
|
super(pInfo, deviceType_1.DeviceType.HmIpTaster);
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
13
16
|
/**
|
|
14
17
|
* Not present for HM-IP-Taster
|
|
15
18
|
* @inheritDoc
|
|
@@ -20,10 +23,6 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
20
23
|
* @inheritDoc
|
|
21
24
|
*/
|
|
22
25
|
this.buttonTop = undefined;
|
|
23
|
-
this._battery = -99;
|
|
24
|
-
this._lastBatteryPersist = 0;
|
|
25
|
-
this._lastBatteryLevel = -1;
|
|
26
|
-
this._batteryLevelCallbacks = [];
|
|
27
26
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.buttonSwitch);
|
|
28
27
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
29
28
|
this.buttonTopLeft = new button_1.Button('TopLeft', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
@@ -33,15 +32,8 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
33
32
|
this.buttonMidRight = new button_1.Button('MidRight', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
34
33
|
this.buttonBotRight = new button_1.Button('BotRight', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
35
34
|
}
|
|
36
|
-
get
|
|
37
|
-
return this.
|
|
38
|
-
}
|
|
39
|
-
get battery() {
|
|
40
|
-
return this._battery;
|
|
41
|
-
}
|
|
42
|
-
/** @inheritDoc */
|
|
43
|
-
addBatteryLevelCallback(pCallback) {
|
|
44
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
35
|
+
get batteryLevel() {
|
|
36
|
+
return this.battery.level;
|
|
45
37
|
}
|
|
46
38
|
persist(buttonName, pressType) {
|
|
47
39
|
var _a;
|
|
@@ -56,9 +48,7 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
56
48
|
case '0':
|
|
57
49
|
switch (idSplit[4]) {
|
|
58
50
|
case 'OPERATING_VOLTAGE':
|
|
59
|
-
this.
|
|
60
|
-
this.checkForBatteryChange();
|
|
61
|
-
this.persistBatteryDevice();
|
|
51
|
+
this.battery.level = 100 * ((state.val - 1.8) / 1.2);
|
|
62
52
|
break;
|
|
63
53
|
}
|
|
64
54
|
break;
|
|
@@ -129,15 +119,6 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
129
119
|
result.push('____________');
|
|
130
120
|
return result.join('\n');
|
|
131
121
|
}
|
|
132
|
-
persistBatteryDevice() {
|
|
133
|
-
var _a;
|
|
134
|
-
const now = services_1.Utils.nowMS();
|
|
135
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
139
|
-
this._lastBatteryPersist = now;
|
|
140
|
-
}
|
|
141
122
|
pressButton(position, pressType) {
|
|
142
123
|
let taste;
|
|
143
124
|
switch (position) {
|
|
@@ -177,19 +158,6 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
177
158
|
}
|
|
178
159
|
return result;
|
|
179
160
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
182
|
-
*/
|
|
183
|
-
checkForBatteryChange() {
|
|
184
|
-
const newLevel = this.battery;
|
|
185
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
189
|
-
cb(new models_1.BatteryLevelChangeAction(this));
|
|
190
|
-
}
|
|
191
|
-
this._lastBatteryLevel = newLevel;
|
|
192
|
-
}
|
|
193
161
|
}
|
|
194
162
|
exports.HmIpTaster = HmIpTaster;
|
|
195
163
|
HmIpTaster.BUTTON_CAPABILLITIES = {
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
-
import { BatteryLevelChangeAction } from '../../../models';
|
|
3
2
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
4
3
|
import { iBatteryDevice } from '../baseDeviceInterfaces';
|
|
4
|
+
import { Battery } from '../sharedFunctions';
|
|
5
5
|
export declare class HmIpTherm extends HmIPDevice implements iBatteryDevice {
|
|
6
|
-
private _battery;
|
|
7
|
-
private _lastBatteryPersist;
|
|
8
|
-
private _lastBatteryLevel;
|
|
9
|
-
private _batteryLevelCallbacks;
|
|
10
|
-
constructor(pInfo: IoBrokerDeviceInfo);
|
|
11
|
-
get lastBatteryPersist(): number;
|
|
12
|
-
get battery(): number;
|
|
13
6
|
/** @inheritDoc */
|
|
14
|
-
|
|
7
|
+
readonly battery: Battery;
|
|
8
|
+
constructor(pInfo: IoBrokerDeviceInfo);
|
|
9
|
+
get batteryLevel(): number;
|
|
15
10
|
/** @inheritDoc */
|
|
16
11
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
17
|
-
persistBatteryDevice(): void;
|
|
18
|
-
/**
|
|
19
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
20
|
-
*/
|
|
21
|
-
private checkForBatteryChange;
|
|
22
12
|
}
|
|
@@ -5,25 +5,16 @@ const hmIpDevice_1 = require("./hmIpDevice");
|
|
|
5
5
|
const deviceType_1 = require("../deviceType");
|
|
6
6
|
const models_1 = require("../../../models");
|
|
7
7
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
8
|
-
const
|
|
8
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
9
9
|
class HmIpTherm extends hmIpDevice_1.HmIPDevice {
|
|
10
10
|
constructor(pInfo) {
|
|
11
11
|
super(pInfo, deviceType_1.DeviceType.HmIpTherm);
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
this._lastBatteryLevel = -1;
|
|
15
|
-
this._batteryLevelCallbacks = [];
|
|
12
|
+
/** @inheritDoc */
|
|
13
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
16
14
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
17
15
|
}
|
|
18
|
-
get
|
|
19
|
-
return this.
|
|
20
|
-
}
|
|
21
|
-
get battery() {
|
|
22
|
-
return this._battery;
|
|
23
|
-
}
|
|
24
|
-
/** @inheritDoc */
|
|
25
|
-
addBatteryLevelCallback(pCallback) {
|
|
26
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
16
|
+
get batteryLevel() {
|
|
17
|
+
return this.battery.level;
|
|
27
18
|
}
|
|
28
19
|
/** @inheritDoc */
|
|
29
20
|
update(idSplit, state, initial = false) {
|
|
@@ -33,35 +24,11 @@ class HmIpTherm extends hmIpDevice_1.HmIPDevice {
|
|
|
33
24
|
case '0':
|
|
34
25
|
switch (idSplit[4]) {
|
|
35
26
|
case 'OPERATING_VOLTAGE':
|
|
36
|
-
this.
|
|
37
|
-
this.checkForBatteryChange();
|
|
38
|
-
this.persistBatteryDevice();
|
|
27
|
+
this.battery.level = 100 * ((state.val - 1.8) / 1.2);
|
|
39
28
|
break;
|
|
40
29
|
}
|
|
41
30
|
break;
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
|
-
persistBatteryDevice() {
|
|
45
|
-
var _a;
|
|
46
|
-
const now = services_1.Utils.nowMS();
|
|
47
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
51
|
-
this._lastBatteryPersist = now;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
55
|
-
*/
|
|
56
|
-
checkForBatteryChange() {
|
|
57
|
-
const newLevel = this.battery;
|
|
58
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
62
|
-
cb(new models_1.BatteryLevelChangeAction(this));
|
|
63
|
-
}
|
|
64
|
-
this._lastBatteryLevel = newLevel;
|
|
65
|
-
}
|
|
66
33
|
}
|
|
67
34
|
exports.HmIpTherm = HmIpTherm;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WindowPosition = void 0;
|
|
4
4
|
var WindowPosition;
|
|
5
5
|
(function (WindowPosition) {
|
|
6
|
-
WindowPosition[WindowPosition["
|
|
7
|
-
WindowPosition[WindowPosition["
|
|
8
|
-
WindowPosition[WindowPosition["
|
|
6
|
+
WindowPosition[WindowPosition["closed"] = 0] = "closed";
|
|
7
|
+
WindowPosition[WindowPosition["tilted"] = 1] = "tilted";
|
|
8
|
+
WindowPosition[WindowPosition["open"] = 2] = "open";
|
|
9
9
|
})(WindowPosition || (exports.WindowPosition = WindowPosition = {}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { iBatteryDevice } from '../baseDeviceInterfaces';
|
|
2
|
+
import { BatteryLevelChangeAction } from '../../../models';
|
|
3
|
+
import { iJsonOmitKeys } from '../../../models/iJsonOmitKeys';
|
|
4
|
+
export declare class Battery implements iJsonOmitKeys {
|
|
5
|
+
private readonly _device;
|
|
6
|
+
/**
|
|
7
|
+
* The last time the battery was persisted (in milliseconds since 1970)
|
|
8
|
+
*/
|
|
9
|
+
private _level;
|
|
10
|
+
private _lastPersist;
|
|
11
|
+
private _lastLevel;
|
|
12
|
+
private _levelCallbacks;
|
|
13
|
+
private _lastChangeReportMs;
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
readonly jsonOmitKeys: string[];
|
|
16
|
+
constructor(_device: iBatteryDevice);
|
|
17
|
+
get level(): number;
|
|
18
|
+
set level(val: number);
|
|
19
|
+
/** @inheritDoc */
|
|
20
|
+
persist(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Checks whether the battery level did change and if so fires the callbacks
|
|
23
|
+
*/
|
|
24
|
+
checkForChange(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Adds a callback for when the battery-level has Changed.
|
|
27
|
+
* @param pCallback - Function that accepts the new state as parameter
|
|
28
|
+
*/
|
|
29
|
+
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
30
|
+
toJSON(): Partial<iBatteryDevice>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Battery = void 0;
|
|
4
|
+
const services_1 = require("../../services");
|
|
5
|
+
const models_1 = require("../../../models");
|
|
6
|
+
class Battery {
|
|
7
|
+
constructor(_device) {
|
|
8
|
+
this._device = _device;
|
|
9
|
+
/**
|
|
10
|
+
* The last time the battery was persisted (in milliseconds since 1970)
|
|
11
|
+
*/
|
|
12
|
+
this._level = -99;
|
|
13
|
+
this._lastPersist = 0;
|
|
14
|
+
this._lastLevel = -1;
|
|
15
|
+
this._levelCallbacks = [];
|
|
16
|
+
this._lastChangeReportMs = 0;
|
|
17
|
+
/** @inheritDoc */
|
|
18
|
+
this.jsonOmitKeys = ['_device'];
|
|
19
|
+
}
|
|
20
|
+
get level() {
|
|
21
|
+
return this._level;
|
|
22
|
+
}
|
|
23
|
+
set level(val) {
|
|
24
|
+
this._level = val;
|
|
25
|
+
this.checkForChange();
|
|
26
|
+
this.persist();
|
|
27
|
+
}
|
|
28
|
+
/** @inheritDoc */
|
|
29
|
+
persist() {
|
|
30
|
+
var _a;
|
|
31
|
+
const now = services_1.Utils.nowMS();
|
|
32
|
+
if (this._lastPersist + 60000 > now) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this._device);
|
|
36
|
+
this._lastPersist = now;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Checks whether the battery level did change and if so fires the callbacks
|
|
40
|
+
*/
|
|
41
|
+
checkForChange() {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const batteryReportingInterval = (_b = (_a = this._device.settings) === null || _a === void 0 ? void 0 : _a.batteryReportingInterval) !== null && _b !== void 0 ? _b : -1;
|
|
44
|
+
if (this._level == this._lastLevel &&
|
|
45
|
+
(batteryReportingInterval < 0 || services_1.Utils.nowMS() - this._lastChangeReportMs < batteryReportingInterval * 60 * 1000)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this._lastChangeReportMs = services_1.Utils.nowMS();
|
|
49
|
+
for (const cb of this._levelCallbacks) {
|
|
50
|
+
cb(new models_1.BatteryLevelChangeAction(this._device));
|
|
51
|
+
}
|
|
52
|
+
this._lastLevel = this._level;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Adds a callback for when the battery-level has Changed.
|
|
56
|
+
* @param pCallback - Function that accepts the new state as parameter
|
|
57
|
+
*/
|
|
58
|
+
addBatteryLevelCallback(pCallback) {
|
|
59
|
+
this._levelCallbacks.push(pCallback);
|
|
60
|
+
}
|
|
61
|
+
toJSON() {
|
|
62
|
+
return services_1.Utils.jsonFilter(this, this.jsonOmitKeys);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.Battery = Battery;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { WindowPosition } from '../models';
|
|
2
|
+
import { LogLevel } from '../../../models';
|
|
3
|
+
import { iDisposable, LogDebugType } from '../../services';
|
|
4
|
+
import { Window } from '../groups';
|
|
5
|
+
import { iHandleSensor } from '../baseDeviceInterfaces';
|
|
6
|
+
import { iJsonOmitKeys } from '../../../models/iJsonOmitKeys';
|
|
7
|
+
export declare class HandleSensor implements iDisposable, iJsonOmitKeys {
|
|
8
|
+
private readonly _device;
|
|
9
|
+
/** @inheritDoc */
|
|
10
|
+
readonly jsonOmitKeys: string[];
|
|
11
|
+
/**
|
|
12
|
+
* The current position of the handle
|
|
13
|
+
*/
|
|
14
|
+
position: WindowPosition;
|
|
15
|
+
/**
|
|
16
|
+
* The time the handle was open in minutes
|
|
17
|
+
*/
|
|
18
|
+
minutesOpen: number;
|
|
19
|
+
/**
|
|
20
|
+
* The window this handle is attached to
|
|
21
|
+
*/
|
|
22
|
+
window: Window | undefined;
|
|
23
|
+
private _lastPersist;
|
|
24
|
+
private _kippCallback;
|
|
25
|
+
private _closedCallback;
|
|
26
|
+
private _offenCallback;
|
|
27
|
+
private _iOpenTimeout;
|
|
28
|
+
private _helpingRoomTemp;
|
|
29
|
+
constructor(_device: iHandleSensor);
|
|
30
|
+
private get _settings();
|
|
31
|
+
updatePosition(pValue: WindowPosition): void;
|
|
32
|
+
/** @inheritDoc */
|
|
33
|
+
addOffenCallback(pCallback: (pValue: boolean) => void): void;
|
|
34
|
+
/** @inheritDoc */
|
|
35
|
+
addKippCallback(pCallback: (pValue: boolean) => void): void;
|
|
36
|
+
/** @inheritDoc */
|
|
37
|
+
addClosedCallback(pCallback: (pValue: boolean) => void): void;
|
|
38
|
+
dispose(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Persists the handle sensor state to the persistence layer
|
|
41
|
+
*/
|
|
42
|
+
persist(): void;
|
|
43
|
+
log(level: LogLevel, message: string, debugType?: LogDebugType): void;
|
|
44
|
+
toJSON(): Partial<HandleSensor>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandleSensor = void 0;
|
|
4
|
+
const models_1 = require("../models");
|
|
5
|
+
const models_2 = require("../../../models");
|
|
6
|
+
const services_1 = require("../../services");
|
|
7
|
+
class HandleSensor {
|
|
8
|
+
constructor(_device) {
|
|
9
|
+
this._device = _device;
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
this.jsonOmitKeys = ['_device', 'window'];
|
|
12
|
+
/**
|
|
13
|
+
* The current position of the handle
|
|
14
|
+
*/
|
|
15
|
+
this.position = models_1.WindowPosition.closed;
|
|
16
|
+
/**
|
|
17
|
+
* The time the handle was open in minutes
|
|
18
|
+
*/
|
|
19
|
+
this.minutesOpen = 0;
|
|
20
|
+
this._lastPersist = 0;
|
|
21
|
+
this._kippCallback = [];
|
|
22
|
+
this._closedCallback = [];
|
|
23
|
+
this._offenCallback = [];
|
|
24
|
+
this._helpingRoomTemp = false;
|
|
25
|
+
}
|
|
26
|
+
get _settings() {
|
|
27
|
+
return this._device.settings;
|
|
28
|
+
}
|
|
29
|
+
updatePosition(pValue) {
|
|
30
|
+
if (pValue === this.position) {
|
|
31
|
+
if (this._lastPersist == 0) {
|
|
32
|
+
this.persist();
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.log(models_2.LogLevel.Debug, `Update Windowhandle to position "${models_1.WindowPosition[pValue]}"`);
|
|
37
|
+
this.position = pValue;
|
|
38
|
+
for (const c1 of this._closedCallback) {
|
|
39
|
+
c1(pValue === 0);
|
|
40
|
+
}
|
|
41
|
+
for (const c2 of this._kippCallback) {
|
|
42
|
+
c2(pValue === 1);
|
|
43
|
+
}
|
|
44
|
+
for (const c3 of this._offenCallback) {
|
|
45
|
+
c3(pValue === 2);
|
|
46
|
+
}
|
|
47
|
+
this.persist();
|
|
48
|
+
if (pValue === models_1.WindowPosition.closed) {
|
|
49
|
+
if (this._iOpenTimeout !== undefined) {
|
|
50
|
+
clearInterval(this._iOpenTimeout);
|
|
51
|
+
this.log(models_2.LogLevel.Info, `Window closed after ${this.minutesOpen} minutes`);
|
|
52
|
+
this.minutesOpen = 0;
|
|
53
|
+
this._iOpenTimeout = undefined;
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (this._iOpenTimeout !== undefined) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this._iOpenTimeout = services_1.Utils.guardedInterval(() => {
|
|
61
|
+
var _a;
|
|
62
|
+
this.minutesOpen++;
|
|
63
|
+
const heatgroup = (_a = this.window) === null || _a === void 0 ? void 0 : _a.getRoom().HeatGroup;
|
|
64
|
+
if (heatgroup !== undefined) {
|
|
65
|
+
const desiredTemp = heatgroup.desiredTemp;
|
|
66
|
+
const currentTemp = heatgroup.temperature;
|
|
67
|
+
const outSideTemp = services_1.WeatherService.getCurrentTemp();
|
|
68
|
+
// Check if any of these values are unavailable
|
|
69
|
+
if (desiredTemp > -99 && currentTemp > -99 && outSideTemp > -99) {
|
|
70
|
+
const wouldHelp = (desiredTemp < currentTemp && outSideTemp < currentTemp) ||
|
|
71
|
+
(desiredTemp > currentTemp && outSideTemp > currentTemp);
|
|
72
|
+
if (!wouldHelp && this._helpingRoomTemp) {
|
|
73
|
+
const info = "Window should be closed, as it doesn't help reaching target temperature.";
|
|
74
|
+
this.log(models_2.LogLevel.Info, info);
|
|
75
|
+
if (this._settings.informNotHelping) {
|
|
76
|
+
services_1.TelegramService.inform(info);
|
|
77
|
+
}
|
|
78
|
+
this._helpingRoomTemp = false;
|
|
79
|
+
}
|
|
80
|
+
else if (wouldHelp && !this._helpingRoomTemp) {
|
|
81
|
+
this._helpingRoomTemp = true;
|
|
82
|
+
const info = `Das Fenster hilft der Innentemperatur ihr Ziel von ${desiredTemp} zu erreichen. Draußen sind es ${outSideTemp}. Du wirst informiert wenn es nicht mehr hilft.`;
|
|
83
|
+
this.log(models_2.LogLevel.Info, info);
|
|
84
|
+
if (this._settings.informIsHelping) {
|
|
85
|
+
services_1.TelegramService.inform(info);
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
else if (wouldHelp && this._helpingRoomTemp) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const message = `Window is in position ${models_1.WindowPosition[this.position]} since ${this.minutesOpen} minutes`;
|
|
95
|
+
switch (this.minutesOpen) {
|
|
96
|
+
case 15:
|
|
97
|
+
case 30:
|
|
98
|
+
case 60:
|
|
99
|
+
case 120:
|
|
100
|
+
case 240:
|
|
101
|
+
this.log(models_2.LogLevel.Info, message);
|
|
102
|
+
if (this._settings.informOnOpen) {
|
|
103
|
+
services_1.TelegramService.inform(`${this._device.info.room}: ${message}`);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
this.log(models_2.LogLevel.Trace, message);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}, 60000, this);
|
|
111
|
+
}
|
|
112
|
+
/** @inheritDoc */
|
|
113
|
+
addOffenCallback(pCallback) {
|
|
114
|
+
this._offenCallback.push(pCallback);
|
|
115
|
+
}
|
|
116
|
+
/** @inheritDoc */
|
|
117
|
+
addKippCallback(pCallback) {
|
|
118
|
+
this._kippCallback.push(pCallback);
|
|
119
|
+
}
|
|
120
|
+
/** @inheritDoc */
|
|
121
|
+
addClosedCallback(pCallback) {
|
|
122
|
+
this._closedCallback.push(pCallback);
|
|
123
|
+
}
|
|
124
|
+
dispose() {
|
|
125
|
+
if (this._iOpenTimeout) {
|
|
126
|
+
clearInterval(this._iOpenTimeout);
|
|
127
|
+
this._iOpenTimeout = undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Persists the handle sensor state to the persistence layer
|
|
132
|
+
*/
|
|
133
|
+
persist() {
|
|
134
|
+
var _a;
|
|
135
|
+
const now = services_1.Utils.nowMS();
|
|
136
|
+
if (this._lastPersist + 2000 > now) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.log(models_2.LogLevel.Debug, `Persist handle state: ${this.position}`);
|
|
140
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistHandleSensor(this._device);
|
|
141
|
+
this._lastPersist = now;
|
|
142
|
+
}
|
|
143
|
+
log(level, message, debugType = services_1.LogDebugType.None) {
|
|
144
|
+
this._device.log(level, message, debugType);
|
|
145
|
+
}
|
|
146
|
+
toJSON() {
|
|
147
|
+
return services_1.Utils.jsonFilter(this, this.jsonOmitKeys);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.HandleSensor = HandleSensor;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HumiditySensorChangeAction } from '../../../models';
|
|
2
|
+
import { iHumiditySensor } from '../baseDeviceInterfaces';
|
|
3
|
+
import { iJsonOmitKeys } from '../../../models/iJsonOmitKeys';
|
|
4
|
+
export declare class HumiditySensor implements iJsonOmitKeys {
|
|
5
|
+
private readonly _device;
|
|
6
|
+
/** @inheritDoc */
|
|
7
|
+
readonly jsonOmitKeys: string[];
|
|
8
|
+
private _humidityCallbacks;
|
|
9
|
+
private _humidity;
|
|
10
|
+
private readonly _persistHumiditySensorInterval;
|
|
11
|
+
constructor(_device: iHumiditySensor);
|
|
12
|
+
get humidity(): number;
|
|
13
|
+
set humidity(val: number);
|
|
14
|
+
dispose(): void;
|
|
15
|
+
persist(): void;
|
|
16
|
+
addHumidityCallback(pCallback: (action: HumiditySensorChangeAction) => void): void;
|
|
17
|
+
toJSON(): Partial<HumiditySensor>;
|
|
18
|
+
}
|