hoffmation-base 2.20.0-beta.4 → 2.20.0

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.
@@ -19,6 +19,7 @@ class OwnGoveeDevice {
19
19
  this.settings = new models_1.LedSettings();
20
20
  this.deviceType = devices_1.DeviceType.GoveeLed;
21
21
  this.deviceCapabilities = [
22
+ DeviceCapability_1.DeviceCapability.ledLamp,
22
23
  DeviceCapability_1.DeviceCapability.lamp,
23
24
  DeviceCapability_1.DeviceCapability.dimmablelamp,
24
25
  DeviceCapability_1.DeviceCapability.blockAutomatic,
@@ -137,23 +137,25 @@ class VictronDevice {
137
137
  // Step 1: Calculate battery need
138
138
  const hoursTilSunset = time_callback_service_1.TimeCallbackService.hoursTilSunset();
139
139
  let neededBatteryWattage = 0;
140
- if (this.settings.hasBattery) {
140
+ const timeOfDay = time_callback_service_1.TimeCallbackService.dayType(new time_callback_service_1.SunTimeOffsets());
141
+ if (this.settings.hasBattery && timeOfDay !== models_1.TimeOfDay.AfterSunset && timeOfDay !== models_1.TimeOfDay.Night) {
141
142
  if (this.data.battery.soc == null) {
142
143
  this.log(models_1.LogLevel.Debug, `No battery data available from Victron device.`);
143
144
  return;
144
145
  }
145
146
  neededBatteryWattage = ((1 - this.data.battery.soc) * this.settings.batteryCapacityWattage) / hoursTilSunset;
147
+ // Step 2: Calculate expected solar output
148
+ const solarOutput = (_a = this.data.pvInverter.power) !== null && _a !== void 0 ? _a : 0;
149
+ // Step 3: Calculate expected base consumption
150
+ const baseConsumption = this.settings.normalBaseConsumptionWattage;
151
+ // Step 4: Combine to get currently excess energy
152
+ this._excessEnergy = solarOutput - neededBatteryWattage - baseConsumption;
146
153
  }
147
- // Step 2: Calculate expected solar output
148
- const solarOutput = (_a = this.data.pvInverter.power) !== null && _a !== void 0 ? _a : 0;
149
- // Step 3: Calculate expected base consumption
150
- const baseConsumption = this.settings.normalBaseConsumptionWattage;
151
- // Step 4: Combine to get currently excess energy
152
- this._excessEnergy = solarOutput - neededBatteryWattage - baseConsumption;
153
154
  // Whilst calculated spare energy is more precise, we don't mind using the battery as a buffer, if it is full enough.
154
155
  if (this.data.battery.dcPower !== null &&
155
156
  this.data.battery.soc !== null &&
156
- this.data.battery.soc > (hoursTilSunset > 4 ? 0.7 : 0.8)) {
157
+ this.data.battery.soc >
158
+ (hoursTilSunset > 4 && timeOfDay !== models_1.TimeOfDay.AfterSunset && timeOfDay !== models_1.TimeOfDay.Night ? 0.7 : 0.8)) {
157
159
  this._excessEnergy = this.settings.maximumBatteryDischargeWattage - Math.max(this.data.battery.dcPower, 0);
158
160
  }
159
161
  this.calculatePersistenceValues();