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,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.HmIpGriff = void 0;
|
|
7
4
|
const deviceType_1 = require("../deviceType");
|
|
8
|
-
const
|
|
9
|
-
const models_1 = require("../models");
|
|
10
|
-
const models_2 = require("../../../models");
|
|
11
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
5
|
+
const models_1 = require("../../../models");
|
|
12
6
|
const hmIpDevice_1 = require("./hmIpDevice");
|
|
13
7
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
14
8
|
const handleSettings_1 = require("../../../models/deviceSettings/handleSettings");
|
|
9
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
15
10
|
class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
11
|
+
/** @inheritDoc */
|
|
12
|
+
get position() {
|
|
13
|
+
return this.handleSensor.position;
|
|
14
|
+
}
|
|
15
|
+
/** @inheritDoc */
|
|
16
|
+
get minutesOpen() {
|
|
17
|
+
return this.handleSensor.minutesOpen;
|
|
18
|
+
}
|
|
16
19
|
/**
|
|
17
20
|
* Creates an instance of {@link DeviceType.HmIpGriff}.
|
|
18
21
|
* @param pInfo - Device creation information
|
|
@@ -20,211 +23,64 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
|
20
23
|
constructor(pInfo) {
|
|
21
24
|
super(pInfo, deviceType_1.DeviceType.HmIpGriff);
|
|
22
25
|
/** @inheritDoc */
|
|
23
|
-
this.
|
|
26
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
24
27
|
/** @inheritDoc */
|
|
25
|
-
this.
|
|
28
|
+
this.handleSensor = new sharedFunctions_1.HandleSensor(this);
|
|
26
29
|
/** @inheritDoc */
|
|
27
|
-
this.
|
|
28
|
-
this._battery = -99;
|
|
29
|
-
this._lastBatteryPersist = 0;
|
|
30
|
-
this._lastHandlePersist = 0;
|
|
31
|
-
this._kippCallback = [];
|
|
32
|
-
this._closedCallback = [];
|
|
33
|
-
this._offenCallback = [];
|
|
34
|
-
this._window = undefined;
|
|
35
|
-
this._helpingRoomTemp = false;
|
|
36
|
-
this._lastBatteryLevel = -1;
|
|
37
|
-
this._batteryLevelCallbacks = [];
|
|
30
|
+
this.settings = new handleSettings_1.HandleSettings();
|
|
38
31
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.handleSensor);
|
|
39
32
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
40
33
|
}
|
|
41
34
|
/** @inheritDoc */
|
|
42
|
-
get
|
|
43
|
-
return this.
|
|
44
|
-
}
|
|
45
|
-
/** @inheritDoc */
|
|
46
|
-
get battery() {
|
|
47
|
-
return this._battery;
|
|
35
|
+
get batteryLevel() {
|
|
36
|
+
return this.battery.level;
|
|
48
37
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
set window(value) {
|
|
53
|
-
this._window = value;
|
|
38
|
+
get window() {
|
|
39
|
+
return this.handleSensor.window;
|
|
54
40
|
}
|
|
55
41
|
/** @inheritDoc */
|
|
56
|
-
|
|
57
|
-
this.
|
|
42
|
+
set window(value) {
|
|
43
|
+
this.handleSensor.window = value;
|
|
58
44
|
}
|
|
59
45
|
/** @inheritDoc */
|
|
60
46
|
addOffenCallback(pCallback) {
|
|
61
|
-
this.
|
|
47
|
+
this.handleSensor.addOffenCallback(pCallback);
|
|
62
48
|
}
|
|
63
49
|
/** @inheritDoc */
|
|
64
50
|
addKippCallback(pCallback) {
|
|
65
|
-
this.
|
|
51
|
+
this.handleSensor.addKippCallback(pCallback);
|
|
66
52
|
}
|
|
67
53
|
/** @inheritDoc */
|
|
68
54
|
addClosedCallback(pCallback) {
|
|
69
|
-
this.
|
|
55
|
+
this.handleSensor.addClosedCallback(pCallback);
|
|
70
56
|
}
|
|
71
57
|
/** @inheritDoc */
|
|
72
58
|
update(idSplit, state, initial = false) {
|
|
73
|
-
this.log(
|
|
59
|
+
this.log(models_1.LogLevel.DeepTrace, `Griff Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
|
|
74
60
|
super.update(idSplit, state, initial, true);
|
|
75
61
|
switch (idSplit[3]) {
|
|
76
62
|
case '0':
|
|
77
63
|
switch (idSplit[4]) {
|
|
78
64
|
case 'OPERATING_VOLTAGE':
|
|
79
|
-
this.
|
|
80
|
-
this.checkForBatteryChange();
|
|
81
|
-
this.persistBatteryDevice();
|
|
65
|
+
this.battery.level = 100 * ((state.val - 0.9) / 0.6);
|
|
82
66
|
break;
|
|
83
67
|
}
|
|
84
68
|
break;
|
|
85
69
|
case '1':
|
|
86
70
|
switch (idSplit[4]) {
|
|
87
71
|
case 'STATE':
|
|
88
|
-
this.updatePosition(state.val);
|
|
72
|
+
this.handleSensor.updatePosition(state.val);
|
|
89
73
|
break;
|
|
90
74
|
case 'OPERATING_VOLTAGE':
|
|
91
|
-
this.
|
|
92
|
-
this.checkForBatteryChange();
|
|
93
|
-
this.persistBatteryDevice();
|
|
75
|
+
this.battery.level = 100 * ((state.val - 0.9) / 0.6);
|
|
94
76
|
break;
|
|
95
77
|
}
|
|
96
78
|
break;
|
|
97
79
|
}
|
|
98
80
|
}
|
|
99
81
|
/** @inheritDoc */
|
|
100
|
-
persistBatteryDevice() {
|
|
101
|
-
var _a;
|
|
102
|
-
const now = services_1.Utils.nowMS();
|
|
103
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
107
|
-
this._lastBatteryPersist = now;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Persists the handle sensor state to the persistence layer
|
|
111
|
-
*/
|
|
112
|
-
persistHandleSensor() {
|
|
113
|
-
var _a;
|
|
114
|
-
const now = services_1.Utils.nowMS();
|
|
115
|
-
if (this._lastHandlePersist + 2000 > now) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this.log(models_2.LogLevel.Debug, `Persist handle state: ${this.position}`);
|
|
119
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistHandleSensor(this);
|
|
120
|
-
this._lastHandlePersist = now;
|
|
121
|
-
}
|
|
122
|
-
/** @inheritDoc */
|
|
123
82
|
dispose() {
|
|
124
|
-
|
|
125
|
-
clearInterval(this._iOpenTimeout);
|
|
126
|
-
this._iOpenTimeout = undefined;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/** @inheritDoc */
|
|
130
|
-
toJSON() {
|
|
131
|
-
return lodash_1.default.omit(super.toJSON(), ['_window']);
|
|
132
|
-
}
|
|
133
|
-
updatePosition(pValue) {
|
|
134
|
-
if (pValue === this.position) {
|
|
135
|
-
if (this._lastHandlePersist == 0) {
|
|
136
|
-
this.persistHandleSensor();
|
|
137
|
-
}
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
this.log(models_2.LogLevel.Debug, `Update Windowhandle to position "${models_1.WindowPosition[pValue]}"`);
|
|
141
|
-
this.position = pValue;
|
|
142
|
-
for (const c1 of this._closedCallback) {
|
|
143
|
-
c1(pValue === 0);
|
|
144
|
-
}
|
|
145
|
-
for (const c2 of this._kippCallback) {
|
|
146
|
-
c2(pValue === 1);
|
|
147
|
-
}
|
|
148
|
-
for (const c3 of this._offenCallback) {
|
|
149
|
-
c3(pValue === 2);
|
|
150
|
-
}
|
|
151
|
-
this.persistHandleSensor();
|
|
152
|
-
if (pValue === models_1.WindowPosition.geschlossen) {
|
|
153
|
-
if (this._iOpenTimeout !== undefined) {
|
|
154
|
-
clearInterval(this._iOpenTimeout);
|
|
155
|
-
this.log(models_2.LogLevel.Info, `Window closed after ${this.minutesOpen} minutes`);
|
|
156
|
-
this.minutesOpen = 0;
|
|
157
|
-
this._iOpenTimeout = undefined;
|
|
158
|
-
}
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (this._iOpenTimeout !== undefined) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
this._iOpenTimeout = services_1.Utils.guardedInterval(() => {
|
|
165
|
-
var _a;
|
|
166
|
-
this.minutesOpen++;
|
|
167
|
-
const heatgroup = (_a = this._window) === null || _a === void 0 ? void 0 : _a.getRoom().HeatGroup;
|
|
168
|
-
if (heatgroup !== undefined) {
|
|
169
|
-
const desiredTemp = heatgroup.desiredTemp;
|
|
170
|
-
const currentTemp = heatgroup.temperature;
|
|
171
|
-
const outSideTemp = services_1.WeatherService.getCurrentTemp();
|
|
172
|
-
// Check if any of these values are unavailable
|
|
173
|
-
if (desiredTemp > -99 && currentTemp > -99 && outSideTemp > -99) {
|
|
174
|
-
const wouldHelp = (desiredTemp < currentTemp && outSideTemp < currentTemp) ||
|
|
175
|
-
(desiredTemp > currentTemp && outSideTemp > currentTemp);
|
|
176
|
-
if (!wouldHelp && this._helpingRoomTemp) {
|
|
177
|
-
const info = "Window should be closed, as it doesn't help reaching target temperature.";
|
|
178
|
-
this.log(models_2.LogLevel.Info, info);
|
|
179
|
-
if (this.settings.informNotHelping) {
|
|
180
|
-
services_1.TelegramService.inform(info);
|
|
181
|
-
}
|
|
182
|
-
this._helpingRoomTemp = false;
|
|
183
|
-
}
|
|
184
|
-
else if (wouldHelp && !this._helpingRoomTemp) {
|
|
185
|
-
this._helpingRoomTemp = true;
|
|
186
|
-
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.`;
|
|
187
|
-
this.log(models_2.LogLevel.Info, info);
|
|
188
|
-
if (this.settings.informIsHelping) {
|
|
189
|
-
services_1.TelegramService.inform(info);
|
|
190
|
-
}
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
else if (wouldHelp && this._helpingRoomTemp) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const message = `Window is in position ${models_1.WindowPosition[this.position]} since ${this.minutesOpen} minutes`;
|
|
199
|
-
switch (this.minutesOpen) {
|
|
200
|
-
case 15:
|
|
201
|
-
case 30:
|
|
202
|
-
case 60:
|
|
203
|
-
case 120:
|
|
204
|
-
case 240:
|
|
205
|
-
this.log(models_2.LogLevel.Info, message);
|
|
206
|
-
if (this.settings.informOnOpen) {
|
|
207
|
-
services_1.TelegramService.inform(`${this.info.room}: ${message}`);
|
|
208
|
-
}
|
|
209
|
-
break;
|
|
210
|
-
default:
|
|
211
|
-
this.log(models_2.LogLevel.Trace, message);
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
}, 60000, this);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
218
|
-
*/
|
|
219
|
-
checkForBatteryChange() {
|
|
220
|
-
const newLevel = this.battery;
|
|
221
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
225
|
-
cb(new models_2.BatteryLevelChangeAction(this));
|
|
226
|
-
}
|
|
227
|
-
this._lastBatteryLevel = newLevel;
|
|
83
|
+
this.handleSensor.dispose();
|
|
228
84
|
}
|
|
229
85
|
}
|
|
230
86
|
exports.HmIpGriff = HmIpGriff;
|
|
@@ -3,34 +3,29 @@ import { iDisposable } from '../../services';
|
|
|
3
3
|
import { HeaterSettings, HumiditySensorChangeAction, TemperatureSensorChangeAction } from '../../../models';
|
|
4
4
|
import { iHeater, iHumiditySensor, iTemperatureSensor } from '../baseDeviceInterfaces';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
|
+
import { HumiditySensor, TemperatureSensor } from '../sharedFunctions';
|
|
6
7
|
export declare class HmIpHeizgruppe extends HmIPDevice implements iTemperatureSensor, iHumiditySensor, iHeater, iDisposable {
|
|
7
8
|
/** @inheritDoc */
|
|
8
9
|
readonly persistHeaterInterval: NodeJS.Timeout;
|
|
9
10
|
/** @inheritDoc */
|
|
10
|
-
|
|
11
|
+
temperatureSensor: TemperatureSensor;
|
|
11
12
|
/** @inheritDoc */
|
|
12
|
-
|
|
13
|
+
humiditySensor: HumiditySensor;
|
|
13
14
|
/** @inheritDoc */
|
|
14
15
|
settings: HeaterSettings;
|
|
15
16
|
private _iAutomaticInterval;
|
|
16
17
|
private _initialSeasonCheckDone;
|
|
17
18
|
private _level;
|
|
18
19
|
private _setPointTemperatureID;
|
|
19
|
-
private _humidityCallbacks;
|
|
20
|
-
private _temperatureCallbacks;
|
|
21
20
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
22
21
|
protected _seasonTurnOff: boolean;
|
|
23
22
|
/** @inheritDoc */
|
|
24
23
|
get seasonTurnOff(): boolean;
|
|
25
24
|
/** @inheritDoc */
|
|
26
25
|
set seasonTurnOff(value: boolean);
|
|
27
|
-
private _temperature;
|
|
28
26
|
get temperature(): number;
|
|
29
|
-
private set temperature(value);
|
|
30
|
-
private _humidity;
|
|
31
27
|
/** @inheritDoc */
|
|
32
28
|
get humidity(): number;
|
|
33
|
-
private set humidity(value);
|
|
34
29
|
private _desiredTemperature;
|
|
35
30
|
/** @inheritDoc */
|
|
36
31
|
get desiredTemperature(): number;
|
|
@@ -43,7 +38,6 @@ export declare class HmIpHeizgruppe extends HmIPDevice implements iTemperatureSe
|
|
|
43
38
|
get sTemperature(): string;
|
|
44
39
|
/** @inheritDoc */
|
|
45
40
|
get iTemperature(): number;
|
|
46
|
-
private _roomTemperature;
|
|
47
41
|
/** @inheritDoc */
|
|
48
42
|
get roomTemperature(): number;
|
|
49
43
|
/** @inheritDoc */
|
|
@@ -62,9 +56,7 @@ export declare class HmIpHeizgruppe extends HmIPDevice implements iTemperatureSe
|
|
|
62
56
|
/** @inheritDoc */
|
|
63
57
|
persistHeater(): void;
|
|
64
58
|
/** @inheritDoc */
|
|
65
|
-
persistHumiditySensor(): void;
|
|
66
|
-
private updateBaseInformation;
|
|
67
|
-
private checkSeasonTurnOff;
|
|
68
|
-
/** @inheritDoc */
|
|
69
59
|
dispose(): void;
|
|
60
|
+
private checkSeasonTurnOff;
|
|
61
|
+
private updateBaseInformation;
|
|
70
62
|
}
|
|
@@ -5,9 +5,9 @@ const hmIpDevice_1 = require("./hmIpDevice");
|
|
|
5
5
|
const deviceType_1 = require("../deviceType");
|
|
6
6
|
const services_1 = require("../../services");
|
|
7
7
|
const models_1 = require("../../../models");
|
|
8
|
-
const baseDeviceInterfaces_1 = require("../baseDeviceInterfaces");
|
|
9
8
|
const device_cluster_type_1 = require("../device-cluster-type");
|
|
10
9
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
10
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
11
11
|
class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
|
|
12
12
|
constructor(pInfo) {
|
|
13
13
|
super(pInfo, deviceType_1.DeviceType.HmIpHeizgruppe);
|
|
@@ -16,25 +16,16 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
|
|
|
16
16
|
this.persistHeater();
|
|
17
17
|
}, 5 * 60 * 1000, this, false);
|
|
18
18
|
/** @inheritDoc */
|
|
19
|
-
this.
|
|
20
|
-
this.persistTemperaturSensor();
|
|
21
|
-
}, 5 * 60 * 1000, this, false);
|
|
19
|
+
this.temperatureSensor = new sharedFunctions_1.TemperatureSensor(this);
|
|
22
20
|
/** @inheritDoc */
|
|
23
|
-
this.
|
|
24
|
-
this.persistHumiditySensor();
|
|
25
|
-
}, 5 * 60 * 1000, this, false);
|
|
21
|
+
this.humiditySensor = new sharedFunctions_1.HumiditySensor(this);
|
|
26
22
|
/** @inheritDoc */
|
|
27
23
|
this.settings = new models_1.HeaterSettings();
|
|
28
24
|
this._initialSeasonCheckDone = false;
|
|
29
25
|
this._level = 0;
|
|
30
26
|
this._setPointTemperatureID = '';
|
|
31
|
-
this._humidityCallbacks = [];
|
|
32
|
-
this._temperatureCallbacks = [];
|
|
33
27
|
this._seasonTurnOff = false;
|
|
34
|
-
this._temperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
|
|
35
|
-
this._humidity = baseDeviceInterfaces_1.UNDEFINED_HUMIDITY_VALUE;
|
|
36
28
|
this._desiredTemperature = 0;
|
|
37
|
-
this._roomTemperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
|
|
38
29
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.temperatureSensor);
|
|
39
30
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.humiditySensor);
|
|
40
31
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.heater);
|
|
@@ -60,25 +51,13 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
|
|
|
60
51
|
}
|
|
61
52
|
get temperature() {
|
|
62
53
|
if (this.settings.useOwnTemperatur) {
|
|
63
|
-
return this.
|
|
64
|
-
}
|
|
65
|
-
return this._roomTemperature;
|
|
66
|
-
}
|
|
67
|
-
set temperature(val) {
|
|
68
|
-
this._temperature = val;
|
|
69
|
-
for (const cb of this._temperatureCallbacks) {
|
|
70
|
-
cb(new models_1.TemperatureSensorChangeAction(this, val));
|
|
54
|
+
return this.temperatureSensor.temperature;
|
|
71
55
|
}
|
|
56
|
+
return this.roomTemperature;
|
|
72
57
|
}
|
|
73
58
|
/** @inheritDoc */
|
|
74
59
|
get humidity() {
|
|
75
|
-
return this.
|
|
76
|
-
}
|
|
77
|
-
set humidity(val) {
|
|
78
|
-
this._humidity = val;
|
|
79
|
-
for (const cb of this._humidityCallbacks) {
|
|
80
|
-
cb(new models_1.HumiditySensorChangeAction(this, val));
|
|
81
|
-
}
|
|
60
|
+
return this.humiditySensor.humidity;
|
|
82
61
|
}
|
|
83
62
|
/** @inheritDoc */
|
|
84
63
|
get desiredTemperature() {
|
|
@@ -109,14 +88,11 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
|
|
|
109
88
|
}
|
|
110
89
|
/** @inheritDoc */
|
|
111
90
|
get roomTemperature() {
|
|
112
|
-
return this.
|
|
91
|
+
return this.temperatureSensor.roomTemperature;
|
|
113
92
|
}
|
|
114
93
|
/** @inheritDoc */
|
|
115
94
|
addHumidityCallback(pCallback) {
|
|
116
|
-
this.
|
|
117
|
-
if (this._humidity > 0) {
|
|
118
|
-
pCallback(new models_1.HumiditySensorChangeAction(this, this._humidity));
|
|
119
|
-
}
|
|
95
|
+
this.humiditySensor.addHumidityCallback(pCallback);
|
|
120
96
|
}
|
|
121
97
|
getBelongingHeizungen() {
|
|
122
98
|
return this.room.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.Heater);
|
|
@@ -153,14 +129,11 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
|
|
|
153
129
|
}
|
|
154
130
|
/** @inheritDoc */
|
|
155
131
|
addTempChangeCallback(pCallback) {
|
|
156
|
-
this.
|
|
157
|
-
if (this._temperature > baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE) {
|
|
158
|
-
pCallback(new models_1.TemperatureSensorChangeAction(this, this._temperature));
|
|
159
|
-
}
|
|
132
|
+
this.temperatureSensor.addTempChangeCallback(pCallback);
|
|
160
133
|
}
|
|
161
134
|
/** @inheritDoc */
|
|
162
135
|
onTemperaturChange(newTemperatur) {
|
|
163
|
-
this.
|
|
136
|
+
this.temperatureSensor.roomTemperature = newTemperatur;
|
|
164
137
|
}
|
|
165
138
|
/** @inheritDoc */
|
|
166
139
|
persistTemperaturSensor() {
|
|
@@ -173,20 +146,35 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
|
|
|
173
146
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistHeater(this);
|
|
174
147
|
}
|
|
175
148
|
/** @inheritDoc */
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
149
|
+
dispose() {
|
|
150
|
+
this.temperatureSensor.dispose();
|
|
151
|
+
this.humiditySensor.dispose();
|
|
152
|
+
if (this.persistHeaterInterval) {
|
|
153
|
+
clearInterval(this.persistHeaterInterval);
|
|
154
|
+
}
|
|
155
|
+
if (this._iAutomaticInterval) {
|
|
156
|
+
clearInterval(this._iAutomaticInterval);
|
|
157
|
+
this._iAutomaticInterval = undefined;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
checkSeasonTurnOff() {
|
|
161
|
+
const isSummer = services_1.Utils.beetweenDays(new Date(), this.settings.seasonTurnOffDay, this.settings.seasonTurnOnDay);
|
|
162
|
+
if (isSummer !== this.seasonTurnOff || !this._initialSeasonCheckDone) {
|
|
163
|
+
this.log(models_1.LogLevel.Info, `Switching Seasonal Heating --> New seasonTurnOff: ${isSummer}`);
|
|
164
|
+
this.seasonTurnOff = isSummer;
|
|
165
|
+
}
|
|
166
|
+
this._initialSeasonCheckDone = true;
|
|
179
167
|
}
|
|
180
168
|
updateBaseInformation(name, state) {
|
|
181
169
|
switch (name) {
|
|
182
170
|
case 'ACTUAL_TEMPERATURE':
|
|
183
|
-
this.temperature = state.val;
|
|
171
|
+
this.temperatureSensor.temperature = state.val;
|
|
184
172
|
break;
|
|
185
173
|
case 'LEVEL':
|
|
186
174
|
this._level = state.val;
|
|
187
175
|
break;
|
|
188
176
|
case 'HUMIDITY':
|
|
189
|
-
this.humidity = state.val;
|
|
177
|
+
this.humiditySensor.humidity = state.val;
|
|
190
178
|
break;
|
|
191
179
|
case 'SET_POINT_TEMPERATURE':
|
|
192
180
|
this.log(models_1.LogLevel.DeepTrace, `Heizgruppe Update Soll-Temperatur JSON: ${JSON.stringify(state)}`);
|
|
@@ -194,29 +182,5 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
|
|
|
194
182
|
break;
|
|
195
183
|
}
|
|
196
184
|
}
|
|
197
|
-
checkSeasonTurnOff() {
|
|
198
|
-
const isSummer = services_1.Utils.beetweenDays(new Date(), this.settings.seasonTurnOffDay, this.settings.seasonTurnOnDay);
|
|
199
|
-
if (isSummer !== this.seasonTurnOff || !this._initialSeasonCheckDone) {
|
|
200
|
-
this.log(models_1.LogLevel.Info, `Switching Seasonal Heating --> New seasonTurnOff: ${isSummer}`);
|
|
201
|
-
this.seasonTurnOff = isSummer;
|
|
202
|
-
}
|
|
203
|
-
this._initialSeasonCheckDone = true;
|
|
204
|
-
}
|
|
205
|
-
/** @inheritDoc */
|
|
206
|
-
dispose() {
|
|
207
|
-
if (this.persistTemperatureSensorInterval) {
|
|
208
|
-
clearInterval(this.persistTemperatureSensorInterval);
|
|
209
|
-
}
|
|
210
|
-
if (this.persistHumiditySensorInterval) {
|
|
211
|
-
clearInterval(this.persistHumiditySensorInterval);
|
|
212
|
-
}
|
|
213
|
-
if (this.persistHeaterInterval) {
|
|
214
|
-
clearInterval(this.persistHeaterInterval);
|
|
215
|
-
}
|
|
216
|
-
if (this._iAutomaticInterval) {
|
|
217
|
-
clearInterval(this._iAutomaticInterval);
|
|
218
|
-
this._iAutomaticInterval = undefined;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
185
|
}
|
|
222
186
|
exports.HmIpHeizgruppe = HmIpHeizgruppe;
|
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
import { BatteryLevelChangeAction } from '../../../models';
|
|
2
1
|
import { HmIPDevice } from './hmIpDevice';
|
|
3
2
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
4
3
|
import { iBatteryDevice } from '../baseDeviceInterfaces';
|
|
4
|
+
import { Battery } from '../sharedFunctions';
|
|
5
5
|
export declare class HmIpHeizung extends HmIPDevice implements iBatteryDevice {
|
|
6
|
-
|
|
6
|
+
/** @inheritDoc */
|
|
7
|
+
readonly battery: Battery;
|
|
7
8
|
private _temperatur;
|
|
8
9
|
private _level;
|
|
9
10
|
private _adaptionState;
|
|
10
|
-
private _lastBatteryPersist;
|
|
11
|
-
private _lastBatteryLevel;
|
|
12
|
-
private _batteryLevelCallbacks;
|
|
13
11
|
private _desiredTemperatur;
|
|
14
12
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
15
|
-
get
|
|
16
|
-
get battery(): number;
|
|
13
|
+
get batteryLevel(): number;
|
|
17
14
|
get desiredTemperatur(): number;
|
|
18
15
|
get iLevel(): number;
|
|
19
16
|
get iTemperatur(): number;
|
|
20
17
|
/** @inheritDoc */
|
|
21
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
22
|
-
/** @inheritDoc */
|
|
23
18
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
24
|
-
persistBatteryDevice(): void;
|
|
25
19
|
private updateBaseInformation;
|
|
26
|
-
/**
|
|
27
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
28
|
-
*/
|
|
29
|
-
private checkForBatteryChange;
|
|
30
20
|
}
|
|
@@ -5,7 +5,7 @@ const deviceType_1 = require("../deviceType");
|
|
|
5
5
|
const models_1 = require("../../../models");
|
|
6
6
|
const hmIpDevice_1 = require("./hmIpDevice");
|
|
7
7
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
8
|
-
const
|
|
8
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
9
9
|
var HmIpHeizungAdaptionStates;
|
|
10
10
|
(function (HmIpHeizungAdaptionStates) {
|
|
11
11
|
HmIpHeizungAdaptionStates[HmIpHeizungAdaptionStates["StateNotAvailable"] = 0] = "StateNotAvailable";
|
|
@@ -21,20 +21,15 @@ var HmIpHeizungAdaptionStates;
|
|
|
21
21
|
class HmIpHeizung extends hmIpDevice_1.HmIPDevice {
|
|
22
22
|
constructor(pInfo) {
|
|
23
23
|
super(pInfo, deviceType_1.DeviceType.HmIpHeizung);
|
|
24
|
-
|
|
24
|
+
/** @inheritDoc */
|
|
25
|
+
this.battery = new sharedFunctions_1.Battery(this);
|
|
25
26
|
this._temperatur = 0;
|
|
26
27
|
this._level = 0;
|
|
27
|
-
this._lastBatteryPersist = 0;
|
|
28
|
-
this._lastBatteryLevel = -1;
|
|
29
|
-
this._batteryLevelCallbacks = [];
|
|
30
28
|
this._desiredTemperatur = 0;
|
|
31
29
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
32
30
|
}
|
|
33
|
-
get
|
|
34
|
-
return this.
|
|
35
|
-
}
|
|
36
|
-
get battery() {
|
|
37
|
-
return this._battery;
|
|
31
|
+
get batteryLevel() {
|
|
32
|
+
return this.battery.level;
|
|
38
33
|
}
|
|
39
34
|
get desiredTemperatur() {
|
|
40
35
|
return this._desiredTemperatur;
|
|
@@ -46,10 +41,6 @@ class HmIpHeizung extends hmIpDevice_1.HmIPDevice {
|
|
|
46
41
|
return this._temperatur;
|
|
47
42
|
}
|
|
48
43
|
/** @inheritDoc */
|
|
49
|
-
addBatteryLevelCallback(pCallback) {
|
|
50
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
51
|
-
}
|
|
52
|
-
/** @inheritDoc */
|
|
53
44
|
update(idSplit, state, initial = false) {
|
|
54
45
|
this.log(models_1.LogLevel.DeepTrace, `Heizung Update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
|
|
55
46
|
super.update(idSplit, state, initial, true);
|
|
@@ -57,9 +48,7 @@ class HmIpHeizung extends hmIpDevice_1.HmIPDevice {
|
|
|
57
48
|
case '0':
|
|
58
49
|
switch (idSplit[4]) {
|
|
59
50
|
case 'OPERATING_VOLTAGE':
|
|
60
|
-
this.
|
|
61
|
-
this.checkForBatteryChange();
|
|
62
|
-
this.persistBatteryDevice();
|
|
51
|
+
this.battery.level = 100 * ((state.val - 1.8) / 1.2);
|
|
63
52
|
break;
|
|
64
53
|
}
|
|
65
54
|
break;
|
|
@@ -68,15 +57,6 @@ class HmIpHeizung extends hmIpDevice_1.HmIPDevice {
|
|
|
68
57
|
break;
|
|
69
58
|
}
|
|
70
59
|
}
|
|
71
|
-
persistBatteryDevice() {
|
|
72
|
-
var _a;
|
|
73
|
-
const now = services_1.Utils.nowMS();
|
|
74
|
-
if (this._lastBatteryPersist + 60000 > now) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
78
|
-
this._lastBatteryPersist = now;
|
|
79
|
-
}
|
|
80
60
|
updateBaseInformation(name, state) {
|
|
81
61
|
switch (name) {
|
|
82
62
|
case 'ACTUAL_TEMPERATURE':
|
|
@@ -98,18 +78,5 @@ class HmIpHeizung extends hmIpDevice_1.HmIPDevice {
|
|
|
98
78
|
break;
|
|
99
79
|
}
|
|
100
80
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
103
|
-
*/
|
|
104
|
-
checkForBatteryChange() {
|
|
105
|
-
const newLevel = this.battery;
|
|
106
|
-
if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
for (const cb of this._batteryLevelCallbacks) {
|
|
110
|
-
cb(new models_1.BatteryLevelChangeAction(this));
|
|
111
|
-
}
|
|
112
|
-
this._lastBatteryLevel = newLevel;
|
|
113
|
-
}
|
|
114
81
|
}
|
|
115
82
|
exports.HmIpHeizung = HmIpHeizung;
|
|
@@ -1,41 +1,32 @@
|
|
|
1
1
|
import { HmIPDevice } from './hmIpDevice';
|
|
2
|
-
import {
|
|
2
|
+
import { MotionSensorAction, MotionSensorSettings } from '../../../models';
|
|
3
3
|
import { iBatteryDevice, iIlluminationSensor, iMotionSensor } from '../baseDeviceInterfaces';
|
|
4
4
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
5
|
+
import { Battery } from '../sharedFunctions';
|
|
5
6
|
export declare class HmIpPraezenz extends HmIPDevice implements iIlluminationSensor, iBatteryDevice, iMotionSensor {
|
|
7
|
+
/** @inheritDoc */
|
|
8
|
+
readonly battery: Battery;
|
|
6
9
|
private static PRESENCE_DETECTION;
|
|
7
10
|
private static CURRENT_ILLUMINATION;
|
|
8
11
|
/** @inheritDoc */
|
|
9
12
|
movementDetected: boolean;
|
|
10
13
|
/** @inheritDoc */
|
|
11
14
|
settings: MotionSensorSettings;
|
|
12
|
-
private _battery;
|
|
13
|
-
private _lastBatteryPersist;
|
|
14
15
|
private _movementDetectedCallback;
|
|
15
16
|
private initialized;
|
|
16
17
|
private _lastMotionTime;
|
|
17
18
|
private _detectionsToday;
|
|
18
19
|
private _currentIllumination;
|
|
19
|
-
private _lastBatteryLevel;
|
|
20
|
-
private _batteryLevelCallbacks;
|
|
21
20
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
22
|
-
get
|
|
23
|
-
get battery(): number;
|
|
21
|
+
get batteryLevel(): number;
|
|
24
22
|
get timeSinceLastMotion(): number;
|
|
25
23
|
get detectionsToday(): number;
|
|
26
24
|
set detectionsToday(pVal: number);
|
|
27
25
|
get currentIllumination(): number;
|
|
28
26
|
private set currentIllumination(value);
|
|
29
|
-
/** @inheritDoc */
|
|
30
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
31
27
|
addMovementCallback(pCallback: (action: MotionSensorAction) => void): void;
|
|
32
28
|
/** @inheritDoc */
|
|
33
29
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
34
30
|
updatePresence(pVal: boolean): void;
|
|
35
31
|
persistMotionSensor(): void;
|
|
36
|
-
persistBatteryDevice(): void;
|
|
37
|
-
/**
|
|
38
|
-
* Checks whether the battery level did change and if so fires the callbacks
|
|
39
|
-
*/
|
|
40
|
-
private checkForBatteryChange;
|
|
41
32
|
}
|