hoffmation-base 1.0.13 → 1.0.16

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 (41) hide show
  1. package/lib/index.js +1 -1
  2. package/lib/models/deviceSettings/acSettings.d.ts +15 -0
  3. package/lib/models/deviceSettings/acSettings.js +15 -0
  4. package/lib/models/rooms/RoomBase.d.ts +1 -2
  5. package/lib/models/rooms/RoomBase.js +0 -3
  6. package/lib/server/devices/Heizgruppen.d.ts +0 -1
  7. package/lib/server/devices/Heizgruppen.js +2 -13
  8. package/lib/server/devices/baseDeviceInterfaces/iHumiditySensor.d.ts +1 -0
  9. package/lib/server/devices/baseDeviceInterfaces/iHumiditySensor.js +2 -0
  10. package/lib/server/devices/device-list.d.ts +2 -2
  11. package/lib/server/devices/device-list.js +6 -6
  12. package/lib/server/devices/groups/fensterGroup.js +1 -1
  13. package/lib/server/devices/groups/heatGroup.d.ts +20 -2
  14. package/lib/server/devices/groups/heatGroup.js +100 -38
  15. package/lib/server/devices/groups/index.d.ts +0 -1
  16. package/lib/server/devices/groups/index.js +0 -1
  17. package/lib/server/devices/groups/tasterGroup.js +4 -4
  18. package/lib/server/devices/hmIPDevices/hmIpGriff.js +1 -1
  19. package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.js +1 -1
  20. package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +1 -1
  21. package/lib/server/services/Telegram/telegram-Commands.js +1 -1
  22. package/lib/server/services/ac/ac-device.d.ts +7 -3
  23. package/lib/server/services/ac/ac-device.js +36 -10
  24. package/lib/server/services/ac/ac-mode.d.ts +4 -3
  25. package/lib/server/services/ac/ac-mode.js +4 -3
  26. package/lib/server/services/ac/acDeviceType.d.ts +4 -0
  27. package/lib/server/services/ac/acDeviceType.js +8 -0
  28. package/lib/server/services/ac/daikin-service.d.ts +2 -2
  29. package/lib/server/services/ac/daikin-service.js +9 -1
  30. package/lib/server/services/ac/index.d.ts +2 -1
  31. package/lib/server/services/ac/index.js +4 -2
  32. package/lib/server/services/ac/own-ac-devices.d.ts +7 -0
  33. package/lib/server/services/ac/{own-daikin-devices.js → own-ac-devices.js} +4 -4
  34. package/lib/server/services/ac/own-daikin-device.js +2 -1
  35. package/lib/server/services/api/api-service.d.ts +3 -3
  36. package/lib/server/services/api/api-service.js +2 -2
  37. package/lib/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +1 -1
  39. package/lib/server/devices/groups/acGroup.d.ts +0 -12
  40. package/lib/server/devices/groups/acGroup.js +0 -38
  41. package/lib/server/services/ac/own-daikin-devices.d.ts +0 -7
package/lib/index.js CHANGED
@@ -72,7 +72,7 @@ class HoffmationBase {
72
72
  server_1.SonosService.initialize();
73
73
  }
74
74
  if ((_b = server_1.SettingsService.settings.daikin) === null || _b === void 0 ? void 0 : _b.active) {
75
- server_1.DaikinService.addOwnDevices(server_1.OwnDaikinDevices.ownDevices);
75
+ server_1.DaikinService.addOwnDevices(server_1.OwnAcDevices.ownDevices);
76
76
  server_1.DaikinService.initialize();
77
77
  }
78
78
  server_1.Utils.guardedNewThread(() => {
@@ -4,4 +4,19 @@ export declare class AcSettings extends DeviceSettings {
4
4
  minimumMinutes: number;
5
5
  maximumHours: number;
6
6
  maximumMinutes: number;
7
+ /**
8
+ * The temperatur below which cooling should be stopped
9
+ * @type {number}
10
+ */
11
+ stopCoolingTemperatur: number;
12
+ /**
13
+ * The temperatur above which heating should be stopped
14
+ * @type {number}
15
+ */
16
+ stopHeatingTemperatur: number;
17
+ /**
18
+ * Heating can be forbidden completly e.g. for summer season
19
+ * @type {boolean}
20
+ */
21
+ heatingAllowed: boolean;
7
22
  }
@@ -9,6 +9,21 @@ class AcSettings extends deviceSettings_1.DeviceSettings {
9
9
  this.minimumMinutes = 0;
10
10
  this.maximumHours = 24;
11
11
  this.maximumMinutes = 0;
12
+ /**
13
+ * The temperatur below which cooling should be stopped
14
+ * @type {number}
15
+ */
16
+ this.stopCoolingTemperatur = 22;
17
+ /**
18
+ * The temperatur above which heating should be stopped
19
+ * @type {number}
20
+ */
21
+ this.stopHeatingTemperatur = 21.0;
22
+ /**
23
+ * Heating can be forbidden completly e.g. for summer season
24
+ * @type {boolean}
25
+ */
26
+ this.heatingAllowed = false;
12
27
  }
13
28
  }
14
29
  exports.AcSettings = AcSettings;
@@ -1,5 +1,5 @@
1
1
  import { TimeCallback } from '../timeCallback';
2
- import { AcGroup, BaseGroup, DeviceCluster, FensterGroup, GroupType, HeatGroup, LampenGroup, PraesenzGroup, SmokeGroup, SonosGroup, TasterGroup, WaterGroup } from '../../server';
2
+ import { BaseGroup, DeviceCluster, FensterGroup, GroupType, HeatGroup, LampenGroup, PraesenzGroup, SmokeGroup, SonosGroup, TasterGroup, WaterGroup } from '../../server';
3
3
  import { RoomSettings } from './RoomSettings';
4
4
  import { iRoomBase } from './iRoomBase';
5
5
  import { RoomInfo } from './roomInfo';
@@ -15,7 +15,6 @@ export declare class RoomBase implements iRoomBase {
15
15
  constructor(roomName: string, settings: RoomSettings, groups: Map<GroupType, BaseGroup>);
16
16
  protected _deviceCluster: DeviceCluster;
17
17
  get deviceCluster(): DeviceCluster;
18
- get AcGroup(): AcGroup | undefined;
19
18
  get FensterGroup(): FensterGroup | undefined;
20
19
  get PraesenzGroup(): PraesenzGroup | undefined;
21
20
  get LampenGroup(): LampenGroup | undefined;
@@ -23,9 +23,6 @@ class RoomBase {
23
23
  get deviceCluster() {
24
24
  return this._deviceCluster;
25
25
  }
26
- get AcGroup() {
27
- return this.groups.get(server_1.GroupType.Ac);
28
- }
29
26
  get FensterGroup() {
30
27
  return this.groups.get(server_1.GroupType.Window);
31
28
  }
@@ -1,6 +1,5 @@
1
1
  import { HmIpHeizgruppe } from './hmIPDevices';
2
2
  export declare class Heizgruppen {
3
- static getInfo(): string;
4
3
  static getSpecificInfo(pText: string | undefined): Promise<string>;
5
4
  static getProblems(): string;
6
5
  static getAllGruppen(): HmIpHeizgruppe[];
@@ -4,19 +4,8 @@ exports.Heizgruppen = void 0;
4
4
  const deviceType_1 = require("./deviceType");
5
5
  const devices_1 = require("./devices");
6
6
  const services_1 = require("../services");
7
+ const groups_1 = require("./groups");
7
8
  class Heizgruppen {
8
- static getInfo() {
9
- const gruppen = Heizgruppen.getAllGruppen();
10
- gruppen.sort((a, b) => {
11
- return a.info.customName.localeCompare(b.info.customName);
12
- });
13
- const response = [`Dies sind die aktuellen Informationen der Heizungen:`];
14
- response.push(`Name\t\tLuft Feuchtigkeit\t\tAktuelle Temperatur\t\tSoll Temperatur\t\tVentilstellung`);
15
- for (const g of gruppen) {
16
- response.push(`${g.info.customName}:\t\t${g.humidity}%\t\t${g.sTemperatur}\t\t${g.desiredTemperatur}°C\t\t${g.sLevel}`);
17
- }
18
- return response.join('\n');
19
- }
20
9
  static async getSpecificInfo(pText) {
21
10
  var _a, _b;
22
11
  if (pText === undefined || !pText.includes('"')) {
@@ -25,7 +14,7 @@ class Heizgruppen {
25
14
  const searchText = pText.split('"')[1];
26
15
  const group = this.getSpecificGroup(searchText);
27
16
  if (group === undefined) {
28
- return `"${searchText}" ist keine gültige Heizgruppe, im Folgenden ist eine Liste aller gültigen Heizgruppen:\n${this.getInfo()}`;
17
+ return `"${searchText}" ist keine gültige Heizgruppe, im Folgenden ist eine Liste aller gültigen Heizgruppen:\n${groups_1.HeatGroup.getInfo()}`;
29
18
  }
30
19
  const results = (_b = (await ((_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.readTemperaturDataPoint(group, 20)))) !== null && _b !== void 0 ? _b : [];
31
20
  const response = [`Dies sind die letzten 20 Messpunkte der Heizgruppe:`];
@@ -1,4 +1,5 @@
1
1
  import { IBaseDevice } from './iBaseDevice';
2
+ export declare const UNDEFINED_HUMIDITY_VALUE = -1;
2
3
  export interface iHumiditySensor extends IBaseDevice {
3
4
  humidity: number;
4
5
  addHumidityCallback(pCallback: (pValue: number) => void): void;
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UNDEFINED_HUMIDITY_VALUE = void 0;
4
+ exports.UNDEFINED_HUMIDITY_VALUE = -1;
@@ -3,8 +3,8 @@ import { IBaseDevice } from './baseDeviceInterfaces';
3
3
  export declare class DeviceList {
4
4
  private _ids;
5
5
  private readonly _isSonos;
6
- private readonly _isDaikin;
7
- constructor(_ids?: string[], _isSonos?: boolean, _isDaikin?: boolean);
6
+ private readonly _isAc;
7
+ constructor(_ids?: string[], _isSonos?: boolean, _isAc?: boolean);
8
8
  get ids(): string[];
9
9
  getDevices(): Array<IBaseDevice | OwnSonosDevice | AcDevice>;
10
10
  }
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceList = void 0;
4
4
  const services_1 = require("../services");
5
5
  class DeviceList {
6
- constructor(_ids = [], _isSonos = false, _isDaikin = false) {
6
+ constructor(_ids = [], _isSonos = false, _isAc = false) {
7
7
  this._ids = _ids;
8
8
  this._isSonos = _isSonos;
9
- this._isDaikin = _isDaikin;
9
+ this._isAc = _isAc;
10
10
  // Empty
11
11
  }
12
12
  get ids() {
@@ -21,10 +21,10 @@ class DeviceList {
21
21
  result.push(services_1.OwnSonosDevices.ownDevices[dID]);
22
22
  }
23
23
  }
24
- else if (this._isDaikin) {
25
- const daikinDevice = services_1.OwnDaikinDevices.ownDevices[dID];
26
- if (daikinDevice !== undefined) {
27
- result.push(services_1.OwnDaikinDevices.ownDevices[dID]);
24
+ else if (this._isAc) {
25
+ const acDevice = services_1.OwnAcDevices.ownDevices[dID];
26
+ if (acDevice !== undefined) {
27
+ result.push(services_1.OwnAcDevices.ownDevices[dID]);
28
28
  }
29
29
  }
30
30
  else {
@@ -84,7 +84,7 @@ class FensterGroup extends base_group_1.BaseGroup {
84
84
  }
85
85
  let desiredPos = f.desiredPosition;
86
86
  if (desiredPos > 0) {
87
- services_1.WeatherService.weatherRolloPosition(desiredPos, (_b = (_a = room.HeatGroup) === null || _a === void 0 ? void 0 : _a.desiredTemp) !== null && _b !== void 0 ? _b : -99, (_d = (_c = room.HeatGroup) === null || _c === void 0 ? void 0 : _c.currentTemp) !== null && _d !== void 0 ? _d : -99);
87
+ services_1.WeatherService.weatherRolloPosition(desiredPos, (_b = (_a = room.HeatGroup) === null || _a === void 0 ? void 0 : _a.desiredTemp) !== null && _b !== void 0 ? _b : -99, (_d = (_c = room.HeatGroup) === null || _c === void 0 ? void 0 : _c.temperature) !== null && _d !== void 0 ? _d : -99);
88
88
  }
89
89
  if (f.griffeInPosition(models_2.FensterPosition.offen) > 0 && desiredPos < 100) {
90
90
  return;
@@ -1,12 +1,30 @@
1
1
  import { BaseGroup } from './base-group';
2
2
  import { iHeater, iHumiditySensor, iTemperaturSensor } from '../baseDeviceInterfaces';
3
+ import { AcDevice } from '../../services';
3
4
  export declare class HeatGroup extends BaseGroup {
4
- constructor(roomName: string, heaterIds: string[], tempSensorIds: string[], humiditySensorIds: string[]);
5
- get currentTemp(): number;
5
+ constructor(roomName: string, heaterIds: string[], tempSensorIds: string[], humiditySensorIds: string[], acIds: string[]);
6
+ /**
7
+ * The current measured temperature of the room in Celsius
8
+ * @returns {number}
9
+ */
10
+ get humidity(): number;
11
+ /**
12
+ * The current measured temperature of the room in Celsius
13
+ * @returns {number}
14
+ */
15
+ get temperature(): number;
6
16
  get desiredTemp(): number;
17
+ static getInfo(): string;
7
18
  getHeater(): iHeater[];
8
19
  getTempSensors(): iTemperaturSensor[];
9
20
  getHumiditySensors(): iHumiditySensor[];
21
+ getOwnAcDevices(): AcDevice[];
10
22
  initialize(): void;
23
+ /**
24
+ * Sets all ACs to new desired Value
25
+ * @param {boolean} newDesiredState
26
+ * @param {boolean} force Whether this was a manual trigger, thus blocking automatic changes for 1 hour
27
+ */
28
+ setAc(newDesiredState: boolean, force?: boolean): void;
11
29
  private recalcRoomTemperatur;
12
30
  }
@@ -6,51 +6,42 @@ const group_type_1 = require("./group-type");
6
6
  const device_cluster_type_1 = require("../device-cluster-type");
7
7
  const device_list_1 = require("../device-list");
8
8
  const baseDeviceInterfaces_1 = require("../baseDeviceInterfaces");
9
+ const services_1 = require("../../services");
10
+ const models_1 = require("../../../models");
9
11
  class HeatGroup extends base_group_1.BaseGroup {
10
- constructor(roomName, heaterIds, tempSensorIds, humiditySensorIds) {
12
+ constructor(roomName, heaterIds, tempSensorIds, humiditySensorIds, acIds) {
11
13
  super(roomName, group_type_1.GroupType.Heating);
12
14
  this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.Heater, new device_list_1.DeviceList(heaterIds));
13
15
  this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.TemperaturSensor, new device_list_1.DeviceList(tempSensorIds));
14
16
  this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.HumiditySensor, new device_list_1.DeviceList(humiditySensorIds));
17
+ this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.Ac, new device_list_1.DeviceList(acIds, false, true));
15
18
  }
16
- get currentTemp() {
17
- if (this.getHeater().length === 0) {
18
- return -99;
19
- }
20
- let value = 0;
21
- const sensors = this.getTempSensors();
22
- for (const h of sensors) {
23
- value += h.iTemperatur;
24
- }
25
- return Math.round((value / sensors.length) * 10) / 10;
26
- }
27
- get desiredTemp() {
28
- if (this.getHeater().length === 0) {
29
- return -99;
30
- }
31
- let value = 0;
32
- for (const h of this.getHeater()) {
33
- value += h.desiredTemperatur;
34
- }
35
- return Math.round((value / this.getHeater().length) * 10) / 10;
36
- }
37
- getHeater() {
38
- return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.Heater);
39
- }
40
- getTempSensors() {
41
- return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.TemperaturSensor);
42
- }
43
- getHumiditySensors() {
44
- return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.HumiditySensor);
45
- }
46
- initialize() {
47
- this.getTempSensors().forEach((sensor) => {
48
- sensor.addTempChangeCallback((_newVal) => {
49
- this.recalcRoomTemperatur();
50
- });
19
+ /**
20
+ * The current measured temperature of the room in Celsius
21
+ * @returns {number}
22
+ */
23
+ get humidity() {
24
+ let humidity = baseDeviceInterfaces_1.UNDEFINED_HUMIDITY_VALUE;
25
+ let count = 0;
26
+ this.getHumiditySensors().forEach((sensor) => {
27
+ const sensorValue = sensor.humidity;
28
+ if (sensorValue === baseDeviceInterfaces_1.UNDEFINED_HUMIDITY_VALUE) {
29
+ return;
30
+ }
31
+ if (count === 0) {
32
+ count = 1;
33
+ humidity = sensorValue;
34
+ return;
35
+ }
36
+ humidity = (humidity * count + sensorValue) / ++count;
51
37
  });
38
+ return humidity;
52
39
  }
53
- recalcRoomTemperatur() {
40
+ /**
41
+ * The current measured temperature of the room in Celsius
42
+ * @returns {number}
43
+ */
44
+ get temperature() {
54
45
  let temp = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
55
46
  let count = 0;
56
47
  this.getTempSensors().forEach((sensor) => {
@@ -80,7 +71,78 @@ class HeatGroup extends base_group_1.BaseGroup {
80
71
  }
81
72
  temp = (temp * count + sensorValue) / ++count;
82
73
  });
83
- if (temp === baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE) {
74
+ return temp;
75
+ }
76
+ get desiredTemp() {
77
+ if (this.getHeater().length === 0) {
78
+ return -99;
79
+ }
80
+ let value = 0;
81
+ for (const h of this.getHeater()) {
82
+ value += h.desiredTemperatur;
83
+ }
84
+ return Math.round((value / this.getHeater().length) * 10) / 10;
85
+ }
86
+ static getInfo() {
87
+ var _a, _b, _c;
88
+ const rooms = Array.from(services_1.API.getRooms().values()).filter((r) => {
89
+ return r.HeatGroup !== undefined;
90
+ });
91
+ rooms.sort((a, b) => {
92
+ return a.roomName.localeCompare(b.roomName);
93
+ });
94
+ const response = [`Dies sind die aktuellen Informationen der Heizungen:`];
95
+ response.push(`Name\t\tLuft Feuchtigkeit\t\tAktuelle Temperatur\t\tSoll Temperatur\t\tVentilstellung`);
96
+ for (const r of rooms) {
97
+ response.push(`${r.roomName}:\t\t${(_a = r.HeatGroup) === null || _a === void 0 ? void 0 : _a.humidity}%\t\t${(_b = r.HeatGroup) === null || _b === void 0 ? void 0 : _b.temperature}\t\t${(_c = r.HeatGroup) === null || _c === void 0 ? void 0 : _c.desiredTemp}°C`);
98
+ }
99
+ return response.join('\n');
100
+ }
101
+ getHeater() {
102
+ return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.Heater);
103
+ }
104
+ getTempSensors() {
105
+ return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.TemperaturSensor);
106
+ }
107
+ getHumiditySensors() {
108
+ return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.HumiditySensor);
109
+ }
110
+ getOwnAcDevices() {
111
+ return this.deviceCluster.getDevicesByType(device_cluster_type_1.DeviceClusterType.Ac);
112
+ }
113
+ initialize() {
114
+ this.getTempSensors().forEach((sensor) => {
115
+ sensor.addTempChangeCallback((_newVal) => {
116
+ this.recalcRoomTemperatur();
117
+ });
118
+ });
119
+ this.getOwnAcDevices().forEach((acDev) => {
120
+ acDev.room = this.getRoom();
121
+ });
122
+ }
123
+ /**
124
+ * Sets all ACs to new desired Value
125
+ * @param {boolean} newDesiredState
126
+ * @param {boolean} force Whether this was a manual trigger, thus blocking automatic changes for 1 hour
127
+ */
128
+ setAc(newDesiredState, force = false) {
129
+ const devs = this.getOwnAcDevices();
130
+ this.log(models_1.LogLevel.Debug, `set ${devs.length} Ac's to new State: ${newDesiredState}`);
131
+ for (const dev of devs) {
132
+ if (newDesiredState) {
133
+ dev.turnOn();
134
+ continue;
135
+ }
136
+ if (force) {
137
+ dev.deactivateAutomaticTurnOn(60 * 60 * 1000);
138
+ continue;
139
+ }
140
+ dev.turnOff();
141
+ }
142
+ }
143
+ recalcRoomTemperatur() {
144
+ const temp = this.temperature;
145
+ if (temp == baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE) {
84
146
  return;
85
147
  }
86
148
  this.getHeater().forEach((heater) => {
@@ -1,4 +1,3 @@
1
- export * from './acGroup';
2
1
  export * from './base-group';
3
2
  export * from './Fenster';
4
3
  export * from './fensterGroup';
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./acGroup"), exports);
18
17
  __exportStar(require("./base-group"), exports);
19
18
  __exportStar(require("./Fenster"), exports);
20
19
  __exportStar(require("./fensterGroup"), exports);
@@ -54,13 +54,13 @@ class TasterGroup extends base_group_1.BaseGroup {
54
54
  }
55
55
  }
56
56
  if (((_j = services_1.SettingsService.settings.daikin) === null || _j === void 0 ? void 0 : _j.buttonBotRightForAc) === true) {
57
- const acGroup = this.getRoom().AcGroup;
58
- if (acGroup !== undefined && acGroup.getOwnAcDevices().length > 0) {
57
+ const heatGroup = this.getRoom().HeatGroup;
58
+ if (heatGroup !== undefined && heatGroup.getOwnAcDevices().length > 0) {
59
59
  (_k = t.buttonBotRight) === null || _k === void 0 ? void 0 : _k.addCb(button_1.ButtonPressType.short, (pValue) => {
60
- pValue && acGroup.setAc(true);
60
+ pValue && heatGroup.setAc(true);
61
61
  });
62
62
  (_l = t.buttonBotRight) === null || _l === void 0 ? void 0 : _l.addCb(button_1.ButtonPressType.long, (pValue) => {
63
- pValue && acGroup.setAc(false, true);
63
+ pValue && heatGroup.setAc(false, true);
64
64
  });
65
65
  }
66
66
  }
@@ -75,7 +75,7 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
75
75
  const heatgroup = (_a = this._fenster) === null || _a === void 0 ? void 0 : _a.getRoom().HeatGroup;
76
76
  if (heatgroup !== undefined) {
77
77
  const desiredTemp = heatgroup.desiredTemp;
78
- const currentTemp = heatgroup.currentTemp;
78
+ const currentTemp = heatgroup.temperature;
79
79
  const outSideTemp = services_1.WeatherService.getCurrentTemp();
80
80
  // Check if any of these values are unavailable
81
81
  if (desiredTemp > -99 && currentTemp > -99 && outSideTemp > -99) {
@@ -19,7 +19,7 @@ class HmIpHeizgruppe extends hmIpDevice_1.HmIPDevice {
19
19
  this._temperaturCallbacks = [];
20
20
  this._seasonTurnOff = false;
21
21
  this._temperatur = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
22
- this._humidity = 0;
22
+ this._humidity = baseDeviceInterfaces_1.UNDEFINED_HUMIDITY_VALUE;
23
23
  this._desiredTemperatur = 0;
24
24
  this._roomTemperatur = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
25
25
  this._setPointTemperaturID = `${this.info.fullID}.1.SET_POINT_TEMPERATURE`;
@@ -9,7 +9,7 @@ class ZigbeeSonoffTemp extends BaseDevices_1.ZigbeeDevice {
9
9
  super(pInfo, deviceType_1.DeviceType.ZigbeeSonoffTemp);
10
10
  this._humidityCallbacks = [];
11
11
  this._temperaturCallbacks = [];
12
- this._humidity = -99;
12
+ this._humidity = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
13
13
  this._temperatur = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
14
14
  }
15
15
  get humidity() {
@@ -69,7 +69,7 @@ class TelegramCommands {
69
69
  telegram_service_1.TelegramService.addMessageCallback(new telegramMessageCalback_1.TelegramMessageCallback('HeizungCheck', /\/check_temperatur/, async (m) => {
70
70
  if (m.from === undefined)
71
71
  return false;
72
- telegram_service_1.TelegramService.sendMessage([m.chat.id], devices_1.Heizgruppen.getInfo());
72
+ telegram_service_1.TelegramService.sendMessage([m.chat.id], devices_1.HeatGroup.getInfo());
73
73
  return true;
74
74
  }, 'Gibt die Namen und aktuellen Werte sämtlicher Heizgruppen aus (aktuelle Temperatur, Soll Temperatur, Ventilstellung).'));
75
75
  telegram_service_1.TelegramService.addMessageCallback(new telegramMessageCalback_1.TelegramMessageCallback('HeizungError', /\/temperatur_error/, async (m) => {
@@ -1,20 +1,23 @@
1
1
  import { iExcessEnergyConsumer } from '../../devices';
2
- import { ExcessEnergyConsumerSettings, LogLevel } from '../../../models';
2
+ import { ExcessEnergyConsumerSettings, LogLevel, RoomBase } from '../../../models';
3
3
  import { AcMode } from './ac-mode';
4
4
  import { AcSettings } from '../../../models/deviceSettings/acSettings';
5
+ import { AcDeviceType } from './acDeviceType';
5
6
  export declare abstract class AcDevice implements iExcessEnergyConsumer {
6
7
  name: string;
7
8
  roomName: string;
8
9
  ip: string;
10
+ acDeviceType: AcDeviceType;
9
11
  currentConsumption: number;
10
12
  energyConsumerSettings: ExcessEnergyConsumerSettings;
11
13
  acSettings: AcSettings;
14
+ room: RoomBase | undefined;
12
15
  protected _activatedByExcessEnergy: boolean;
13
16
  protected _blockAutomaticTurnOnMS: number;
14
- private turnOffTimeout;
15
- protected constructor(name: string, roomName: string, ip: string);
17
+ protected constructor(name: string, roomName: string, ip: string, acDeviceType: AcDeviceType);
16
18
  abstract get on(): boolean;
17
19
  isAvailableForExcessEnergy(): boolean;
20
+ calculateDesiredMode(): AcMode;
18
21
  /**
19
22
  * Disable automatic Turn-On for given amount of ms and turn off immediately.
20
23
  * @param {number} timeout
@@ -27,4 +30,5 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer {
27
30
  turnOffDueToMissingEnergy(): void;
28
31
  log(level: LogLevel, message: string): void;
29
32
  wasActivatedByExcessEnergy(): boolean;
33
+ private automaticCheck;
30
34
  }
@@ -4,18 +4,20 @@ exports.AcDevice = void 0;
4
4
  const models_1 = require("../../../models");
5
5
  const utils_1 = require("../utils");
6
6
  const log_service_1 = require("../log-service");
7
+ const ac_mode_1 = require("./ac-mode");
7
8
  const acSettings_1 = require("../../../models/deviceSettings/acSettings");
8
9
  class AcDevice {
9
- constructor(name, roomName, ip) {
10
+ constructor(name, roomName, ip, acDeviceType) {
10
11
  this.name = name;
11
12
  this.roomName = roomName;
12
13
  this.ip = ip;
14
+ this.acDeviceType = acDeviceType;
13
15
  this.currentConsumption = -1;
14
16
  this.energyConsumerSettings = new models_1.ExcessEnergyConsumerSettings();
15
17
  this.acSettings = new acSettings_1.AcSettings();
16
18
  this._activatedByExcessEnergy = false;
17
19
  this._blockAutomaticTurnOnMS = -1;
18
- this.turnOffTimeout = null;
20
+ utils_1.Utils.guardedInterval(this.automaticCheck, 60000, this, true);
19
21
  }
20
22
  isAvailableForExcessEnergy() {
21
23
  if (utils_1.Utils.nowMS() < this._blockAutomaticTurnOnMS) {
@@ -24,7 +26,25 @@ class AcDevice {
24
26
  const minimumStart = utils_1.Utils.dateByTimeSpan(this.acSettings.minimumHours, this.acSettings.minimumMinutes);
25
27
  const maximumEnd = utils_1.Utils.dateByTimeSpan(this.acSettings.maximumHours, this.acSettings.maximumMinutes);
26
28
  const now = new Date();
27
- return !(now < minimumStart || now > maximumEnd);
29
+ if (now < minimumStart || now > maximumEnd) {
30
+ return false;
31
+ }
32
+ return this.calculateDesiredMode() !== ac_mode_1.AcMode.Off;
33
+ }
34
+ calculateDesiredMode() {
35
+ var _a, _b;
36
+ const temp = (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.HeatGroup) === null || _b === void 0 ? void 0 : _b.temperature;
37
+ if (temp === undefined) {
38
+ this.log(models_1.LogLevel.Warn, `Can't calculate AC Mode as we have no room temperature`);
39
+ return ac_mode_1.AcMode.Off;
40
+ }
41
+ if (temp > this.acSettings.stopCoolingTemperatur) {
42
+ return ac_mode_1.AcMode.Cooling;
43
+ }
44
+ if (temp < this.acSettings.stopHeatingTemperatur && this.acSettings.heatingAllowed) {
45
+ return ac_mode_1.AcMode.Heating;
46
+ }
47
+ return ac_mode_1.AcMode.Off;
28
48
  }
29
49
  /**
30
50
  * Disable automatic Turn-On for given amount of ms and turn off immediately.
@@ -39,14 +59,8 @@ class AcDevice {
39
59
  return;
40
60
  }
41
61
  this._activatedByExcessEnergy = true;
62
+ this.setDesiredMode(this.calculateDesiredMode(), false);
42
63
  this.turnOn();
43
- if (this.acSettings.maximumHours < 24 && this.turnOffTimeout === null) {
44
- this.turnOffTimeout = utils_1.Utils.guardedTimeout(() => {
45
- if (this._activatedByExcessEnergy) {
46
- this.turnOff();
47
- }
48
- }, Math.min(utils_1.Utils.dateByTimeSpan(this.acSettings.maximumHours, this.acSettings.maximumMinutes).getTime() - utils_1.Utils.nowMS(), 1000), this);
49
- }
50
64
  }
51
65
  turnOffDueToMissingEnergy() {
52
66
  this.turnOff();
@@ -57,5 +71,17 @@ class AcDevice {
57
71
  wasActivatedByExcessEnergy() {
58
72
  return this._activatedByExcessEnergy;
59
73
  }
74
+ automaticCheck() {
75
+ if (!this.on) {
76
+ return;
77
+ }
78
+ const desiredMode = this.calculateDesiredMode();
79
+ const maximumEnd = utils_1.Utils.dateByTimeSpan(this.acSettings.maximumHours, this.acSettings.maximumMinutes);
80
+ const now = new Date();
81
+ if (now > maximumEnd || (this._activatedByExcessEnergy && desiredMode == ac_mode_1.AcMode.Off)) {
82
+ this.turnOff();
83
+ return;
84
+ }
85
+ }
60
86
  }
61
87
  exports.AcDevice = AcDevice;
@@ -1,5 +1,6 @@
1
1
  export declare enum AcMode {
2
- Auto = 0,
3
- Cooling = 1,
4
- Heating = 2
2
+ Off = 0,
3
+ Auto = 1,
4
+ Cooling = 2,
5
+ Heating = 3
5
6
  }
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AcMode = void 0;
4
4
  var AcMode;
5
5
  (function (AcMode) {
6
- AcMode[AcMode["Auto"] = 0] = "Auto";
7
- AcMode[AcMode["Cooling"] = 1] = "Cooling";
8
- AcMode[AcMode["Heating"] = 2] = "Heating";
6
+ AcMode[AcMode["Off"] = 0] = "Off";
7
+ AcMode[AcMode["Auto"] = 1] = "Auto";
8
+ AcMode[AcMode["Cooling"] = 2] = "Cooling";
9
+ AcMode[AcMode["Heating"] = 3] = "Heating";
9
10
  })(AcMode = exports.AcMode || (exports.AcMode = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum AcDeviceType {
2
+ Unknown = 0,
3
+ Daikin = 1
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AcDeviceType = void 0;
4
+ var AcDeviceType;
5
+ (function (AcDeviceType) {
6
+ AcDeviceType[AcDeviceType["Unknown"] = 0] = "Unknown";
7
+ AcDeviceType[AcDeviceType["Daikin"] = 1] = "Daikin";
8
+ })(AcDeviceType = exports.AcDeviceType || (exports.AcDeviceType = {}));
@@ -1,5 +1,5 @@
1
1
  import { DaikinAC, DaikinManager } from 'daikin-controller';
2
- import { OwnDaikinDevice } from './own-daikin-device';
2
+ import { AcDevice } from './ac-device';
3
3
  export declare class DaikinService {
4
4
  private static _ownDevices;
5
5
  private static _daikinManager;
@@ -7,7 +7,7 @@ export declare class DaikinService {
7
7
  private static _isInitialized;
8
8
  static get isInitialized(): boolean;
9
9
  static addOwnDevices(daikinDevices: {
10
- [name: string]: OwnDaikinDevice;
10
+ [name: string]: AcDevice;
11
11
  }): void;
12
12
  static getDevice(name: string): DaikinAC | undefined;
13
13
  static initialize(): Promise<void>;
@@ -9,6 +9,7 @@ const settings_service_1 = require("../settings-service");
9
9
  const devices_1 = require("../../devices");
10
10
  const network_1 = require("../network");
11
11
  const utils_1 = require("../utils");
12
+ const acDeviceType_1 = require("./acDeviceType");
12
13
  class DaikinService {
13
14
  static get daikinManager() {
14
15
  return this._daikinManager;
@@ -17,7 +18,14 @@ class DaikinService {
17
18
  return this._isInitialized;
18
19
  }
19
20
  static addOwnDevices(daikinDevices) {
20
- this._ownDevices = daikinDevices;
21
+ const toAdd = {};
22
+ for (const name in daikinDevices) {
23
+ const d = daikinDevices[name];
24
+ if (d.acDeviceType == acDeviceType_1.AcDeviceType.Daikin) {
25
+ toAdd[name] = d;
26
+ }
27
+ }
28
+ this._ownDevices = toAdd;
21
29
  }
22
30
  static getDevice(name) {
23
31
  return this.daikinManager.devices[name];