hoffmation-base 3.0.0-alpha.40 → 3.0.0-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/lib/index.js +6 -3
  2. package/lib/models/action/batteryLevelChangeAction.d.ts +13 -0
  3. package/lib/models/action/batteryLevelChangeAction.js +14 -0
  4. package/lib/models/action/index.d.ts +1 -0
  5. package/lib/models/action/index.js +3 -1
  6. package/lib/models/command/blockAutomaticUntilCommand.js +1 -1
  7. package/lib/models/command/commandType.d.ts +1 -0
  8. package/lib/models/command/commandType.js +1 -0
  9. package/lib/models/deviceSettings/dachsSettings.d.ts +8 -0
  10. package/lib/models/deviceSettings/dachsSettings.js +10 -1
  11. package/lib/server/devices/baseDeviceInterfaces/iBatteryDevice.d.ts +9 -3
  12. package/lib/server/devices/dachs/dachs.d.ts +6 -2
  13. package/lib/server/devices/dachs/dachs.js +19 -2
  14. package/lib/server/devices/groups/lightGroup.js +2 -3
  15. package/lib/server/devices/groups/presenceGroup.js +2 -3
  16. package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +9 -0
  17. package/lib/server/devices/hmIPDevices/hmIpGriff.js +21 -0
  18. package/lib/server/devices/hmIPDevices/hmIpHeizung.d.ts +12 -3
  19. package/lib/server/devices/hmIPDevices/hmIpHeizung.js +32 -12
  20. package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +9 -1
  21. package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +20 -0
  22. package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +13 -4
  23. package/lib/server/devices/hmIPDevices/hmIpTaster.js +28 -8
  24. package/lib/server/devices/hmIPDevices/hmIpTherm.d.ts +10 -1
  25. package/lib/server/devices/hmIPDevices/hmIpTherm.js +25 -5
  26. package/lib/server/devices/shelly/shellyTrv.d.ts +9 -1
  27. package/lib/server/devices/shelly/shellyTrv.js +20 -0
  28. package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.d.ts +19 -11
  29. package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +47 -27
  30. package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.d.ts +16 -7
  31. package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.js +45 -25
  32. package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +9 -1
  33. package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +20 -0
  34. package/lib/server/devices/zigbee/zigbeeAquaraVibra.d.ts +9 -0
  35. package/lib/server/devices/zigbee/zigbeeAquaraVibra.js +20 -0
  36. package/lib/server/devices/zigbee/zigbeeAquaraWater.d.ts +18 -9
  37. package/lib/server/devices/zigbee/zigbeeAquaraWater.js +44 -24
  38. package/lib/server/devices/zigbee/zigbeeHeimanSmoke.d.ts +21 -12
  39. package/lib/server/devices/zigbee/zigbeeHeimanSmoke.js +37 -17
  40. package/lib/server/devices/zigbee/zigbeeSonoffTemp.d.ts +17 -9
  41. package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +30 -10
  42. package/lib/server/services/ac/own-daikin-device.d.ts +8 -0
  43. package/lib/server/services/ac/own-daikin-device.js +8 -0
  44. package/lib/server/services/victron/victron-device.d.ts +15 -4
  45. package/lib/server/services/victron/victron-device.js +54 -12
  46. package/lib/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +1 -1
@@ -8,16 +8,8 @@ const models_1 = require("../../../models");
8
8
  const DeviceCapability_1 = require("../DeviceCapability");
9
9
  const services_1 = require("../../services");
10
10
  class HmIpTaster extends hmIpDevice_1.HmIPDevice {
11
- get lastBatteryPersist() {
12
- return this._lastBatteryPersist;
13
- }
14
- get battery() {
15
- return this._battery;
16
- }
17
11
  constructor(pInfo) {
18
12
  super(pInfo, deviceType_1.DeviceType.HmIpTaster);
19
- this._battery = -99;
20
- this._lastBatteryPersist = 0;
21
13
  /**
22
14
  * Not present for HM-IP-Taster
23
15
  * @inheritDoc
@@ -28,6 +20,10 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
28
20
  * @inheritDoc
29
21
  */
30
22
  this.buttonTop = undefined;
23
+ this._battery = -99;
24
+ this._lastBatteryPersist = 0;
25
+ this._lastBatteryLevel = -1;
26
+ this._batteryLevelCallbacks = [];
31
27
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.buttonSwitch);
32
28
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
33
29
  this.buttonTopLeft = new button_1.Button('TopLeft', HmIpTaster.BUTTON_CAPABILLITIES);
@@ -37,6 +33,16 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
37
33
  this.buttonMidRight = new button_1.Button('MidRight', HmIpTaster.BUTTON_CAPABILLITIES);
38
34
  this.buttonBotRight = new button_1.Button('BotRight', HmIpTaster.BUTTON_CAPABILLITIES);
39
35
  }
36
+ get lastBatteryPersist() {
37
+ return this._lastBatteryPersist;
38
+ }
39
+ get battery() {
40
+ return this._battery;
41
+ }
42
+ /** @inheritDoc */
43
+ addBatteryLevelCallback(pCallback) {
44
+ this._batteryLevelCallbacks.push(pCallback);
45
+ }
40
46
  persist(buttonName, pressType) {
41
47
  var _a;
42
48
  (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistSwitchInput(this, pressType, buttonName);
@@ -51,6 +57,7 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
51
57
  switch (idSplit[4]) {
52
58
  case 'OPERATING_VOLTAGE':
53
59
  this._battery = 100 * ((state.val - 1.8) / 1.2);
60
+ this.checkForBatteryChange();
54
61
  this.persistBatteryDevice();
55
62
  break;
56
63
  }
@@ -170,6 +177,19 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
170
177
  }
171
178
  return result;
172
179
  }
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
+ }
173
193
  }
174
194
  exports.HmIpTaster = HmIpTaster;
175
195
  HmIpTaster.BUTTON_CAPABILLITIES = {
@@ -1,13 +1,22 @@
1
1
  import { HmIPDevice } from './hmIpDevice';
2
+ import { BatteryLevelChangeAction } from '../../../models';
2
3
  import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
3
4
  import { iBatteryDevice } from '../baseDeviceInterfaces';
4
5
  export declare class HmIpTherm extends HmIPDevice implements iBatteryDevice {
5
6
  private _battery;
6
7
  private _lastBatteryPersist;
8
+ private _lastBatteryLevel;
9
+ private _batteryLevelCallbacks;
10
+ constructor(pInfo: IoBrokerDeviceInfo);
7
11
  get lastBatteryPersist(): number;
8
12
  get battery(): number;
9
- constructor(pInfo: IoBrokerDeviceInfo);
13
+ /** @inheritDoc */
14
+ addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
10
15
  /** @inheritDoc */
11
16
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
12
17
  persistBatteryDevice(): void;
18
+ /**
19
+ * Checks whether the battery level did change and if so fires the callbacks
20
+ */
21
+ private checkForBatteryChange;
13
22
  }
@@ -7,17 +7,23 @@ const models_1 = require("../../../models");
7
7
  const DeviceCapability_1 = require("../DeviceCapability");
8
8
  const services_1 = require("../../services");
9
9
  class HmIpTherm extends hmIpDevice_1.HmIPDevice {
10
+ constructor(pInfo) {
11
+ super(pInfo, deviceType_1.DeviceType.HmIpTherm);
12
+ this._battery = -99;
13
+ this._lastBatteryPersist = 0;
14
+ this._lastBatteryLevel = -1;
15
+ this._batteryLevelCallbacks = [];
16
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
17
+ }
10
18
  get lastBatteryPersist() {
11
19
  return this._lastBatteryPersist;
12
20
  }
13
21
  get battery() {
14
22
  return this._battery;
15
23
  }
16
- constructor(pInfo) {
17
- super(pInfo, deviceType_1.DeviceType.HmIpTherm);
18
- this._battery = -99;
19
- this._lastBatteryPersist = 0;
20
- this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
24
+ /** @inheritDoc */
25
+ addBatteryLevelCallback(pCallback) {
26
+ this._batteryLevelCallbacks.push(pCallback);
21
27
  }
22
28
  /** @inheritDoc */
23
29
  update(idSplit, state, initial = false) {
@@ -28,6 +34,7 @@ class HmIpTherm extends hmIpDevice_1.HmIPDevice {
28
34
  switch (idSplit[4]) {
29
35
  case 'OPERATING_VOLTAGE':
30
36
  this._battery = 100 * ((state.val - 1.8) / 1.2);
37
+ this.checkForBatteryChange();
31
38
  this.persistBatteryDevice();
32
39
  break;
33
40
  }
@@ -43,5 +50,18 @@ class HmIpTherm extends hmIpDevice_1.HmIPDevice {
43
50
  (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
44
51
  this._lastBatteryPersist = now;
45
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
+ }
46
66
  }
47
67
  exports.HmIpTherm = HmIpTherm;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { ShellyDevice } from './shellyDevice';
3
3
  import { iBatteryDevice, iHeater } from '../baseDeviceInterfaces';
4
- import { HeaterSettings } from '../../../models';
4
+ import { BatteryLevelChangeAction, HeaterSettings } from '../../../models';
5
5
  import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
6
6
  export declare class ShellyTrv extends ShellyDevice implements iHeater, iBatteryDevice {
7
7
  /** @inheritDoc */
@@ -30,6 +30,8 @@ export declare class ShellyTrv extends ShellyDevice implements iHeater, iBattery
30
30
  private readonly _setEnableExternalTempId;
31
31
  private readonly _setPointTemperaturID;
32
32
  private readonly _valvePosId;
33
+ private _lastBatteryLevel;
34
+ private _batteryLevelCallbacks;
33
35
  constructor(pInfo: IoBrokerDeviceInfo);
34
36
  /** @inheritDoc */
35
37
  get lastBatteryPersist(): number;
@@ -52,6 +54,8 @@ export declare class ShellyTrv extends ShellyDevice implements iHeater, iBattery
52
54
  get roomTemperature(): number;
53
55
  private set roomTemperatur(value);
54
56
  /** @inheritDoc */
57
+ addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
58
+ /** @inheritDoc */
55
59
  checkAutomaticChange(): void;
56
60
  /** @inheritDoc */
57
61
  onTemperaturChange(newTemperatur: number): void;
@@ -71,4 +75,8 @@ export declare class ShellyTrv extends ShellyDevice implements iHeater, iBattery
71
75
  private setExternalTemperatureEnabled;
72
76
  private setValve;
73
77
  private setMinimumLevel;
78
+ /**
79
+ * Checks whether the battery level did change and if so fires the callbacks
80
+ */
81
+ private checkForBatteryChange;
74
82
  }
@@ -41,6 +41,8 @@ class ShellyTrv extends shellyDevice_1.ShellyDevice {
41
41
  Kd: 9, // PID: Kd in 1/1000
42
42
  });
43
43
  this._lastBatteryPersist = 0;
44
+ this._lastBatteryLevel = -1;
45
+ this._batteryLevelCallbacks = [];
44
46
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.heater);
45
47
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
46
48
  this._setAutomaticModeId = `${this.info.fullID}.tmp.automaticTemperatureControl`;
@@ -123,6 +125,10 @@ class ShellyTrv extends shellyDevice_1.ShellyDevice {
123
125
  }
124
126
  }
125
127
  /** @inheritDoc */
128
+ addBatteryLevelCallback(pCallback) {
129
+ this._batteryLevelCallbacks.push(pCallback);
130
+ }
131
+ /** @inheritDoc */
126
132
  checkAutomaticChange() {
127
133
  var _a;
128
134
  if (!this._initialSeasonCheckDone) {
@@ -194,6 +200,7 @@ class ShellyTrv extends shellyDevice_1.ShellyDevice {
194
200
  }
195
201
  else if (idSplit[3] === 'bat' && idSplit[4] === 'value') {
196
202
  this._battery = state.val;
203
+ this.checkForBatteryChange();
197
204
  this.persistBatteryDevice();
198
205
  if (this._battery < 20) {
199
206
  this.log(models_1.LogLevel.Warn, 'Das Shelly Gerät hat unter 20% Batterie.');
@@ -275,5 +282,18 @@ class ShellyTrv extends shellyDevice_1.ShellyDevice {
275
282
  setMinimumLevel(pidForcedMinimum) {
276
283
  this.setState(this._minumumLevelId, pidForcedMinimum);
277
284
  }
285
+ /**
286
+ * Checks whether the battery level did change and if so fires the callbacks
287
+ */
288
+ checkForBatteryChange() {
289
+ const newLevel = this.battery;
290
+ if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
291
+ return;
292
+ }
293
+ for (const cb of this._batteryLevelCallbacks) {
294
+ cb(new models_1.BatteryLevelChangeAction(this));
295
+ }
296
+ this._lastBatteryLevel = newLevel;
297
+ }
278
298
  }
279
299
  exports.ShellyTrv = ShellyTrv;
@@ -1,21 +1,16 @@
1
1
  /// <reference types="node" />
2
2
  import { ZigbeeDevice } from './zigbeeDevice';
3
3
  import { iBatteryDevice, iHeater } from '../../baseDeviceInterfaces';
4
- import { HeaterSettings } from '../../../../models';
4
+ import { BatteryLevelChangeAction, HeaterSettings } from '../../../../models';
5
5
  import { DeviceType } from '../../deviceType';
6
6
  import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
7
7
  import { PIDController } from '../../../../liquid-pid';
8
8
  export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatteryDevice {
9
- protected _battery: number;
10
- private _lastBatteryPersist;
11
- /** @inheritDoc */
12
- get lastBatteryPersist(): number;
13
9
  /** @inheritDoc */
14
10
  readonly persistHeaterInterval: NodeJS.Timeout;
15
11
  /** @inheritDoc */
16
12
  settings: HeaterSettings;
17
- /** @inheritDoc */
18
- get battery(): number;
13
+ protected _battery: number;
19
14
  protected _iAutomaticInterval: NodeJS.Timeout | undefined;
20
15
  protected _initialSeasonCheckDone: boolean;
21
16
  protected _level: number;
@@ -23,8 +18,16 @@ export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatt
23
18
  protected _temperatur: number;
24
19
  protected _desiredTemperatur: number;
25
20
  protected _pidController: PIDController;
26
- constructor(pInfo: IoBrokerDeviceInfo, pType: DeviceType);
27
21
  protected _seasonTurnOff: boolean;
22
+ protected _roomTemperature: number;
23
+ private _lastBatteryPersist;
24
+ private _lastBatteryLevel;
25
+ private _batteryLevelCallbacks;
26
+ constructor(pInfo: IoBrokerDeviceInfo, pType: DeviceType);
27
+ /** @inheritDoc */
28
+ get lastBatteryPersist(): number;
29
+ /** @inheritDoc */
30
+ get battery(): number;
28
31
  /** @inheritDoc */
29
32
  get seasonTurnOff(): boolean;
30
33
  /** @inheritDoc */
@@ -39,21 +42,26 @@ export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatt
39
42
  get sTemperatur(): string;
40
43
  /** @inheritDoc */
41
44
  get iTemperature(): number;
42
- protected _roomTemperature: number;
43
45
  /** @inheritDoc */
44
46
  get roomTemperature(): number;
45
47
  protected set roomTemperatur(val: number);
46
48
  /** @inheritDoc */
49
+ addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
50
+ /** @inheritDoc */
47
51
  checkAutomaticChange(): void;
48
52
  /** @inheritDoc */
49
53
  onTemperaturChange(newTemperatur: number): void;
50
54
  persistHeater(): void;
51
55
  /** @inheritDoc */
52
56
  update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
53
- protected getNextPidLevel(): number;
54
- private checkSeasonTurnOff;
55
57
  /** @inheritDoc */
56
58
  persistBatteryDevice(): void;
57
59
  /** @inheritDoc */
58
60
  dispose(): void;
61
+ protected getNextPidLevel(): number;
62
+ private checkSeasonTurnOff;
63
+ /**
64
+ * Checks whether the battery level did change and if so fires the callbacks
65
+ */
66
+ private checkForBatteryChange;
59
67
  }
@@ -8,24 +8,15 @@ const services_1 = require("../../../services");
8
8
  const DeviceCapability_1 = require("../../DeviceCapability");
9
9
  const liquid_pid_1 = require("../../../../liquid-pid");
10
10
  class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
11
- /** @inheritDoc */
12
- get lastBatteryPersist() {
13
- return this._lastBatteryPersist;
14
- }
15
- /** @inheritDoc */
16
- get battery() {
17
- return this._battery;
18
- }
19
11
  constructor(pInfo, pType) {
20
12
  super(pInfo, pType);
21
- this._battery = -99;
22
- this._lastBatteryPersist = 0;
23
13
  /** @inheritDoc */
24
14
  this.persistHeaterInterval = services_1.Utils.guardedInterval(() => {
25
15
  this.persistHeater();
26
16
  }, 5 * 60 * 1000, this, false);
27
17
  /** @inheritDoc */
28
18
  this.settings = new models_1.HeaterSettings();
19
+ this._battery = -99;
29
20
  this._initialSeasonCheckDone = false;
30
21
  this._level = 0;
31
22
  this._setPointTemperaturID = '';
@@ -43,6 +34,9 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
43
34
  });
44
35
  this._seasonTurnOff = false;
45
36
  this._roomTemperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
37
+ this._lastBatteryPersist = 0;
38
+ this._lastBatteryLevel = -1;
39
+ this._batteryLevelCallbacks = [];
46
40
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.heater);
47
41
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
48
42
  this._iAutomaticInterval = services_1.Utils.guardedInterval(this.checkAutomaticChange, 300000, this); // Alle 5 Minuten prüfen
@@ -51,6 +45,14 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
51
45
  }, 0, 2, 0));
52
46
  }
53
47
  /** @inheritDoc */
48
+ get lastBatteryPersist() {
49
+ return this._lastBatteryPersist;
50
+ }
51
+ /** @inheritDoc */
52
+ get battery() {
53
+ return this._battery;
54
+ }
55
+ /** @inheritDoc */
54
56
  get seasonTurnOff() {
55
57
  return this._seasonTurnOff;
56
58
  }
@@ -98,6 +100,10 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
98
100
  this._roomTemperature = val;
99
101
  }
100
102
  /** @inheritDoc */
103
+ addBatteryLevelCallback(pCallback) {
104
+ this._batteryLevelCallbacks.push(pCallback);
105
+ }
106
+ /** @inheritDoc */
101
107
  checkAutomaticChange() {
102
108
  var _a;
103
109
  if (!this._initialSeasonCheckDone) {
@@ -134,6 +140,7 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
134
140
  switch (idSplit[3]) {
135
141
  case 'battery':
136
142
  this._battery = state.val;
143
+ this.checkForBatteryChange();
137
144
  this.persistBatteryDevice();
138
145
  if (this._battery < 20) {
139
146
  this.log(models_1.LogLevel.Warn, 'Das Zigbee Gerät hat unter 20% Batterie.');
@@ -142,23 +149,6 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
142
149
  }
143
150
  super.update(idSplit, state, initial, pOverride);
144
151
  }
145
- getNextPidLevel() {
146
- if (this.seasonTurnOff || this._roomTemperature < 0) {
147
- return 0;
148
- }
149
- this._pidController.setPoint(this.desiredTemperature);
150
- const newValue = this._pidController.calculate(this._roomTemperature);
151
- this.log(models_1.LogLevel.Debug, `New PID Value ${newValue}% (cTemp: ${this._roomTemperature}, dTemp: ${this.desiredTemperature})`);
152
- return newValue;
153
- }
154
- checkSeasonTurnOff() {
155
- const desiredState = services_1.Utils.beetweenDays(new Date(), this.settings.seasonTurnOffDay, this.settings.seasonTurnOnDay);
156
- if (desiredState !== this.seasonTurnOff || !this._initialSeasonCheckDone) {
157
- this.log(models_1.LogLevel.Info, `Switching Seasonal Heating --> New seasonTurnOff: ${desiredState}`);
158
- this.seasonTurnOff = desiredState;
159
- }
160
- this._initialSeasonCheckDone = true;
161
- }
162
152
  /** @inheritDoc */
163
153
  persistBatteryDevice() {
164
154
  var _a;
@@ -180,5 +170,35 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
180
170
  }
181
171
  super.dispose();
182
172
  }
173
+ getNextPidLevel() {
174
+ if (this.seasonTurnOff || this._roomTemperature < 0) {
175
+ return 0;
176
+ }
177
+ this._pidController.setPoint(this.desiredTemperature);
178
+ const newValue = this._pidController.calculate(this._roomTemperature);
179
+ this.log(models_1.LogLevel.Debug, `New PID Value ${newValue}% (cTemp: ${this._roomTemperature}, dTemp: ${this.desiredTemperature})`);
180
+ return newValue;
181
+ }
182
+ checkSeasonTurnOff() {
183
+ const desiredState = services_1.Utils.beetweenDays(new Date(), this.settings.seasonTurnOffDay, this.settings.seasonTurnOnDay);
184
+ if (desiredState !== this.seasonTurnOff || !this._initialSeasonCheckDone) {
185
+ this.log(models_1.LogLevel.Info, `Switching Seasonal Heating --> New seasonTurnOff: ${desiredState}`);
186
+ this.seasonTurnOff = desiredState;
187
+ }
188
+ this._initialSeasonCheckDone = true;
189
+ }
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
+ }
183
203
  }
184
204
  exports.ZigbeeHeater = ZigbeeHeater;
@@ -1,35 +1,44 @@
1
1
  import { DeviceType } from '../../deviceType';
2
+ import { BatteryLevelChangeAction } from '../../../../models';
2
3
  import { ZigbeeDevice } from './zigbeeDevice';
3
4
  import { MagnetPosition } from '../../models';
4
5
  import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
5
6
  import { iBatteryDevice, iMagnetSensor } from '../../baseDeviceInterfaces';
6
7
  export declare class ZigbeeMagnetContact extends ZigbeeDevice implements iBatteryDevice, iMagnetSensor {
7
- protected _battery: number;
8
- private _lastBatteryPersist;
9
- /** @inheritDoc */
10
- get lastBatteryPersist(): number;
11
- /** @inheritDoc */
12
- get battery(): number;
13
8
  /** @inheritDoc */
14
9
  position: MagnetPosition;
15
10
  /** @inheritDoc */
16
11
  telegramOnOpen: boolean;
17
12
  /** @inheritDoc */
18
13
  speakOnOpen: boolean;
14
+ protected _battery: number;
15
+ private _lastBatteryPersist;
16
+ private _lastBatteryLevel;
17
+ private _batteryLevelCallbacks;
19
18
  private _closedCallback;
20
19
  private _openCallback;
21
20
  private _iOpenTimeout;
22
21
  private minutesOpen;
23
22
  constructor(pInfo: IoBrokerDeviceInfo, deviceType: DeviceType);
24
23
  /** @inheritDoc */
24
+ get lastBatteryPersist(): number;
25
+ /** @inheritDoc */
26
+ get battery(): number;
27
+ /** @inheritDoc */
25
28
  addOpenCallback(pCallback: (pValue: boolean) => void): void;
26
29
  /** @inheritDoc */
27
30
  addClosedCallback(pCallback: (pValue: boolean) => void): void;
28
31
  /** @inheritDoc */
32
+ addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
33
+ /** @inheritDoc */
29
34
  update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverrride?: boolean): void;
30
- protected updatePosition(pValue: MagnetPosition): void;
31
35
  /** @inheritDoc */
32
36
  dispose(): void;
33
37
  /** @inheritDoc */
34
38
  persistBatteryDevice(): void;
39
+ protected updatePosition(pValue: MagnetPosition): void;
40
+ /**
41
+ * Checks whether the battery level did change and if so fires the callbacks
42
+ */
43
+ private checkForBatteryChange;
35
44
  }
@@ -6,29 +6,31 @@ const models_1 = require("../../../../models");
6
6
  const zigbeeDevice_1 = require("./zigbeeDevice");
7
7
  const models_2 = require("../../models");
8
8
  class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
9
- /** @inheritDoc */
10
- get lastBatteryPersist() {
11
- return this._lastBatteryPersist;
12
- }
13
- /** @inheritDoc */
14
- get battery() {
15
- return this._battery;
16
- }
17
9
  constructor(pInfo, deviceType) {
18
10
  super(pInfo, deviceType);
19
- this._battery = -99;
20
- this._lastBatteryPersist = 0;
21
11
  /** @inheritDoc */
22
12
  this.position = models_2.MagnetPosition.closed;
23
13
  /** @inheritDoc */
24
14
  this.telegramOnOpen = false;
25
15
  /** @inheritDoc */
26
16
  this.speakOnOpen = false;
17
+ this._battery = -99;
18
+ this._lastBatteryPersist = 0;
19
+ this._lastBatteryLevel = -1;
20
+ this._batteryLevelCallbacks = [];
27
21
  this._closedCallback = [];
28
22
  this._openCallback = [];
29
23
  this.minutesOpen = 0;
30
24
  }
31
25
  /** @inheritDoc */
26
+ get lastBatteryPersist() {
27
+ return this._lastBatteryPersist;
28
+ }
29
+ /** @inheritDoc */
30
+ get battery() {
31
+ return this._battery;
32
+ }
33
+ /** @inheritDoc */
32
34
  addOpenCallback(pCallback) {
33
35
  this._openCallback.push(pCallback);
34
36
  }
@@ -37,11 +39,16 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
37
39
  this._closedCallback.push(pCallback);
38
40
  }
39
41
  /** @inheritDoc */
42
+ addBatteryLevelCallback(pCallback) {
43
+ this._batteryLevelCallbacks.push(pCallback);
44
+ }
45
+ /** @inheritDoc */
40
46
  update(idSplit, state, initial = false, pOverrride = false) {
41
47
  super.update(idSplit, state, initial, pOverrride);
42
48
  switch (idSplit[3]) {
43
49
  case 'battery':
44
50
  this._battery = state.val;
51
+ this.checkForBatteryChange();
45
52
  this.persistBatteryDevice();
46
53
  if (this._battery < 20) {
47
54
  this.log(models_1.LogLevel.Warn, 'Das Zigbee Gerät hat unter 20% Batterie.');
@@ -49,6 +56,24 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
49
56
  break;
50
57
  }
51
58
  }
59
+ /** @inheritDoc */
60
+ dispose() {
61
+ if (this._iOpenTimeout) {
62
+ clearInterval(this._iOpenTimeout);
63
+ this._iOpenTimeout = undefined;
64
+ }
65
+ super.dispose();
66
+ }
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
+ }
52
77
  updatePosition(pValue) {
53
78
  if (pValue === this.position) {
54
79
  return;
@@ -106,23 +131,18 @@ class ZigbeeMagnetContact extends zigbeeDevice_1.ZigbeeDevice {
106
131
  }, 60000, this);
107
132
  }
108
133
  }
109
- /** @inheritDoc */
110
- dispose() {
111
- if (this._iOpenTimeout) {
112
- clearInterval(this._iOpenTimeout);
113
- this._iOpenTimeout = undefined;
114
- }
115
- super.dispose();
116
- }
117
- /** @inheritDoc */
118
- persistBatteryDevice() {
119
- var _a;
120
- const now = services_1.Utils.nowMS();
121
- if (this._lastBatteryPersist + 60000 > now) {
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) {
122
140
  return;
123
141
  }
124
- (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
125
- this._lastBatteryPersist = now;
142
+ for (const cb of this._batteryLevelCallbacks) {
143
+ cb(new models_1.BatteryLevelChangeAction(this));
144
+ }
145
+ this._lastBatteryLevel = newLevel;
126
146
  }
127
147
  }
128
148
  exports.ZigbeeMagnetContact = ZigbeeMagnetContact;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { DeviceType } from '../../deviceType';
3
3
  import { ZigbeeDevice } from './index';
4
- import { MotionSensorAction, MotionSensorSettings } from '../../../../models';
4
+ import { BatteryLevelChangeAction, MotionSensorAction, MotionSensorSettings } from '../../../../models';
5
5
  import { iBatteryDevice, iMotionSensor } from '../../baseDeviceInterfaces';
6
6
  import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
7
7
  export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionSensor, iBatteryDevice {
@@ -17,6 +17,8 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
17
17
  private _movementDetected;
18
18
  private _battery;
19
19
  private _lastBatteryPersist;
20
+ private _lastBatteryLevel;
21
+ private _batteryLevelCallbacks;
20
22
  constructor(pInfo: IoBrokerDeviceInfo, type: DeviceType);
21
23
  /** @inheritDoc */
22
24
  get lastBatteryPersist(): number;
@@ -26,6 +28,8 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
26
28
  get battery(): number;
27
29
  /** @inheritDoc */
28
30
  get timeSinceLastMotion(): number;
31
+ /** @inheritDoc */
32
+ addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
29
33
  /**
30
34
  * Adds a callback for when a motion state has changed.
31
35
  * @param pCallback - Function that accepts the new state as parameter
@@ -41,4 +45,8 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
41
45
  persistBatteryDevice(): void;
42
46
  private resetFallbackTimeout;
43
47
  private startFallbackTimeout;
48
+ /**
49
+ * Checks whether the battery level did change and if so fires the callbacks
50
+ */
51
+ private checkForBatteryChange;
44
52
  }