diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5f1406..d7b963d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,10 @@ ## **WORK IN PROGRESS** * (theimo1221) Update packages --> -## 3.0.0-alpha.94 (2024-10-16) -* (theimo1221) Expose weather report humidity -* (theimo1221) Update packages - -## 3.0.0-alpha.93 (2024-10-16) +## **WORK IN PROGRESS** -* (theimo1221) Update OpenWeatherMap API from 2.5 to 3.0 +* (theimo1221) Improve Dachs Warm-Water-Pump behaviour ## 3.0.0 @@ -84,6 +80,8 @@ temp-/humidity sensor and buttons for up/down * (theimo1221) Add option to report Victron Battery at interval even without level change. * (theimo1221) Make Victron AC Block configurable +* (theimo1221) Update OpenWeatherMap API from 2.5 to 3.0 +* (theimo1221) Expose weather report humidity ## 2.23.0 (2024-02-25) diff --git a/src/server/devices/dachs/dachs.ts b/src/server/devices/dachs/dachs.ts index a06534a0..e2cce4ce 100644 --- a/src/server/devices/dachs/dachs.ts +++ b/src/server/devices/dachs/dachs.ts @@ -230,6 +230,10 @@ export class Dachs implements iBaseDevice, iActuator { /** @inheritDoc */ public setActuator(c: ActuatorSetStateCommand): void { LampUtils.setActuator(this, c); + if (c.on && this.warmWaterPump && (this.queuedValue === true || this._dachsOn)) { + const startPumpCommand: ActuatorSetStateCommand = new ActuatorSetStateCommand(c, true, 'Dachs is starting/on'); + this.warmWaterPump.setActuator(startPumpCommand); + } } /** @inheritDoc */ @@ -277,48 +281,9 @@ export class Dachs implements iBaseDevice, iActuator { * @param {BatteryLevelChangeAction} action - The action containing the new level */ private onBatteryLevelChange(action: BatteryLevelChangeAction): void { + const shouldDachsBeStarted: boolean = this.shouldDachsBeStarted(action); this.checkHeatingRod(action); - if (this.blockDachsStart !== undefined) { - if (action.newLevel > this.settings.batteryLevelPreventStartThreshold) { - const blockAction: ActuatorSetStateCommand = new ActuatorSetStateCommand( - action, - true, - `Battery reached ${action.newLevel}%, Dachs should not run any more`, - null, - ); - blockAction.overrideCommandSource = CommandSource.Force; - this.blockDachsStart.setActuator(blockAction); - return; - } else if (action.newLevel < this.settings.batteryLevelAllowStartThreshold) { - const liftAction: ActuatorSetStateCommand = new ActuatorSetStateCommand( - action, - false, - `Battery reached ${action.newLevel}%, Dachs is now allowed to run if needed`, - null, - ); - this.blockDachsStart.setActuator(liftAction); - } else if (this.blockDachsStart.actuatorOn) { - // We haven't reached the lower threshold yet --> nothing to do - return; - } - } - if (this._dachsOn) { - // We are already running - return; - } - - const dayType: TimeOfDay = TimeCallbackService.dayType(new SunTimeOffsets()); - - if ( - (dayType === TimeOfDay.Daylight || dayType === TimeOfDay.BeforeSunrise) && - action.newLevel > this.settings.batteryLevelTurnOnThreshold - ) { - // It is daytime (maybe solar power) and it is no critical battery level - return; - } - - if (action.newLevel > this.settings.batteryLevelBeforeNightTurnOnThreshold) { - // It is not daylight but battery level is high enough + if (!shouldDachsBeStarted) { return; } @@ -342,12 +307,18 @@ export class Dachs implements iBaseDevice, iActuator { const heatStorageTemp: number = this._tempHeatStorage; let desiredState: boolean = false; let reason: string = ''; - if (wwTemp > this.settings.warmWaterDesiredMinTemp + 3) { - desiredState = false; - reason = `Temperature of warm water pump ${wwTemp}°C is above desired minimum temperature ${this.settings.warmWaterDesiredMinTemp}°C`; + if (this._dachsOn) { + desiredState = true; + reason = 'Dachs is on anyways'; } else if (wwTemp > heatStorageTemp) { desiredState = false; reason = `Temperature of warm water pump ${wwTemp}°C is higher than temperature of heat storage ${heatStorageTemp}°C`; + } else if (this.blockDachsStart?.actuatorOn === false) { + desiredState = true; + reason = 'Dachs is not blocked --> lowering storage temp might trigger it.'; + } else if (wwTemp > this.settings.warmWaterDesiredMinTemp + 3) { + desiredState = false; + reason = `Temperature of warm water pump ${wwTemp}°C is above desired minimum temperature ${this.settings.warmWaterDesiredMinTemp}°C`; } else if (heatStorageTemp < this.settings.warmWaterDesiredMinTemp - 4) { desiredState = false; reason = `Temperature of heat storage ${heatStorageTemp}°C is too low to heat water.`; @@ -384,4 +355,51 @@ export class Dachs implements iBaseDevice, iActuator { ); this.heatingRod.setActuator(setAction); } + + private shouldDachsBeStarted(action: BatteryLevelChangeAction): boolean { + if (this.blockDachsStart !== undefined) { + if (action.newLevel > this.settings.batteryLevelPreventStartThreshold) { + const blockAction: ActuatorSetStateCommand = new ActuatorSetStateCommand( + action, + true, + `Battery reached ${action.newLevel}%, Dachs should not run any more`, + null, + ); + blockAction.overrideCommandSource = CommandSource.Force; + this.blockDachsStart.setActuator(blockAction); + return false; + } else if (action.newLevel < this.settings.batteryLevelAllowStartThreshold) { + const liftAction: ActuatorSetStateCommand = new ActuatorSetStateCommand( + action, + false, + `Battery reached ${action.newLevel}%, Dachs is now allowed to run if needed`, + null, + ); + this.blockDachsStart.setActuator(liftAction); + } else if (this.blockDachsStart.actuatorOn) { + // We haven't reached the lower threshold yet --> nothing to do + return false; + } + } + if (this._dachsOn) { + // We are already running + return false; + } + + const dayType: TimeOfDay = TimeCallbackService.dayType(new SunTimeOffsets()); + + if ( + (dayType === TimeOfDay.Daylight || dayType === TimeOfDay.BeforeSunrise) && + action.newLevel > this.settings.batteryLevelTurnOnThreshold + ) { + // It is daytime (maybe solar power) and it is no critical battery level + return false; + } + + if (action.newLevel > this.settings.batteryLevelBeforeNightTurnOnThreshold) { + // It is not daylight but battery level is high enough + return false; + } + return true; + } }