hoffmation-base 2.9.1 → 2.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server/services/ac/ac-device.d.ts +5 -3
- package/lib/server/services/ac/ac-device.js +13 -7
- package/lib/server/services/ac/own-daikin-device.js +2 -0
- package/lib/server/services/blockAutomaticHandler.d.ts +1 -1
- package/lib/server/services/blockAutomaticHandler.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { DeviceInfo, DeviceType, iAcDevice, iExcessEnergyConsumer, iRoomDevice } from '../../devices';
|
|
1
|
+
import { DeviceInfo, DeviceType, iAcDevice, iExcessEnergyConsumer, iRoomDevice, iTemporaryDisableAutomatic } from '../../devices';
|
|
2
2
|
import { AcSettings, ExcessEnergyConsumerSettings, LogLevel, RoomBase } from '../../../models';
|
|
3
3
|
import { LogDebugType } from '../log-service';
|
|
4
4
|
import { AcMode } from './ac-mode';
|
|
5
5
|
import { AcDeviceType } from './acDeviceType';
|
|
6
6
|
import { DeviceCapability } from '../../devices/DeviceCapability';
|
|
7
|
-
|
|
7
|
+
import { BlockAutomaticHandler } from '../blockAutomaticHandler';
|
|
8
|
+
export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDevice, iAcDevice, iTemporaryDisableAutomatic {
|
|
8
9
|
ip: string;
|
|
9
10
|
acDeviceType: AcDeviceType;
|
|
10
11
|
currentConsumption: number;
|
|
11
12
|
settings: AcSettings;
|
|
12
13
|
room: RoomBase | undefined;
|
|
13
14
|
deviceCapabilities: DeviceCapability[];
|
|
15
|
+
readonly blockAutomationHandler: BlockAutomaticHandler;
|
|
14
16
|
protected _activatedByExcessEnergy: boolean;
|
|
15
|
-
protected _blockAutomaticChangeMS: number;
|
|
16
17
|
protected _info: DeviceInfo;
|
|
17
18
|
get temperature(): number;
|
|
18
19
|
get customName(): string;
|
|
@@ -27,6 +28,7 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
|
|
|
27
28
|
get name(): string;
|
|
28
29
|
get id(): string;
|
|
29
30
|
abstract get on(): boolean;
|
|
31
|
+
restoreTargetAutomaticValue(): void;
|
|
30
32
|
isAvailableForExcessEnergy(): boolean;
|
|
31
33
|
calculateDesiredMode(): AcMode;
|
|
32
34
|
/**
|
|
@@ -13,6 +13,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
13
13
|
const DeviceCapability_1 = require("../../devices/DeviceCapability");
|
|
14
14
|
const settings_service_1 = require("../settings-service");
|
|
15
15
|
const config_1 = require("../../config");
|
|
16
|
+
const blockAutomaticHandler_1 = require("../blockAutomaticHandler");
|
|
16
17
|
class AcDevice {
|
|
17
18
|
get temperature() {
|
|
18
19
|
return this._roomTemperature;
|
|
@@ -25,9 +26,8 @@ class AcDevice {
|
|
|
25
26
|
this.acDeviceType = acDeviceType;
|
|
26
27
|
this.currentConsumption = -1;
|
|
27
28
|
this.settings = new models_1.AcSettings();
|
|
28
|
-
this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.ac];
|
|
29
|
+
this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.ac, DeviceCapability_1.DeviceCapability.blockAutomatic];
|
|
29
30
|
this._activatedByExcessEnergy = false;
|
|
30
|
-
this._blockAutomaticChangeMS = -1;
|
|
31
31
|
this._roomTemperature = 0;
|
|
32
32
|
this._info = new devices_1.DeviceInfo();
|
|
33
33
|
this._info.fullName = `AC ${name}`;
|
|
@@ -38,6 +38,7 @@ class AcDevice {
|
|
|
38
38
|
utils_1.Utils.guardedInterval(this.persist, 15 * 60 * 1000, this, true);
|
|
39
39
|
this.persistDeviceInfo();
|
|
40
40
|
this.loadDeviceSettings();
|
|
41
|
+
this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
|
|
41
42
|
}
|
|
42
43
|
get energySettings() {
|
|
43
44
|
return this.settings.energySettings;
|
|
@@ -61,11 +62,15 @@ class AcDevice {
|
|
|
61
62
|
var _a;
|
|
62
63
|
return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `ac-${this.info.room}-${this.info.customName}`;
|
|
63
64
|
}
|
|
65
|
+
restoreTargetAutomaticValue() {
|
|
66
|
+
this.log(models_1.LogLevel.Debug, `Restore Target Automatic value`);
|
|
67
|
+
this.automaticCheck();
|
|
68
|
+
}
|
|
64
69
|
isAvailableForExcessEnergy() {
|
|
65
70
|
if (this.settings.useOwnTemperatureAndAutomatic) {
|
|
66
71
|
return false;
|
|
67
72
|
}
|
|
68
|
-
if (
|
|
73
|
+
if (this.blockAutomationHandler.automaticBlockActive) {
|
|
69
74
|
return false;
|
|
70
75
|
}
|
|
71
76
|
if (!utils_1.Utils.timeWithinBorders(this.settings.minimumHours, this.settings.minimumMinutes, this.settings.maximumHours, this.settings.maximumMinutes)) {
|
|
@@ -117,7 +122,7 @@ class AcDevice {
|
|
|
117
122
|
* @param {number} timeout
|
|
118
123
|
*/
|
|
119
124
|
deactivateAutomaticChange(timeout = 60 * 60 * 1000) {
|
|
120
|
-
this.
|
|
125
|
+
this.blockAutomationHandler.disableAutomatic(timeout);
|
|
121
126
|
}
|
|
122
127
|
onTemperaturChange(newTemperatur) {
|
|
123
128
|
this.roomTemperatur = newTemperatur;
|
|
@@ -130,7 +135,7 @@ class AcDevice {
|
|
|
130
135
|
(_a = utils_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistAC(this);
|
|
131
136
|
}
|
|
132
137
|
turnOnForExcessEnergy() {
|
|
133
|
-
if (this.
|
|
138
|
+
if (this.blockAutomationHandler.automaticBlockActive) {
|
|
134
139
|
return;
|
|
135
140
|
}
|
|
136
141
|
this._activatedByExcessEnergy = true;
|
|
@@ -141,7 +146,7 @@ class AcDevice {
|
|
|
141
146
|
this.turnOff();
|
|
142
147
|
}
|
|
143
148
|
setState(mode, forceTime = 60 * 60 * 1000) {
|
|
144
|
-
this.
|
|
149
|
+
this.blockAutomationHandler.disableAutomatic(forceTime);
|
|
145
150
|
if (mode == ac_mode_1.AcMode.Off) {
|
|
146
151
|
this.turnOff();
|
|
147
152
|
return;
|
|
@@ -172,7 +177,7 @@ class AcDevice {
|
|
|
172
177
|
}
|
|
173
178
|
automaticCheck() {
|
|
174
179
|
var _a;
|
|
175
|
-
if (
|
|
180
|
+
if (this.blockAutomationHandler.automaticBlockActive) {
|
|
176
181
|
// We aren't allowed to turn on or off anyway --> exit
|
|
177
182
|
return;
|
|
178
183
|
}
|
|
@@ -190,6 +195,7 @@ class AcDevice {
|
|
|
190
195
|
this.turnOff();
|
|
191
196
|
return;
|
|
192
197
|
}
|
|
198
|
+
this.turnOn();
|
|
193
199
|
}
|
|
194
200
|
toJSON() {
|
|
195
201
|
// eslint-disable-next-line
|
|
@@ -63,10 +63,12 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
turnOn() {
|
|
66
|
+
this.log(models_1.LogLevel.Info, `Turning on`);
|
|
66
67
|
this.desiredState = daikin_controller_1.Power.ON;
|
|
67
68
|
this.setDesiredInfo();
|
|
68
69
|
}
|
|
69
70
|
turnOff() {
|
|
71
|
+
this.log(models_1.LogLevel.Info, `Turning off`);
|
|
70
72
|
this._activatedByExcessEnergy = false;
|
|
71
73
|
this.desiredState = daikin_controller_1.Power.OFF;
|
|
72
74
|
this.setDesiredInfo();
|
|
@@ -9,7 +9,7 @@ export declare class BlockAutomaticHandler {
|
|
|
9
9
|
private _restoreAutomaticStateTimeout;
|
|
10
10
|
get restoreAutomaticStateTimeout(): NodeJS.Timeout | null;
|
|
11
11
|
get automaticBlockActive(): boolean;
|
|
12
|
-
disableAutomatic(
|
|
12
|
+
disableAutomatic(durationMS: number, onCollideAction?: CollisionSolving): void;
|
|
13
13
|
disableAutomaticUntil(targetDate: Date, onCollideAction?: CollisionSolving): void;
|
|
14
14
|
liftAutomaticBlock(): void;
|
|
15
15
|
private updateRestoreTimeout;
|
|
@@ -26,8 +26,8 @@ class BlockAutomaticHandler {
|
|
|
26
26
|
get automaticBlockActive() {
|
|
27
27
|
return this._automaticBlockedUntil > new Date();
|
|
28
28
|
}
|
|
29
|
-
disableAutomatic(
|
|
30
|
-
this.disableAutomaticUntil(new Date(utils_1.Utils.nowMS() +
|
|
29
|
+
disableAutomatic(durationMS, onCollideAction = models_1.CollisionSolving.overrideIfGreater) {
|
|
30
|
+
this.disableAutomaticUntil(new Date(utils_1.Utils.nowMS() + durationMS), onCollideAction);
|
|
31
31
|
}
|
|
32
32
|
disableAutomaticUntil(targetDate, onCollideAction = models_1.CollisionSolving.overrideIfGreater) {
|
|
33
33
|
const now = new Date();
|
|
@@ -45,7 +45,7 @@ class BlockAutomaticHandler {
|
|
|
45
45
|
if (this._restoreAutomaticStateTimeout !== null) {
|
|
46
46
|
clearTimeout(this._restoreAutomaticStateTimeout);
|
|
47
47
|
}
|
|
48
|
-
this._restoreAutomaticStateTimeout = utils_1.Utils.guardedTimeout(this._restoreAutomatic, this._automaticBlockedUntil.getTime() - utils_1.Utils.nowMS(), this);
|
|
48
|
+
this._restoreAutomaticStateTimeout = utils_1.Utils.guardedTimeout(this._restoreAutomatic, this._automaticBlockedUntil.getTime() - utils_1.Utils.nowMS() + 500, this);
|
|
49
49
|
}
|
|
50
50
|
toJSON() {
|
|
51
51
|
return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['_restoreAutomatic']));
|