hoffmation-base 2.20.0 → 2.20.1

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.
@@ -151,11 +151,23 @@ class VictronDevice {
151
151
  // Step 4: Combine to get currently excess energy
152
152
  this._excessEnergy = solarOutput - neededBatteryWattage - baseConsumption;
153
153
  }
154
+ let isSocTooLow = false;
155
+ if (this.data.battery.dcPower !== null && this.data.battery.soc !== null) {
156
+ if (timeOfDay === models_1.TimeOfDay.Night) {
157
+ isSocTooLow = this.data.battery.soc < 0.5;
158
+ }
159
+ else if (timeOfDay === models_1.TimeOfDay.AfterSunset) {
160
+ isSocTooLow = this.data.battery.soc < 0.75;
161
+ }
162
+ else if (hoursTilSunset > 4) {
163
+ isSocTooLow = this.data.battery.soc < 0.7;
164
+ }
165
+ else {
166
+ isSocTooLow = this.data.battery.soc < 0.8;
167
+ }
168
+ }
154
169
  // Whilst calculated spare energy is more precise, we don't mind using the battery as a buffer, if it is full enough.
155
- if (this.data.battery.dcPower !== null &&
156
- this.data.battery.soc !== null &&
157
- this.data.battery.soc >
158
- (hoursTilSunset > 4 && timeOfDay !== models_1.TimeOfDay.AfterSunset && timeOfDay !== models_1.TimeOfDay.Night ? 0.7 : 0.8)) {
170
+ if (this.data.battery.dcPower !== null && this.data.battery.soc !== null && !isSocTooLow) {
159
171
  this._excessEnergy = this.settings.maximumBatteryDischargeWattage - Math.max(this.data.battery.dcPower, 0);
160
172
  }
161
173
  this.calculatePersistenceValues();