hoffmation-base 2.4.6 → 2.5.0

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.
@@ -1,5 +1,8 @@
1
1
  import { DeviceSettings } from './deviceSettings';
2
+ import { TemperatureSettings } from '../temperatureSettings';
3
+ import { iIdHolder } from '../iIdHolder';
2
4
  export declare class HeaterSettings extends DeviceSettings {
5
+ automaticPoints: TemperatureSettings[];
3
6
  automaticMode: boolean;
4
7
  automaticFallBackTemperatur: number;
5
8
  useOwnTemperatur: boolean;
@@ -33,4 +36,6 @@ export declare class HeaterSettings extends DeviceSettings {
33
36
  pidForcedMinimum: number;
34
37
  fromPartialObject(data: Partial<HeaterSettings>): void;
35
38
  protected toJSON(): Partial<HeaterSettings>;
39
+ deleteAutomaticPoint(name: string, device: iIdHolder): void;
40
+ setAutomaticPoint(setting: TemperatureSettings, device: iIdHolder): void;
36
41
  }
@@ -6,6 +6,7 @@ const server_1 = require("../../server");
6
6
  class HeaterSettings extends deviceSettings_1.DeviceSettings {
7
7
  constructor() {
8
8
  super(...arguments);
9
+ this.automaticPoints = [];
9
10
  this.automaticMode = true;
10
11
  this.automaticFallBackTemperatur = 20;
11
12
  this.useOwnTemperatur = true;
@@ -39,20 +40,39 @@ class HeaterSettings extends deviceSettings_1.DeviceSettings {
39
40
  this.pidForcedMinimum = 1;
40
41
  }
41
42
  fromPartialObject(data) {
42
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
43
- this.automaticMode = (_a = data.automaticMode) !== null && _a !== void 0 ? _a : this.automaticMode;
44
- this.automaticFallBackTemperatur = (_b = data.automaticFallBackTemperatur) !== null && _b !== void 0 ? _b : this.automaticFallBackTemperatur;
45
- this.useOwnTemperatur = (_c = data.useOwnTemperatur) !== null && _c !== void 0 ? _c : this.useOwnTemperatur;
46
- this.controlByPid = (_d = data.controlByPid) !== null && _d !== void 0 ? _d : this.controlByPid;
47
- this.controlByTempDiff = (_e = data.controlByTempDiff) !== null && _e !== void 0 ? _e : this.controlByTempDiff;
48
- this.seasonalTurnOffActive = (_f = data.seasonalTurnOffActive) !== null && _f !== void 0 ? _f : this.seasonalTurnOffActive;
49
- this.seasonTurnOffDay = (_g = data.seasonTurnOffDay) !== null && _g !== void 0 ? _g : this.seasonTurnOffDay;
50
- this.seasonTurnOnDay = (_h = data.seasonTurnOnDay) !== null && _h !== void 0 ? _h : this.seasonTurnOnDay;
51
- this.pidForcedMinimum = (_j = data.pidForcedMinimum) !== null && _j !== void 0 ? _j : this.pidForcedMinimum;
43
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
44
+ this.automaticPoints = (_a = data.automaticPoints) !== null && _a !== void 0 ? _a : this.automaticPoints;
45
+ this.automaticMode = (_b = data.automaticMode) !== null && _b !== void 0 ? _b : this.automaticMode;
46
+ this.automaticFallBackTemperatur = (_c = data.automaticFallBackTemperatur) !== null && _c !== void 0 ? _c : this.automaticFallBackTemperatur;
47
+ this.useOwnTemperatur = (_d = data.useOwnTemperatur) !== null && _d !== void 0 ? _d : this.useOwnTemperatur;
48
+ this.controlByPid = (_e = data.controlByPid) !== null && _e !== void 0 ? _e : this.controlByPid;
49
+ this.controlByTempDiff = (_f = data.controlByTempDiff) !== null && _f !== void 0 ? _f : this.controlByTempDiff;
50
+ this.seasonalTurnOffActive = (_g = data.seasonalTurnOffActive) !== null && _g !== void 0 ? _g : this.seasonalTurnOffActive;
51
+ this.seasonTurnOffDay = (_h = data.seasonTurnOffDay) !== null && _h !== void 0 ? _h : this.seasonTurnOffDay;
52
+ this.seasonTurnOnDay = (_j = data.seasonTurnOnDay) !== null && _j !== void 0 ? _j : this.seasonTurnOnDay;
53
+ this.pidForcedMinimum = (_k = data.pidForcedMinimum) !== null && _k !== void 0 ? _k : this.pidForcedMinimum;
52
54
  super.fromPartialObject(data);
53
55
  }
54
56
  toJSON() {
55
57
  return server_1.Utils.jsonFilter(this);
56
58
  }
59
+ deleteAutomaticPoint(name, device) {
60
+ const currentIndex = this.automaticPoints.findIndex((v) => v.name === name);
61
+ if (currentIndex === -1) {
62
+ return;
63
+ }
64
+ this.automaticPoints.splice(currentIndex, 1);
65
+ this.persist(device);
66
+ }
67
+ setAutomaticPoint(setting, device) {
68
+ const currentIndex = this.automaticPoints.findIndex((v) => v.name === setting.name);
69
+ if (currentIndex === -1) {
70
+ this.automaticPoints.push(setting);
71
+ }
72
+ else {
73
+ this.automaticPoints[currentIndex] = setting;
74
+ }
75
+ this.persist(device);
76
+ }
57
77
  }
58
78
  exports.HeaterSettings = HeaterSettings;
@@ -3,10 +3,9 @@ export declare class TemperatureSettings {
3
3
  start: Daytime;
4
4
  end: Daytime;
5
5
  temperature: number;
6
+ name: string;
6
7
  active: boolean;
7
- constructor(start: Daytime, end: Daytime, temperature: number, active?: boolean);
8
- static getActiveSetting(settings: {
9
- [name: string]: TemperatureSettings;
10
- }, date: Date): TemperatureSettings | undefined;
8
+ constructor(start: Daytime, end: Daytime, temperature: number, name: string, active?: boolean);
9
+ static getActiveSetting(settings: TemperatureSettings[], date: Date): TemperatureSettings | undefined;
11
10
  isNowInRange(date: Date): boolean;
12
11
  }
@@ -2,18 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TemperatureSettings = void 0;
4
4
  class TemperatureSettings {
5
- constructor(start, end, temperature, active = true) {
5
+ constructor(start, end, temperature, name, active = true) {
6
6
  this.start = start;
7
7
  this.end = end;
8
8
  this.temperature = temperature;
9
+ this.name = name;
9
10
  this.active = active;
10
11
  }
11
12
  static getActiveSetting(settings, date) {
12
- for (const name of Object.keys(settings)) {
13
- if (settings[name] === undefined) {
14
- continue;
15
- }
16
- const setting = settings[name];
13
+ for (const setting of settings) {
17
14
  if (setting.isNowInRange(date)) {
18
15
  return setting;
19
16
  }
@@ -11,7 +11,7 @@ export interface iHeater extends iRoomDevice {
11
11
  readonly persistHeaterInterval: NodeJS.Timeout;
12
12
  seasonTurnOff: boolean;
13
13
  deleteAutomaticPoint(name: string): void;
14
- setAutomaticPoint(name: string, setting: TemperatureSettings): void;
14
+ setAutomaticPoint(setting: TemperatureSettings): void;
15
15
  stopAutomaticCheck(): void;
16
16
  checkAutomaticChange(): void;
17
17
  onTemperaturChange(newTemperatur: number): void;
@@ -14,7 +14,6 @@ export declare class HmIpHeizgruppe extends HmIPDevice implements iTemperatureSe
14
14
  private _initialSeasonCheckDone;
15
15
  private _level;
16
16
  private _setPointTemperatureID;
17
- private _automaticPoints;
18
17
  private _humidityCallbacks;
19
18
  private _temperatureCallbacks;
20
19
  constructor(pInfo: IoBrokerDeviceInfo);
@@ -39,8 +38,8 @@ export declare class HmIpHeizgruppe extends HmIPDevice implements iTemperatureSe
39
38
  set roomTemperature(value: number);
40
39
  addHumidityCallback(pCallback: (pValue: number) => void): void;
41
40
  deleteAutomaticPoint(name: string): void;
41
+ setAutomaticPoint(setting: TemperatureSettings): void;
42
42
  getBelongingHeizungen(): iHeater[];
43
- setAutomaticPoint(name: string, setting: TemperatureSettings): void;
44
43
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
45
44
  stopAutomaticCheck(): void;
46
45
  checkAutomaticChange(): void;
@@ -24,7 +24,6 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
24
24
  this._initialSeasonCheckDone = false;
25
25
  this._level = 0;
26
26
  this._setPointTemperatureID = '';
27
- this._automaticPoints = {};
28
27
  this._humidityCallbacks = [];
29
28
  this._temperatureCallbacks = [];
30
29
  this._seasonTurnOff = false;
@@ -109,8 +108,10 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
109
108
  }
110
109
  }
111
110
  deleteAutomaticPoint(name) {
112
- if (this._automaticPoints[name] !== undefined)
113
- delete this._automaticPoints[name];
111
+ this.settings.deleteAutomaticPoint(name, this);
112
+ }
113
+ setAutomaticPoint(setting) {
114
+ this.settings.setAutomaticPoint(setting, this);
114
115
  }
115
116
  getBelongingHeizungen() {
116
117
  if (!this.room) {
@@ -118,9 +119,6 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
118
119
  }
119
120
  return this.room.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.Heater);
120
121
  }
121
- setAutomaticPoint(name, setting) {
122
- this._automaticPoints[name] = setting;
123
- }
124
122
  update(idSplit, state, initial = false) {
125
123
  this.log(models_1.LogLevel.DeepTrace, `Heizgruppe Update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
126
124
  super.update(idSplit, state, initial, true);
@@ -144,7 +142,7 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
144
142
  if (!this.settings.automaticMode || this.seasonTurnOff) {
145
143
  return;
146
144
  }
147
- const setting = models_1.TemperatureSettings.getActiveSetting(this._automaticPoints, new Date());
145
+ const setting = models_1.TemperatureSettings.getActiveSetting(this.settings.automaticPoints, new Date());
148
146
  if (setting === undefined) {
149
147
  this.log(models_1.LogLevel.Warn, `Undefined Heating Timestamp.`);
150
148
  this.desiredTemperature = this.settings.automaticFallBackTemperatur;
@@ -40,7 +40,7 @@ export declare class ZigbeeHeater extends ZigbeeDevice implements iHeater, iBatt
40
40
  set roomTemperatur(val: number);
41
41
  checkAutomaticChange(): void;
42
42
  deleteAutomaticPoint(name: string): void;
43
- setAutomaticPoint(name: string, setting: TemperatureSettings): void;
43
+ setAutomaticPoint(setting: TemperatureSettings): void;
44
44
  stopAutomaticCheck(): void;
45
45
  onTemperaturChange(newTemperatur: number): void;
46
46
  persistHeater(): void;
@@ -98,7 +98,7 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
98
98
  if (!this.settings.automaticMode || this.seasonTurnOff) {
99
99
  return;
100
100
  }
101
- const setting = models_1.TemperatureSettings.getActiveSetting(this._automaticPoints, new Date());
101
+ const setting = models_1.TemperatureSettings.getActiveSetting(this.settings.automaticPoints, new Date());
102
102
  if (setting === undefined) {
103
103
  this.log(models_1.LogLevel.Warn, `Undefined Heating Timestamp.`);
104
104
  this.desiredTemperature = this.settings.automaticFallBackTemperatur;
@@ -110,11 +110,10 @@ class ZigbeeHeater extends zigbeeDevice_1.ZigbeeDevice {
110
110
  }
111
111
  }
112
112
  deleteAutomaticPoint(name) {
113
- if (this._automaticPoints[name] !== undefined)
114
- delete this._automaticPoints[name];
113
+ this.settings.deleteAutomaticPoint(name, this);
115
114
  }
116
- setAutomaticPoint(name, setting) {
117
- this._automaticPoints[name] = setting;
115
+ setAutomaticPoint(setting) {
116
+ this.settings.setAutomaticPoint(setting, this);
118
117
  }
119
118
  stopAutomaticCheck() {
120
119
  if (this._iAutomaticInterval !== undefined) {