hoffmation-base 1.3.0 → 1.3.2

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,7 @@
1
1
  import { iBaseDevice } from '../../server';
2
+ import { ExcessEnergyConsumerSettings } from '../excessEnergyConsumerSettings';
2
3
  export declare abstract class DeviceSettings {
4
+ energyConsumerSettings: ExcessEnergyConsumerSettings | undefined;
3
5
  persist(device: iBaseDevice): void;
4
6
  initializeFromDb(device: iBaseDevice): void;
5
7
  fromPartialObject(_obj: Partial<DeviceSettings>): void;
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceSettings = void 0;
4
4
  const server_1 = require("../../server");
5
5
  const logLevel_1 = require("../logLevel");
6
+ const excessEnergyConsumerSettings_1 = require("../excessEnergyConsumerSettings");
6
7
  class DeviceSettings {
8
+ constructor() {
9
+ this.energyConsumerSettings = undefined;
10
+ }
7
11
  persist(device) {
8
12
  var _a;
9
13
  (_a = server_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistDeviceSettings(device, JSON.stringify(this));
@@ -32,7 +36,12 @@ class DeviceSettings {
32
36
  });
33
37
  }
34
38
  fromPartialObject(_obj) {
35
- // Nothing
39
+ if (_obj.energyConsumerSettings) {
40
+ if (this.energyConsumerSettings === undefined) {
41
+ this.energyConsumerSettings = new excessEnergyConsumerSettings_1.ExcessEnergyConsumerSettings();
42
+ }
43
+ this.energyConsumerSettings.fromPartialObject(_obj.energyConsumerSettings);
44
+ }
36
45
  }
37
46
  toJSON() {
38
47
  return server_1.Utils.jsonFilter(this);
@@ -5,7 +5,8 @@ const deviceSettings_1 = require("./deviceSettings");
5
5
  const server_1 = require("../../server");
6
6
  class SceneSettings extends deviceSettings_1.DeviceSettings {
7
7
  fromPartialObject(data) {
8
- this.defaultTurnOffTimeout = data.defaultTurnOffTimeout;
8
+ var _a;
9
+ this.defaultTurnOffTimeout = (_a = data.defaultTurnOffTimeout) !== null && _a !== void 0 ? _a : this.defaultTurnOffTimeout;
9
10
  super.fromPartialObject(data);
10
11
  }
11
12
  toJSON() {
@@ -14,4 +14,5 @@ export declare class ExcessEnergyConsumerSettings {
14
14
  * Devices with same prio try to share as good as possible.
15
15
  */
16
16
  priority?: number, rampUpOnSpareEnergy?: boolean, powerReactionTime?: number);
17
+ fromPartialObject(obj: Partial<ExcessEnergyConsumerSettings>): void;
17
18
  }
@@ -15,5 +15,11 @@ class ExcessEnergyConsumerSettings {
15
15
  this.rampUpOnSpareEnergy = rampUpOnSpareEnergy;
16
16
  this.powerReactionTime = powerReactionTime;
17
17
  }
18
+ fromPartialObject(obj) {
19
+ var _a, _b, _c;
20
+ this.priority = (_a = obj.priority) !== null && _a !== void 0 ? _a : this.priority;
21
+ this.rampUpOnSpareEnergy = (_b = obj.rampUpOnSpareEnergy) !== null && _b !== void 0 ? _b : this.rampUpOnSpareEnergy;
22
+ this.powerReactionTime = (_c = obj.powerReactionTime) !== null && _c !== void 0 ? _c : this.powerReactionTime;
23
+ }
18
24
  }
19
25
  exports.ExcessEnergyConsumerSettings = ExcessEnergyConsumerSettings;
@@ -18,6 +18,7 @@ export declare enum DeviceCapability {
18
18
  batteryDriven = 16,
19
19
  tv = 17,
20
20
  ledLamp = 18,
21
+ smokeSensor = 19,
21
22
  bluetoothDetector = 101,
22
23
  trackableDevice = 102,
23
24
  scene = 103
@@ -22,6 +22,7 @@ var DeviceCapability;
22
22
  DeviceCapability[DeviceCapability["batteryDriven"] = 16] = "batteryDriven";
23
23
  DeviceCapability[DeviceCapability["tv"] = 17] = "tv";
24
24
  DeviceCapability[DeviceCapability["ledLamp"] = 18] = "ledLamp";
25
+ DeviceCapability[DeviceCapability["smokeSensor"] = 19] = "smokeSensor";
25
26
  DeviceCapability[DeviceCapability["bluetoothDetector"] = 101] = "bluetoothDetector";
26
27
  DeviceCapability[DeviceCapability["trackableDevice"] = 102] = "trackableDevice";
27
28
  DeviceCapability[DeviceCapability["scene"] = 103] = "scene";
@@ -1,6 +1,7 @@
1
1
  import { ExcessEnergyConsumerSettings, LogLevel } from '../../../models';
2
- export interface iExcessEnergyConsumer {
3
- energyConsumerSettings: ExcessEnergyConsumerSettings;
2
+ import { iBaseDevice } from './iBaseDevice';
3
+ export interface iExcessEnergyConsumer extends iBaseDevice {
4
+ readonly energySettings: ExcessEnergyConsumerSettings;
4
5
  currentConsumption: number;
5
6
  on: boolean;
6
7
  isAvailableForExcessEnergy(): boolean;
@@ -0,0 +1,5 @@
1
+ import { iRoomDevice } from './iRoomDevice';
2
+ export interface iSmokeDetectorDevice extends iRoomDevice {
3
+ readonly smoke: boolean;
4
+ stopAlarm(quiet: boolean): void;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -14,6 +14,7 @@ export * from './iMotionSensor';
14
14
  export * from './iRoomDevice';
15
15
  export * from './iScene';
16
16
  export * from './iShutter';
17
+ export * from './iSmokeDetectorDevice';
17
18
  export * from './iSpeaker';
18
19
  export * from './iTemperatureSensor';
19
20
  export * from './iTvDevice';
@@ -30,6 +30,7 @@ __exportStar(require("./iMotionSensor"), exports);
30
30
  __exportStar(require("./iRoomDevice"), exports);
31
31
  __exportStar(require("./iScene"), exports);
32
32
  __exportStar(require("./iShutter"), exports);
33
+ __exportStar(require("./iSmokeDetectorDevice"), exports);
33
34
  __exportStar(require("./iSpeaker"), exports);
34
35
  __exportStar(require("./iTemperatureSensor"), exports);
35
36
  __exportStar(require("./iTvDevice"), exports);
@@ -1,7 +1,7 @@
1
- import { ZigbeeHeimanSmoke } from '../zigbee';
2
1
  import { BaseGroup } from './base-group';
2
+ import { iSmokeDetectorDevice } from '../baseDeviceInterfaces';
3
3
  export declare class SmokeGroup extends BaseGroup {
4
4
  constructor(roomName: string, smokeDetectorIds: string[]);
5
- getSmokeDetectors(): ZigbeeHeimanSmoke[];
5
+ getSmokeDetectors(): iSmokeDetectorDevice[];
6
6
  stopAlarm(): void;
7
7
  }
@@ -172,7 +172,7 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
172
172
  var _a;
173
173
  const potentialDevices = this._excessEnergyConsumer.filter((e) => {
174
174
  var _a;
175
- if (e.energyConsumerSettings.priority === -1 || e.on || !e.isAvailableForExcessEnergy()) {
175
+ if (e.energySettings.priority === -1 || e.on || !e.isAvailableForExcessEnergy()) {
176
176
  return false;
177
177
  }
178
178
  if (((_a = this._lastDeviceChange) === null || _a === void 0 ? void 0 : _a.newState) && e === this._lastDeviceChange.device) {
@@ -188,9 +188,9 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
188
188
  return;
189
189
  }
190
190
  potentialDevices.sort((a, b) => {
191
- return b.energyConsumerSettings.priority - a.energyConsumerSettings.priority;
191
+ return b.energySettings.priority - a.energySettings.priority;
192
192
  });
193
- this.blockDeviceChangeTime = services_1.Utils.nowMS() + potentialDevices[0].energyConsumerSettings.powerReactionTime;
193
+ this.blockDeviceChangeTime = services_1.Utils.nowMS() + potentialDevices[0].energySettings.powerReactionTime;
194
194
  potentialDevices[0].log(models_1.LogLevel.Info, `Turning on, as we have ${this.excessEnergy}W to spare...`);
195
195
  potentialDevices[0].turnOnForExcessEnergy();
196
196
  this._lastDeviceChange = { newState: true, device: potentialDevices[0] };
@@ -199,7 +199,7 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
199
199
  var _a;
200
200
  const potentialDevices = this._excessEnergyConsumer.filter((e) => {
201
201
  var _a;
202
- if (e.energyConsumerSettings.priority === -1 || !e.on) {
202
+ if (e.energySettings.priority === -1 || !e.on) {
203
203
  return false;
204
204
  }
205
205
  if (!e.wasActivatedByExcessEnergy()) {
@@ -219,10 +219,10 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
219
219
  return;
220
220
  }
221
221
  potentialDevices.sort((a, b) => {
222
- return a.energyConsumerSettings.priority - b.energyConsumerSettings.priority;
222
+ return a.energySettings.priority - b.energySettings.priority;
223
223
  });
224
224
  potentialDevices[0].log(models_1.LogLevel.Info, `Turning off, as we don't have energy to spare...`);
225
- this.blockDeviceChangeTime = services_1.Utils.nowMS() + potentialDevices[0].energyConsumerSettings.powerReactionTime;
225
+ this.blockDeviceChangeTime = services_1.Utils.nowMS() + potentialDevices[0].energySettings.powerReactionTime;
226
226
  potentialDevices[0].turnOffDueToMissingEnergy();
227
227
  this._lastDeviceChange = { newState: false, device: potentialDevices[0] };
228
228
  }
@@ -13,10 +13,10 @@ export declare class ZigbeeBlitzShp extends ZigbeeActuator implements iExcessEne
13
13
  private _loadPower;
14
14
  get loadPower(): number;
15
15
  settings: ActuatorSettings;
16
- energyConsumerSettings: ExcessEnergyConsumerSettings;
17
16
  private readonly _availableForExcessEnergy;
18
17
  private _activatedByExcessEnergy;
19
18
  constructor(pInfo: IoBrokerDeviceInfo);
19
+ get energySettings(): ExcessEnergyConsumerSettings;
20
20
  get currentConsumption(): number;
21
21
  get on(): boolean;
22
22
  isAvailableForExcessEnergy(): boolean;
@@ -13,9 +13,9 @@ class ZigbeeBlitzShp extends BaseDevices_1.ZigbeeActuator {
13
13
  this._energy = 0;
14
14
  this._loadPower = 0;
15
15
  this.settings = new models_1.ActuatorSettings();
16
- this.energyConsumerSettings = new models_1.ExcessEnergyConsumerSettings();
17
16
  this._availableForExcessEnergy = true;
18
17
  this._activatedByExcessEnergy = false;
18
+ this.settings.energyConsumerSettings = new models_1.ExcessEnergyConsumerSettings();
19
19
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.excessEnergyConsumer);
20
20
  }
21
21
  get steckerOn() {
@@ -30,6 +30,10 @@ class ZigbeeBlitzShp extends BaseDevices_1.ZigbeeActuator {
30
30
  get loadPower() {
31
31
  return this._loadPower;
32
32
  }
33
+ get energySettings() {
34
+ var _a;
35
+ return (_a = this.settings.energyConsumerSettings) !== null && _a !== void 0 ? _a : new models_1.ExcessEnergyConsumerSettings();
36
+ }
33
37
  get currentConsumption() {
34
38
  return this._loadPower;
35
39
  }
@@ -2,18 +2,19 @@
2
2
  /// <reference types="iobroker" />
3
3
  import { ZigbeeDevice } from './BaseDevices';
4
4
  import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
5
- import { iBatteryDevice } from '../baseDeviceInterfaces';
6
- export declare class ZigbeeHeimanSmoke extends ZigbeeDevice implements iBatteryDevice {
5
+ import { iBatteryDevice, iSmokeDetectorDevice } from '../baseDeviceInterfaces';
6
+ export declare class ZigbeeHeimanSmoke extends ZigbeeDevice implements iBatteryDevice, iSmokeDetectorDevice {
7
7
  private _battery;
8
8
  private _lastBatteryPersist;
9
9
  get lastBatteryPersist(): number;
10
10
  get battery(): number;
11
- smoke: boolean;
11
+ constructor(pInfo: IoBrokerDeviceInfo);
12
+ private _smoke;
12
13
  iAlarmTimeout: NodeJS.Timeout | undefined;
13
14
  private _messageAlarmFirst;
14
15
  private _messageAlarm;
15
16
  private _messageAlarmEnd;
16
- constructor(pInfo: IoBrokerDeviceInfo);
17
+ get smoke(): boolean;
17
18
  private _roomName;
18
19
  set roomName(val: string);
19
20
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
@@ -11,13 +11,14 @@ class ZigbeeHeimanSmoke extends BaseDevices_1.ZigbeeDevice {
11
11
  super(pInfo, deviceType_1.DeviceType.ZigbeeHeimanSmoke);
12
12
  this._battery = -99;
13
13
  this._lastBatteryPersist = 0;
14
- this.smoke = false;
14
+ this._smoke = false;
15
15
  this.iAlarmTimeout = undefined;
16
16
  this._messageAlarmFirst = '';
17
17
  this._messageAlarm = '';
18
18
  this._messageAlarmEnd = '';
19
19
  this._roomName = '';
20
20
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
21
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.smokeSensor);
21
22
  this._messageAlarmFirst = services_1.Res.fireAlarmStart(this._roomName, this.info.customName);
22
23
  this._messageAlarm = services_1.Res.fireAlarmRepeat(this._roomName, this.info.customName);
23
24
  this._messageAlarmEnd = services_1.Res.fireAlarmEnd(this._roomName);
@@ -28,6 +29,9 @@ class ZigbeeHeimanSmoke extends BaseDevices_1.ZigbeeDevice {
28
29
  get battery() {
29
30
  return this._battery;
30
31
  }
32
+ get smoke() {
33
+ return this._smoke;
34
+ }
31
35
  set roomName(val) {
32
36
  this._roomName = val;
33
37
  this._messageAlarmFirst = services_1.Res.fireAlarmStart(this._roomName, this.info.customName);
@@ -57,7 +61,7 @@ class ZigbeeHeimanSmoke extends BaseDevices_1.ZigbeeDevice {
57
61
  else if (newVal) {
58
62
  this.startAlarm();
59
63
  }
60
- this.smoke = newVal;
64
+ this._smoke = newVal;
61
65
  break;
62
66
  }
63
67
  }
@@ -8,13 +8,15 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
8
8
  ip: string;
9
9
  acDeviceType: AcDeviceType;
10
10
  currentConsumption: number;
11
- energyConsumerSettings: ExcessEnergyConsumerSettings;
12
11
  settings: AcSettings;
13
12
  room: RoomBase | undefined;
14
13
  deviceCapabilities: DeviceCapability[];
14
+ protected _activatedByExcessEnergy: boolean;
15
+ protected _blockAutomaticChangeMS: number;
15
16
  protected _info: DeviceInfo;
16
17
  get temperature(): number;
17
18
  protected constructor(name: string, roomName: string, ip: string, acDeviceType: AcDeviceType);
19
+ get energySettings(): ExcessEnergyConsumerSettings;
18
20
  private _roomTemperature;
19
21
  get roomTemperature(): number;
20
22
  get info(): DeviceInfo;
@@ -22,14 +24,12 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
22
24
  set info(info: DeviceInfo);
23
25
  abstract get deviceType(): DeviceType;
24
26
  get name(): string;
25
- protected _activatedByExcessEnergy: boolean;
26
- protected _blockAutomaticTurnOnMS: number;
27
27
  get id(): string;
28
28
  abstract get on(): boolean;
29
29
  isAvailableForExcessEnergy(): boolean;
30
30
  calculateDesiredMode(): AcMode;
31
31
  /**
32
- * Disable automatic Turn-On for given amount of ms and turn off immediately.
32
+ * Disable automatic Turn-On and Turn-Off for given amount of ms.
33
33
  * @param {number} timeout
34
34
  */
35
35
  deactivateAutomaticChange(timeout?: number): void;
@@ -40,6 +40,7 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
40
40
  turnOnForExcessEnergy(): void;
41
41
  abstract turnOff(): void;
42
42
  turnOffDueToMissingEnergy(): void;
43
+ setState(mode: AcMode, forceTime?: number): void;
43
44
  log(level: LogLevel, message: string, debugType?: LogDebugType): void;
44
45
  wasActivatedByExcessEnergy(): boolean;
45
46
  loadDeviceSettings(): void;
@@ -18,12 +18,12 @@ class AcDevice {
18
18
  this.ip = ip;
19
19
  this.acDeviceType = acDeviceType;
20
20
  this.currentConsumption = -1;
21
- this.energyConsumerSettings = new models_1.ExcessEnergyConsumerSettings();
22
21
  this.settings = new models_1.AcSettings();
23
22
  this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.ac];
24
- this._roomTemperature = 0;
25
23
  this._activatedByExcessEnergy = false;
26
- this._blockAutomaticTurnOnMS = -1;
24
+ this._blockAutomaticChangeMS = -1;
25
+ this._roomTemperature = 0;
26
+ this.settings.energyConsumerSettings = new models_1.ExcessEnergyConsumerSettings();
27
27
  this._info = new devices_1.DeviceInfo();
28
28
  this._info.fullName = `AC ${name}`;
29
29
  this._info.customName = `${roomName} ${name}`;
@@ -37,6 +37,10 @@ class AcDevice {
37
37
  get temperature() {
38
38
  return this._roomTemperature;
39
39
  }
40
+ get energySettings() {
41
+ var _a;
42
+ return (_a = this.settings.energyConsumerSettings) !== null && _a !== void 0 ? _a : new models_1.ExcessEnergyConsumerSettings();
43
+ }
40
44
  get roomTemperature() {
41
45
  return this._roomTemperature;
42
46
  }
@@ -57,7 +61,7 @@ class AcDevice {
57
61
  return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `ac-${this.info.room}-${this.info.customName}`;
58
62
  }
59
63
  isAvailableForExcessEnergy() {
60
- if (utils_1.Utils.nowMS() < this._blockAutomaticTurnOnMS) {
64
+ if (utils_1.Utils.nowMS() < this._blockAutomaticChangeMS) {
61
65
  return false;
62
66
  }
63
67
  const minimumStart = utils_1.Utils.dateByTimeSpan(this.settings.minimumHours, this.settings.minimumMinutes);
@@ -76,6 +80,14 @@ class AcDevice {
76
80
  return ac_mode_1.AcMode.Off;
77
81
  }
78
82
  const acOn = this.on;
83
+ // Check Turn Off Time
84
+ const maximumEnd = utils_1.Utils.dateByTimeSpan(this.settings.maximumHours, this.settings.maximumMinutes);
85
+ const minimumStart = utils_1.Utils.dateByTimeSpan(this.settings.minimumHours, this.settings.minimumMinutes);
86
+ const now = new Date();
87
+ if (acOn && (now > maximumEnd || now < minimumStart)) {
88
+ this.log(models_1.LogLevel.Info, `We should turn off now, to respect night settings.`);
89
+ return ac_mode_1.AcMode.Off;
90
+ }
79
91
  let threshold = acOn ? 0 : 1;
80
92
  let desiredMode = ac_mode_1.AcMode.Off;
81
93
  const excessEnergy = (_b = (_a = devices_1.Devices.energymanager) === null || _a === void 0 ? void 0 : _a.excessEnergy) !== null && _b !== void 0 ? _b : -1;
@@ -97,11 +109,11 @@ class AcDevice {
97
109
  return desiredMode;
98
110
  }
99
111
  /**
100
- * Disable automatic Turn-On for given amount of ms and turn off immediately.
112
+ * Disable automatic Turn-On and Turn-Off for given amount of ms.
101
113
  * @param {number} timeout
102
114
  */
103
115
  deactivateAutomaticChange(timeout = 60 * 60 * 1000) {
104
- this._blockAutomaticTurnOnMS = utils_1.Utils.nowMS() + timeout;
116
+ this._blockAutomaticChangeMS = utils_1.Utils.nowMS() + timeout;
105
117
  }
106
118
  onTemperaturChange(newTemperatur) {
107
119
  this.roomTemperatur = newTemperatur;
@@ -114,7 +126,7 @@ class AcDevice {
114
126
  (_a = utils_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistAC(this);
115
127
  }
116
128
  turnOnForExcessEnergy() {
117
- if (this._blockAutomaticTurnOnMS > utils_1.Utils.nowMS()) {
129
+ if (this._blockAutomaticChangeMS > utils_1.Utils.nowMS()) {
118
130
  return;
119
131
  }
120
132
  this._activatedByExcessEnergy = true;
@@ -124,6 +136,15 @@ class AcDevice {
124
136
  turnOffDueToMissingEnergy() {
125
137
  this.turnOff();
126
138
  }
139
+ setState(mode, forceTime = 60 * 60 * 1000) {
140
+ this._blockAutomaticChangeMS = utils_1.Utils.nowMS() + forceTime;
141
+ if (mode == ac_mode_1.AcMode.Off) {
142
+ this.turnOff();
143
+ return;
144
+ }
145
+ this.setDesiredMode(mode, false);
146
+ this.turnOn();
147
+ }
127
148
  log(level, message, debugType = log_service_1.LogDebugType.None) {
128
149
  var _a, _b;
129
150
  log_service_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
@@ -147,8 +168,8 @@ class AcDevice {
147
168
  }
148
169
  automaticCheck() {
149
170
  var _a;
150
- if (!this.on && utils_1.Utils.nowMS() < this._blockAutomaticTurnOnMS) {
151
- // We aren't allowed to trun on anyway --> exit
171
+ if (utils_1.Utils.nowMS() < this._blockAutomaticChangeMS) {
172
+ // We aren't allowed to turn on or off anyway --> exit
152
173
  return;
153
174
  }
154
175
  const desiredMode = this.calculateDesiredMode();
@@ -165,13 +186,6 @@ class AcDevice {
165
186
  this.turnOff();
166
187
  return;
167
188
  }
168
- // Check Cooling Turn Off
169
- const maximumEnd = utils_1.Utils.dateByTimeSpan(this.settings.maximumHours, this.settings.maximumMinutes);
170
- const now = new Date();
171
- if (now > maximumEnd) {
172
- this.turnOff();
173
- return;
174
- }
175
189
  }
176
190
  toJSON() {
177
191
  // eslint-disable-next-line
@@ -20,7 +20,6 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
20
20
  this.desiredMode = daikin_controller_1.Mode.COLD;
21
21
  this.deviceType = devices_1.DeviceType.Daikin;
22
22
  this._on = false;
23
- this.energyConsumerSettings.priority = 50;
24
23
  this._device = device;
25
24
  }
26
25
  get device() {
@@ -27,8 +27,9 @@ export declare class API {
27
27
  * @param id The id of the device, if wrong false will be returned
28
28
  * @param {boolean} desiredState
29
29
  * @param {AcMode} desiredMode
30
+ * @param forceTime The time in ms this should not change before automatic change is allowed again
30
31
  */
31
- static setAc(id: string, desiredState: boolean, desiredMode?: AcMode): boolean;
32
+ static setAc(id: string, desiredState: boolean, desiredMode?: AcMode, forceTime?: number): boolean;
32
33
  /**
33
34
  * Turns on/off all AC´s in the home
34
35
  * @param {boolean} desiredState
@@ -64,8 +64,9 @@ class API {
64
64
  * @param id The id of the device, if wrong false will be returned
65
65
  * @param {boolean} desiredState
66
66
  * @param {AcMode} desiredMode
67
+ * @param forceTime The time in ms this should not change before automatic change is allowed again
67
68
  */
68
- static setAc(id, desiredState, desiredMode) {
69
+ static setAc(id, desiredState, desiredMode, forceTime = 60 * 60 * 1000) {
69
70
  const d = this.getAc(id);
70
71
  if (!d) {
71
72
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `AC Device for id ${id} not found`);
@@ -75,14 +76,15 @@ class API {
75
76
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Device for id ${id} is not an ac`);
76
77
  return false;
77
78
  }
78
- if (desiredState) {
79
- d.setDesiredMode((desiredMode !== null && desiredMode !== void 0 ? desiredMode : settings_service_1.SettingsService.heatMode == config_1.HeatingMode.Winter) ? ac_1.AcMode.Heating : ac_1.AcMode.Cooling, false);
80
- d.turnOn();
79
+ if (desiredMode === undefined) {
80
+ if (!desiredState) {
81
+ desiredMode = ac_1.AcMode.Off;
82
+ }
83
+ else {
84
+ desiredMode = settings_service_1.SettingsService.heatMode == config_1.HeatingMode.Winter ? ac_1.AcMode.Heating : ac_1.AcMode.Cooling;
85
+ }
81
86
  }
82
- else {
83
- d.turnOff();
84
- }
85
- d.deactivateAutomaticChange(60 * 60 * 1000);
87
+ d.setState(desiredMode, forceTime);
86
88
  return true;
87
89
  }
88
90
  /**