hoffmation-base 3.0.0-alpha.47 → 3.0.0-alpha.49
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/devices/baseDeviceInterfaces/iEnergyManager.d.ts +4 -0
- package/lib/server/devices/jsObject/jsObjectEnergyManager.d.ts +2 -0
- package/lib/server/devices/jsObject/jsObjectEnergyManager.js +4 -0
- package/lib/server/services/ac/ac-device.js +6 -2
- package/lib/server/services/victron/victron-device.d.ts +8 -6
- package/lib/server/services/victron/victron-device.js +30 -8
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,10 @@ export interface iEnergyManager extends iBaseDevice, iDisposable {
|
|
|
13
13
|
* For devices with {@link DeviceCapability.energyManager} capability.
|
|
14
14
|
*/
|
|
15
15
|
excessEnergy: number;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the Energy Manager actively blocks AC
|
|
18
|
+
*/
|
|
19
|
+
readonly acBlocked: boolean;
|
|
16
20
|
/**
|
|
17
21
|
* The total wattaage being injected into the grid at the moment of last calculation.
|
|
18
22
|
*/
|
|
@@ -23,6 +23,8 @@ export declare class JsObjectEnergyManager extends IoBrokerBaseDevice implements
|
|
|
23
23
|
get drawingWattage(): number;
|
|
24
24
|
get selfConsumingWattage(): number;
|
|
25
25
|
get excessEnergy(): number;
|
|
26
|
+
/** @inheritDoc */
|
|
27
|
+
get acBlocked(): boolean;
|
|
26
28
|
private _excessEnergyConsumerConsumption;
|
|
27
29
|
/**
|
|
28
30
|
* Example:
|
|
@@ -58,6 +58,10 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
58
58
|
get excessEnergy() {
|
|
59
59
|
return this._powerValuePhaseA + this._powerValuePhaseB + this._powerValuePhaseC;
|
|
60
60
|
}
|
|
61
|
+
/** @inheritDoc */
|
|
62
|
+
get acBlocked() {
|
|
63
|
+
return this.excessEnergy < 200;
|
|
64
|
+
}
|
|
61
65
|
/**
|
|
62
66
|
* Example:
|
|
63
67
|
* ________________________________________
|
|
@@ -136,7 +136,7 @@ class AcDevice {
|
|
|
136
136
|
}
|
|
137
137
|
/** @inheritDoc */
|
|
138
138
|
calculateDesiredMode() {
|
|
139
|
-
var _a, _b, _c;
|
|
139
|
+
var _a, _b, _c, _d;
|
|
140
140
|
const acOn = this.on;
|
|
141
141
|
const heatGroup = (_a = this.room) === null || _a === void 0 ? void 0 : _a.HeatGroup;
|
|
142
142
|
if (!heatGroup) {
|
|
@@ -148,6 +148,10 @@ class AcDevice {
|
|
|
148
148
|
acOn && this.log(models_1.LogLevel.Info, 'We should turn off now, as manual disable force is set.');
|
|
149
149
|
return ac_mode_1.AcMode.Off;
|
|
150
150
|
}
|
|
151
|
+
if ((_b = devices_1.Devices.energymanager) === null || _b === void 0 ? void 0 : _b.acBlocked) {
|
|
152
|
+
acOn && this.log(models_1.LogLevel.Info, 'We should turn off now, as energy-manager demands off.');
|
|
153
|
+
return ac_mode_1.AcMode.Off;
|
|
154
|
+
}
|
|
151
155
|
// Check Turn Off Time
|
|
152
156
|
if (!utils_1.Utils.timeWithinBorders(this.settings.minimumHours, this.settings.minimumMinutes, this.settings.maximumHours, this.settings.maximumMinutes)) {
|
|
153
157
|
acOn && this.log(models_1.LogLevel.Info, 'We should turn off now, to respect night settings.');
|
|
@@ -178,7 +182,7 @@ class AcDevice {
|
|
|
178
182
|
let threshold = acOn ? 0.5 : 1.5;
|
|
179
183
|
let thresholdHeating = acOn ? 0.5 : 1.5;
|
|
180
184
|
let desiredMode = ac_mode_1.AcMode.Off;
|
|
181
|
-
const excessEnergy = (
|
|
185
|
+
const excessEnergy = (_d = (_c = devices_1.Devices.energymanager) === null || _c === void 0 ? void 0 : _c.excessEnergy) !== null && _d !== void 0 ? _d : -1;
|
|
182
186
|
if ((acOn ? 200 : 1000) < excessEnergy) {
|
|
183
187
|
// As there is plenty of energy to spare we plan to overshoot the target by 1 degree
|
|
184
188
|
threshold = -0.5;
|
|
@@ -3,13 +3,14 @@ import { BatteryLevelChangeAction, LogLevel, VictronDeviceSettings } from '../..
|
|
|
3
3
|
import { LogDebugType } from '../log-service';
|
|
4
4
|
import { VictronDeviceData, VictronMqttConnectionOptions, VictronMqttConsumer } from 'victron-mqtt-consumer';
|
|
5
5
|
export declare class VictronDevice implements iEnergyManager, iBatteryDevice {
|
|
6
|
-
private readonly _victronConsumer;
|
|
7
6
|
/** @inheritDoc */
|
|
8
7
|
readonly deviceCapabilities: DeviceCapability[];
|
|
9
8
|
/** @inheritDoc */
|
|
10
9
|
deviceType: DeviceType;
|
|
11
10
|
/** @inheritDoc */
|
|
12
11
|
readonly settings: VictronDeviceSettings;
|
|
12
|
+
protected _info: DeviceInfo;
|
|
13
|
+
private readonly _victronConsumer;
|
|
13
14
|
private _excessEnergyConsumer;
|
|
14
15
|
private blockDeviceChangeTime;
|
|
15
16
|
private _lastDeviceChange;
|
|
@@ -20,27 +21,28 @@ export declare class VictronDevice implements iEnergyManager, iBatteryDevice {
|
|
|
20
21
|
private _lastBatteryPersist;
|
|
21
22
|
private _lastBatteryLevel;
|
|
22
23
|
private _batteryLevelCallbacks;
|
|
24
|
+
private _excessEnergy;
|
|
23
25
|
constructor(opts: VictronMqttConnectionOptions);
|
|
24
26
|
/** @inheritDoc */
|
|
27
|
+
get acBlocked(): boolean;
|
|
28
|
+
/** @inheritDoc */
|
|
25
29
|
get lastBatteryPersist(): number;
|
|
26
|
-
protected _info: DeviceInfo;
|
|
27
30
|
get info(): DeviceInfo;
|
|
28
31
|
/** @inheritDoc */
|
|
29
32
|
get battery(): number;
|
|
30
33
|
get victronConsumer(): VictronMqttConsumer;
|
|
31
34
|
get data(): VictronDeviceData;
|
|
32
|
-
private _excessEnergy;
|
|
33
35
|
get excessEnergy(): number;
|
|
34
36
|
get name(): string;
|
|
35
37
|
get customName(): string;
|
|
36
38
|
get id(): string;
|
|
37
|
-
/** @inheritDoc */
|
|
38
|
-
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
39
|
-
addExcessConsumer(device: iExcessEnergyConsumer): void;
|
|
40
39
|
get injectingWattage(): number;
|
|
41
40
|
get drawingWattage(): number;
|
|
42
41
|
get selfConsumingWattage(): number;
|
|
43
42
|
/** @inheritDoc */
|
|
43
|
+
addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
|
|
44
|
+
addExcessConsumer(device: iExcessEnergyConsumer): void;
|
|
45
|
+
/** @inheritDoc */
|
|
44
46
|
dispose(): void;
|
|
45
47
|
getReport(): string;
|
|
46
48
|
recalculatePowerSharing(): void;
|
|
@@ -7,6 +7,7 @@ const models_1 = require("../../../models");
|
|
|
7
7
|
const log_service_1 = require("../log-service");
|
|
8
8
|
const victron_mqtt_consumer_1 = require("victron-mqtt-consumer");
|
|
9
9
|
const time_callback_service_1 = require("../time-callback-service");
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
10
11
|
class VictronDevice {
|
|
11
12
|
constructor(opts) {
|
|
12
13
|
/** @inheritDoc */
|
|
@@ -45,6 +46,20 @@ class VictronDevice {
|
|
|
45
46
|
this._nextPersistEntry = new models_1.EnergyCalculation(utils_1.Utils.nowMS());
|
|
46
47
|
}
|
|
47
48
|
/** @inheritDoc */
|
|
49
|
+
get acBlocked() {
|
|
50
|
+
if (this.settings.hasBattery) {
|
|
51
|
+
const hours = new Date().getHours();
|
|
52
|
+
if (hours < 6 || hours > 18) {
|
|
53
|
+
return this.battery < 70;
|
|
54
|
+
}
|
|
55
|
+
if (hours < 10 || hours > 16) {
|
|
56
|
+
return this.battery < 60;
|
|
57
|
+
}
|
|
58
|
+
return this.battery < 50;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
/** @inheritDoc */
|
|
48
63
|
get lastBatteryPersist() {
|
|
49
64
|
return this._lastBatteryPersist;
|
|
50
65
|
}
|
|
@@ -79,13 +94,6 @@ class VictronDevice {
|
|
|
79
94
|
var _a;
|
|
80
95
|
return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `victron-${this.info.room}-${this.info.customName}`;
|
|
81
96
|
}
|
|
82
|
-
/** @inheritDoc */
|
|
83
|
-
addBatteryLevelCallback(pCallback) {
|
|
84
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
85
|
-
}
|
|
86
|
-
addExcessConsumer(device) {
|
|
87
|
-
this._excessEnergyConsumer.push(device);
|
|
88
|
-
}
|
|
89
97
|
get injectingWattage() {
|
|
90
98
|
var _a;
|
|
91
99
|
return Math.min((_a = this.victronConsumer.data.grid.power) !== null && _a !== void 0 ? _a : 0, 0) * -1;
|
|
@@ -99,6 +107,13 @@ class VictronDevice {
|
|
|
99
107
|
return Math.max((_a = this.victronConsumer.data.system.power) !== null && _a !== void 0 ? _a : 0, 0) - this.drawingWattage;
|
|
100
108
|
}
|
|
101
109
|
/** @inheritDoc */
|
|
110
|
+
addBatteryLevelCallback(pCallback) {
|
|
111
|
+
this._batteryLevelCallbacks.push(pCallback);
|
|
112
|
+
}
|
|
113
|
+
addExcessConsumer(device) {
|
|
114
|
+
this._excessEnergyConsumer.push(device);
|
|
115
|
+
}
|
|
116
|
+
/** @inheritDoc */
|
|
102
117
|
dispose() {
|
|
103
118
|
this._victronConsumer.disconnect();
|
|
104
119
|
if (this._iDatabaseLoggerInterval !== null) {
|
|
@@ -154,7 +169,14 @@ class VictronDevice {
|
|
|
154
169
|
this._lastBatteryPersist = now;
|
|
155
170
|
}
|
|
156
171
|
toJSON() {
|
|
157
|
-
return utils_1.Utils.jsonFilter(this, ['_victronConsumer'])
|
|
172
|
+
return (0, lodash_1.extend)(utils_1.Utils.jsonFilter(this, ['_victronConsumer', '_excessEnergyConsumer']), {
|
|
173
|
+
battery: this.battery,
|
|
174
|
+
acBlocked: this.acBlocked,
|
|
175
|
+
excessEnergy: this.excessEnergy,
|
|
176
|
+
drawingWattage: this.drawingWattage,
|
|
177
|
+
injectingWattage: this.injectingWattage,
|
|
178
|
+
selfConsumingWattage: this.selfConsumingWattage,
|
|
179
|
+
});
|
|
158
180
|
}
|
|
159
181
|
/**
|
|
160
182
|
* Changes the grid set point of the Victron device, to the desired value.
|