hoffmation-base 3.0.0-alpha.46 → 3.0.0-alpha.48
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/config/iLogSettings.d.ts +4 -0
- package/lib/server/devices/baseDeviceInterfaces/iEnergyManager.d.ts +4 -0
- package/lib/server/devices/dachs/dachs.js +2 -2
- package/lib/server/devices/dachs/lib/dachsHttpClient.d.ts +4 -1
- package/lib/server/devices/dachs/lib/dachsHttpClient.js +5 -4
- 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 +5 -2
- package/lib/server/services/log-service/log-debug-type.d.ts +2 -1
- package/lib/server/services/log-service/log-debug-type.js +1 -0
- package/lib/server/services/victron/victron-device.d.ts +8 -6
- package/lib/server/services/victron/victron-device.js +21 -7
- 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
|
*/
|
|
@@ -53,7 +53,7 @@ class Dachs {
|
|
|
53
53
|
flatten: true,
|
|
54
54
|
};
|
|
55
55
|
this.config = modifiedOptions;
|
|
56
|
-
this.client = new lib_1.DachsHttpClient(this.config.connectionOptions);
|
|
56
|
+
this.client = new lib_1.DachsHttpClient(this.config.connectionOptions, this.log.bind(this));
|
|
57
57
|
this.warmWaterSensor = new dachsTemperatureSensor_1.DachsTemperatureSensor(this.config.roomName, 'ww', 'Water Temperature');
|
|
58
58
|
this.heatStorageTempSensor = new dachsTemperatureSensor_1.DachsTemperatureSensor(this.config.roomName, 'hs', 'Heat Storage Temperature');
|
|
59
59
|
services_1.Utils.guardedInterval(this.loadData, this.config.refreshInterval, this);
|
|
@@ -135,7 +135,7 @@ class Dachs {
|
|
|
135
135
|
this.persist();
|
|
136
136
|
})
|
|
137
137
|
.catch((error) => {
|
|
138
|
-
this.log(models_1.LogLevel.Error, `Error while fetching data: ${error}
|
|
138
|
+
this.log(models_1.LogLevel.Error, `Error while fetching data: ${error}`, services_1.LogDebugType.DachsUnreach);
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
/** @inheritDoc */
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { DachsClientOptions, iFlattenedCompleteResponse, KeyListEntityResponse } from '../interfaces';
|
|
3
|
+
import { LogDebugType } from '../../../services';
|
|
4
|
+
import { LogLevel } from '../../../../models';
|
|
3
5
|
/**
|
|
4
6
|
* axios HTTP Client Class
|
|
5
7
|
* - with some prepared fetch functions for data
|
|
@@ -8,10 +10,11 @@ import { DachsClientOptions, iFlattenedCompleteResponse, KeyListEntityResponse }
|
|
|
8
10
|
* @class
|
|
9
11
|
*/
|
|
10
12
|
export declare class DachsHttpClient {
|
|
13
|
+
private readonly _logger;
|
|
11
14
|
private options;
|
|
12
15
|
private readonly url;
|
|
13
16
|
private axiosInstance;
|
|
14
|
-
constructor(options: DachsClientOptions);
|
|
17
|
+
constructor(options: DachsClientOptions, _logger: (level: LogLevel, message: string, logDebugType?: LogDebugType) => void);
|
|
15
18
|
/**
|
|
16
19
|
* Takes every key and add the key to the get parameter list
|
|
17
20
|
* @param {string[]} keys - Array of request keys
|
|
@@ -41,8 +41,9 @@ const models_1 = require("../../../../models");
|
|
|
41
41
|
* @class
|
|
42
42
|
*/
|
|
43
43
|
class DachsHttpClient {
|
|
44
|
-
constructor(options) {
|
|
44
|
+
constructor(options, _logger) {
|
|
45
45
|
var _a;
|
|
46
|
+
this._logger = _logger;
|
|
46
47
|
this.options = options;
|
|
47
48
|
//combine parameter to baseUrl
|
|
48
49
|
//check http prefix
|
|
@@ -61,7 +62,7 @@ class DachsHttpClient {
|
|
|
61
62
|
this.axiosInstance.interceptors.response.use((response) => {
|
|
62
63
|
return response;
|
|
63
64
|
}, (error) => {
|
|
64
|
-
|
|
65
|
+
this._logger(models_1.LogLevel.Error, `DachsHttpClient: ${error.message}`, services_1.LogDebugType.DachsUnreach);
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
@@ -89,7 +90,7 @@ class DachsHttpClient {
|
|
|
89
90
|
fetchByKeys(...keys) {
|
|
90
91
|
return new Promise((resolve, reject) => {
|
|
91
92
|
this.axiosInstance
|
|
92
|
-
.get(
|
|
93
|
+
.get('/getKey' + this.urlBuilder(keys))
|
|
93
94
|
.then((res) => {
|
|
94
95
|
if (!res.data)
|
|
95
96
|
reject('No data received');
|
|
@@ -117,7 +118,7 @@ class DachsHttpClient {
|
|
|
117
118
|
setKeys(data) {
|
|
118
119
|
return new Promise((resolve, reject) => {
|
|
119
120
|
this.axiosInstance
|
|
120
|
-
.post(
|
|
121
|
+
.post('/setKeys', Object.entries(data)
|
|
121
122
|
.map(([key, value]) => `${key}=${value}`)
|
|
122
123
|
.join('&'))
|
|
123
124
|
.then((res) => {
|
|
@@ -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,9 @@ 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
|
+
return ac_mode_1.AcMode.Off;
|
|
153
|
+
}
|
|
151
154
|
// Check Turn Off Time
|
|
152
155
|
if (!utils_1.Utils.timeWithinBorders(this.settings.minimumHours, this.settings.minimumMinutes, this.settings.maximumHours, this.settings.maximumMinutes)) {
|
|
153
156
|
acOn && this.log(models_1.LogLevel.Info, 'We should turn off now, to respect night settings.');
|
|
@@ -178,7 +181,7 @@ class AcDevice {
|
|
|
178
181
|
let threshold = acOn ? 0.5 : 1.5;
|
|
179
182
|
let thresholdHeating = acOn ? 0.5 : 1.5;
|
|
180
183
|
let desiredMode = ac_mode_1.AcMode.Off;
|
|
181
|
-
const excessEnergy = (
|
|
184
|
+
const excessEnergy = (_d = (_c = devices_1.Devices.energymanager) === null || _c === void 0 ? void 0 : _c.excessEnergy) !== null && _d !== void 0 ? _d : -1;
|
|
182
185
|
if ((acOn ? 200 : 1000) < excessEnergy) {
|
|
183
186
|
// As there is plenty of energy to spare we plan to overshoot the target by 1 degree
|
|
184
187
|
threshold = -0.5;
|
|
@@ -13,4 +13,5 @@ var LogDebugType;
|
|
|
13
13
|
LogDebugType[LogDebugType["DaikinSuccessfullControlInfo"] = 7] = "DaikinSuccessfullControlInfo";
|
|
14
14
|
LogDebugType[LogDebugType["EuroHeaterValveLogging"] = 8] = "EuroHeaterValveLogging";
|
|
15
15
|
LogDebugType[LogDebugType["Trilateration"] = 9] = "Trilateration";
|
|
16
|
+
LogDebugType[LogDebugType["DachsUnreach"] = 10] = "DachsUnreach";
|
|
16
17
|
})(LogDebugType || (exports.LogDebugType = LogDebugType = {}));
|
|
@@ -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;
|
|
@@ -45,6 +45,20 @@ class VictronDevice {
|
|
|
45
45
|
this._nextPersistEntry = new models_1.EnergyCalculation(utils_1.Utils.nowMS());
|
|
46
46
|
}
|
|
47
47
|
/** @inheritDoc */
|
|
48
|
+
get acBlocked() {
|
|
49
|
+
if (this.settings.hasBattery) {
|
|
50
|
+
const hours = new Date().getHours();
|
|
51
|
+
if (hours < 6 || hours > 18) {
|
|
52
|
+
return this.battery < 70;
|
|
53
|
+
}
|
|
54
|
+
if (hours < 10 || hours > 16) {
|
|
55
|
+
return this.battery < 60;
|
|
56
|
+
}
|
|
57
|
+
return this.battery < 50;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
/** @inheritDoc */
|
|
48
62
|
get lastBatteryPersist() {
|
|
49
63
|
return this._lastBatteryPersist;
|
|
50
64
|
}
|
|
@@ -79,13 +93,6 @@ class VictronDevice {
|
|
|
79
93
|
var _a;
|
|
80
94
|
return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `victron-${this.info.room}-${this.info.customName}`;
|
|
81
95
|
}
|
|
82
|
-
/** @inheritDoc */
|
|
83
|
-
addBatteryLevelCallback(pCallback) {
|
|
84
|
-
this._batteryLevelCallbacks.push(pCallback);
|
|
85
|
-
}
|
|
86
|
-
addExcessConsumer(device) {
|
|
87
|
-
this._excessEnergyConsumer.push(device);
|
|
88
|
-
}
|
|
89
96
|
get injectingWattage() {
|
|
90
97
|
var _a;
|
|
91
98
|
return Math.min((_a = this.victronConsumer.data.grid.power) !== null && _a !== void 0 ? _a : 0, 0) * -1;
|
|
@@ -99,6 +106,13 @@ class VictronDevice {
|
|
|
99
106
|
return Math.max((_a = this.victronConsumer.data.system.power) !== null && _a !== void 0 ? _a : 0, 0) - this.drawingWattage;
|
|
100
107
|
}
|
|
101
108
|
/** @inheritDoc */
|
|
109
|
+
addBatteryLevelCallback(pCallback) {
|
|
110
|
+
this._batteryLevelCallbacks.push(pCallback);
|
|
111
|
+
}
|
|
112
|
+
addExcessConsumer(device) {
|
|
113
|
+
this._excessEnergyConsumer.push(device);
|
|
114
|
+
}
|
|
115
|
+
/** @inheritDoc */
|
|
102
116
|
dispose() {
|
|
103
117
|
this._victronConsumer.disconnect();
|
|
104
118
|
if (this._iDatabaseLoggerInterval !== null) {
|