hoffmation-base 3.0.0-alpha.41 → 3.0.0-alpha.43
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/index.js +6 -3
- package/lib/models/action/batteryLevelChangeAction.d.ts +13 -0
- package/lib/models/action/batteryLevelChangeAction.js +14 -0
- package/lib/models/action/index.d.ts +1 -0
- package/lib/models/action/index.js +3 -1
- package/lib/models/command/blockAutomaticUntilCommand.js +1 -1
- package/lib/models/command/commandType.d.ts +1 -0
- package/lib/models/command/commandType.js +1 -0
- package/lib/models/deviceSettings/dachsSettings.d.ts +8 -0
- package/lib/models/deviceSettings/dachsSettings.js +10 -1
- package/lib/server/devices/baseDeviceInterfaces/iBatteryDevice.d.ts +9 -3
- package/lib/server/devices/dachs/dachs.d.ts +6 -2
- package/lib/server/devices/dachs/dachs.js +19 -2
- package/lib/server/devices/groups/lightGroup.js +2 -3
- package/lib/server/devices/groups/presenceGroup.js +14 -10
- package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +9 -0
- package/lib/server/devices/hmIPDevices/hmIpGriff.js +21 -0
- package/lib/server/devices/hmIPDevices/hmIpHeizung.d.ts +12 -3
- package/lib/server/devices/hmIPDevices/hmIpHeizung.js +32 -12
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.d.ts +9 -1
- package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +20 -0
- package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +13 -4
- package/lib/server/devices/hmIPDevices/hmIpTaster.js +28 -8
- package/lib/server/devices/hmIPDevices/hmIpTherm.d.ts +10 -1
- package/lib/server/devices/hmIPDevices/hmIpTherm.js +25 -5
- package/lib/server/devices/shelly/shellyTrv.d.ts +9 -1
- package/lib/server/devices/shelly/shellyTrv.js +20 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.d.ts +19 -11
- package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +47 -27
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.d.ts +16 -7
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMagnetContact.js +45 -25
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +9 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +20 -0
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.d.ts +9 -0
- package/lib/server/devices/zigbee/zigbeeAquaraVibra.js +20 -0
- package/lib/server/devices/zigbee/zigbeeAquaraWater.d.ts +18 -9
- package/lib/server/devices/zigbee/zigbeeAquaraWater.js +44 -24
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.d.ts +21 -12
- package/lib/server/devices/zigbee/zigbeeHeimanSmoke.js +37 -17
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.d.ts +17 -9
- package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +30 -10
- package/lib/server/services/ac/own-daikin-device.d.ts +8 -0
- package/lib/server/services/ac/own-daikin-device.js +8 -0
- package/lib/server/services/victron/victron-device.d.ts +15 -4
- package/lib/server/services/victron/victron-device.js +54 -12
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -4,14 +4,16 @@ exports.VictronDevice = void 0;
|
|
|
4
4
|
const devices_1 = require("../../devices");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const models_1 = require("../../../models");
|
|
7
|
-
const DeviceCapability_1 = require("../../devices/DeviceCapability");
|
|
8
7
|
const log_service_1 = require("../log-service");
|
|
9
8
|
const victron_mqtt_consumer_1 = require("victron-mqtt-consumer");
|
|
10
9
|
const time_callback_service_1 = require("../time-callback-service");
|
|
11
10
|
class VictronDevice {
|
|
12
11
|
constructor(opts) {
|
|
13
12
|
/** @inheritDoc */
|
|
14
|
-
this.deviceCapabilities = [
|
|
13
|
+
this.deviceCapabilities = [
|
|
14
|
+
devices_1.DeviceCapability.energyManager,
|
|
15
|
+
devices_1.DeviceCapability.batteryDriven,
|
|
16
|
+
];
|
|
15
17
|
/** @inheritDoc */
|
|
16
18
|
this.deviceType = devices_1.DeviceType.Victron;
|
|
17
19
|
this._excessEnergyConsumer = [];
|
|
@@ -19,6 +21,9 @@ class VictronDevice {
|
|
|
19
21
|
this._iCalculationInterval = null;
|
|
20
22
|
this._iDatabaseLoggerInterval = null;
|
|
21
23
|
this._lastPersistenceCalculation = utils_1.Utils.nowMS();
|
|
24
|
+
this._lastBatteryPersist = 0;
|
|
25
|
+
this._lastBatteryLevel = -1;
|
|
26
|
+
this._batteryLevelCallbacks = [];
|
|
22
27
|
this._excessEnergy = 0;
|
|
23
28
|
this.settings = new models_1.VictronDeviceSettings();
|
|
24
29
|
this._info = new devices_1.DeviceInfo();
|
|
@@ -31,6 +36,7 @@ class VictronDevice {
|
|
|
31
36
|
this.loadDeviceSettings();
|
|
32
37
|
this._victronConsumer = new victron_mqtt_consumer_1.VictronMqttConsumer(opts);
|
|
33
38
|
this._iCalculationInterval = utils_1.Utils.guardedInterval(() => {
|
|
39
|
+
this.checkForBatteryChange();
|
|
34
40
|
this.calculateExcessEnergy();
|
|
35
41
|
}, 5 * 1000, this);
|
|
36
42
|
this._iDatabaseLoggerInterval = utils_1.Utils.guardedInterval(() => {
|
|
@@ -38,9 +44,22 @@ class VictronDevice {
|
|
|
38
44
|
}, 15 * 60 * 1000, this);
|
|
39
45
|
this._nextPersistEntry = new models_1.EnergyCalculation(utils_1.Utils.nowMS());
|
|
40
46
|
}
|
|
47
|
+
/** @inheritDoc */
|
|
48
|
+
get lastBatteryPersist() {
|
|
49
|
+
return this._lastBatteryPersist;
|
|
50
|
+
}
|
|
41
51
|
get info() {
|
|
42
52
|
return this._info;
|
|
43
53
|
}
|
|
54
|
+
/** @inheritDoc */
|
|
55
|
+
get battery() {
|
|
56
|
+
const level = this.data.battery.soc;
|
|
57
|
+
if (level == null) {
|
|
58
|
+
this.log(models_1.LogLevel.Debug, 'No battery data available from Victron device.');
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
return level * 100;
|
|
62
|
+
}
|
|
44
63
|
get victronConsumer() {
|
|
45
64
|
return this._victronConsumer;
|
|
46
65
|
}
|
|
@@ -60,6 +79,10 @@ class VictronDevice {
|
|
|
60
79
|
var _a;
|
|
61
80
|
return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `victron-${this.info.room}-${this.info.customName}`;
|
|
62
81
|
}
|
|
82
|
+
/** @inheritDoc */
|
|
83
|
+
addBatteryLevelCallback(pCallback) {
|
|
84
|
+
this._batteryLevelCallbacks.push(pCallback);
|
|
85
|
+
}
|
|
63
86
|
addExcessConsumer(device) {
|
|
64
87
|
this._excessEnergyConsumer.push(device);
|
|
65
88
|
}
|
|
@@ -120,6 +143,16 @@ class VictronDevice {
|
|
|
120
143
|
(_a = utils_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.addDevice(this);
|
|
121
144
|
}, 5000, this);
|
|
122
145
|
}
|
|
146
|
+
/** @inheritDoc */
|
|
147
|
+
persistBatteryDevice() {
|
|
148
|
+
var _a;
|
|
149
|
+
const now = utils_1.Utils.nowMS();
|
|
150
|
+
if (this._lastBatteryPersist + 60000 > now) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
(_a = utils_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
154
|
+
this._lastBatteryPersist = now;
|
|
155
|
+
}
|
|
123
156
|
toJSON() {
|
|
124
157
|
return utils_1.Utils.jsonFilter(this, ['_victronConsumer']);
|
|
125
158
|
}
|
|
@@ -142,11 +175,11 @@ class VictronDevice {
|
|
|
142
175
|
let neededBatteryWattage = 0;
|
|
143
176
|
const timeOfDay = time_callback_service_1.TimeCallbackService.dayType(new time_callback_service_1.SunTimeOffsets());
|
|
144
177
|
if (this.settings.hasBattery && timeOfDay !== models_1.TimeOfDay.AfterSunset && timeOfDay !== models_1.TimeOfDay.Night) {
|
|
145
|
-
if (this.
|
|
178
|
+
if (this.battery < 0) {
|
|
146
179
|
this.log(models_1.LogLevel.Debug, 'No battery data available from Victron device.');
|
|
147
180
|
return;
|
|
148
181
|
}
|
|
149
|
-
neededBatteryWattage = ((1 - this.
|
|
182
|
+
neededBatteryWattage = ((1 - this.battery / 100.0) * this.settings.batteryCapacityWattage) / hoursTilSunset;
|
|
150
183
|
// Step 2: Calculate expected solar output
|
|
151
184
|
const solarOutput = (_a = this.data.pvInverter.power) !== null && _a !== void 0 ? _a : 0;
|
|
152
185
|
// Step 3: Calculate expected base consumption
|
|
@@ -155,22 +188,22 @@ class VictronDevice {
|
|
|
155
188
|
this._excessEnergy = solarOutput - neededBatteryWattage - baseConsumption;
|
|
156
189
|
}
|
|
157
190
|
let isSocTooLow = false;
|
|
158
|
-
if (this.data.battery.dcPower !== null && this.
|
|
191
|
+
if (this.data.battery.dcPower !== null && this.battery > -1) {
|
|
159
192
|
if (timeOfDay === models_1.TimeOfDay.Night) {
|
|
160
|
-
isSocTooLow = this.
|
|
193
|
+
isSocTooLow = this.battery < 50;
|
|
161
194
|
}
|
|
162
195
|
else if (timeOfDay === models_1.TimeOfDay.AfterSunset) {
|
|
163
|
-
isSocTooLow = this.
|
|
196
|
+
isSocTooLow = this.battery < 75;
|
|
164
197
|
}
|
|
165
198
|
else if (hoursTilSunset > 4) {
|
|
166
|
-
isSocTooLow = this.
|
|
199
|
+
isSocTooLow = this.battery < 70;
|
|
167
200
|
}
|
|
168
201
|
else {
|
|
169
|
-
isSocTooLow = this.
|
|
202
|
+
isSocTooLow = this.battery < 80;
|
|
170
203
|
}
|
|
171
204
|
}
|
|
172
205
|
// Whilst calculated spare energy is more precise, we don't mind using the battery as a buffer, if it is full enough.
|
|
173
|
-
if (this.data.battery.dcPower !== null && this.
|
|
206
|
+
if (this.data.battery.dcPower !== null && this.battery > -1 && !isSocTooLow) {
|
|
174
207
|
this._excessEnergy = this.settings.maximumBatteryDischargeWattage - Math.max(this.data.battery.dcPower, 0);
|
|
175
208
|
}
|
|
176
209
|
this.calculatePersistenceValues();
|
|
@@ -202,8 +235,7 @@ class VictronDevice {
|
|
|
202
235
|
}
|
|
203
236
|
}
|
|
204
237
|
persist() {
|
|
205
|
-
|
|
206
|
-
this._nextPersistEntry.batteryLevel = ((_a = this.data.battery.soc) !== null && _a !== void 0 ? _a : 0) / 100;
|
|
238
|
+
this._nextPersistEntry.batteryLevel = this.battery / 100;
|
|
207
239
|
this._nextPersistEntry.batteryStoredKwH =
|
|
208
240
|
(this._nextPersistEntry.batteryLevel * this.settings.batteryCapacityWattage) / 1000;
|
|
209
241
|
const obj = JSON.parse(JSON.stringify(this._nextPersistEntry));
|
|
@@ -220,5 +252,15 @@ class VictronDevice {
|
|
|
220
252
|
this._nextPersistEntry.selfConsumedKwH += utils_1.Utils.kWh(this.selfConsumingWattage, duration);
|
|
221
253
|
this._lastPersistenceCalculation = now;
|
|
222
254
|
}
|
|
255
|
+
checkForBatteryChange() {
|
|
256
|
+
const newLevel = this.battery;
|
|
257
|
+
if (newLevel == this._lastBatteryLevel) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
for (const cb of this._batteryLevelCallbacks) {
|
|
261
|
+
cb(new models_1.BatteryLevelChangeAction(this));
|
|
262
|
+
}
|
|
263
|
+
this._lastBatteryLevel = newLevel;
|
|
264
|
+
}
|
|
223
265
|
}
|
|
224
266
|
exports.VictronDevice = VictronDevice;
|