Skip to content

Commit

Permalink
remove boost limit
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis committed Oct 15, 2024
1 parent 686f810 commit 7ef2870
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 188 deletions.
13 changes: 1 addition & 12 deletions assets/js/components/Loadpoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
@mincurrent-updated="setMinCurrent"
@phasesconfigured-updated="setPhasesConfigured"
@batteryboost-updated="setBatteryBoost"
@batteryboostlimit-updated="setBatteryBoostLimit"
/>

<div
Expand Down Expand Up @@ -135,9 +134,7 @@ export default {
chargeDuration: Number,
charging: Boolean,
batteryBoost: Boolean,
batteryBoostLimit: Number,
batteryConfigured: Boolean,
batterySoc: Number,
// session
sessionEnergy: Number,
Expand Down Expand Up @@ -283,12 +280,7 @@ export default {
return this.batteryConfigured && this.$hiddenFeatures();
},
batteryBoostActive: function () {
return (
this.batteryBoost &&
this.charging &&
this.batterySoc > this.batteryBoostLimit &&
!["off", "now"].includes(this.mode)
);
return this.batteryBoost && this.charging && !["off", "now"].includes(this.mode);
},
},
watch: {
Expand Down Expand Up @@ -356,9 +348,6 @@ export default {
setBatteryBoost: function (batteryBoost) {
api.post(this.apiPath("batteryboost") + `/${batteryBoost ? "1" : "0"}`);
},
setBatteryBoostLimit: function (batteryBoostLimit) {
api.post(this.apiPath("batteryboostlimit") + `/${batteryBoostLimit}`);
},
fmtPower(value) {
return this.fmtW(value, POWER_UNIT.AUTO);
},
Expand Down
52 changes: 4 additions & 48 deletions assets/js/components/LoadpointSettingsBatteryBoost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,9 @@
@change="handleEnabledChange"
/>
<label :for="formId('batteryBoost')" class="form-check-label">
<i18n-t
keypath="main.loadpointSettings.batteryBoost.description"
tag="div"
scope="global"
>
<template #limit>
<div class="custom-select-inline" @click.prevent="() => {}">
<CustomSelect
:id="formId('batteryBoostLimit')"
:options="limitOptions"
:selected="selectedLimit"
@change="handleLimitChange"
>
<span class="text-decoration-underline">
{{ fmtPercentage(selectedLimit) }}
</span>
</CustomSelect>
</div>
</template>
</i18n-t>
<div>
{{ $t("main.loadpointSettings.batteryBoost.description") }}
</div>
<span v-if="selectedEnabled && !disabled" class="d-block text-primary">
{{ $t("main.loadpointSettings.batteryBoost.once") }}
</span>
Expand All @@ -54,37 +37,26 @@
</template>

<script>
import CustomSelect from "./CustomSelect.vue";
import formatter from "../mixins/formatter";
export default {
components: { CustomSelect },
mixins: [formatter],
props: {
formId: Function,
batterySoc: Number,
mode: String,
batteryBoost: Boolean,
batteryBoostLimit: Number,
},
data() {
return {
selectedEnabled: this.batteryBoost,
selectedLimit: this.batteryBoostLimit,
};
},
watch: {
batteryBoost(newVal) {
this.selectedEnabled = newVal;
},
batteryBoostLimit(newVal) {
this.selectedLimit = newVal;
},
},
computed: {
limitOptions() {
return this.range(95, 0, -5).map((value) => this.limitOption(value));
},
disabled() {
return ["off", "now"].includes(this.mode);
},
Expand All @@ -93,23 +65,7 @@ export default {
handleEnabledChange() {
this.$emit("batteryboost-updated", this.selectedEnabled);
},
handleLimitChange($event) {
this.selectedLimit = parseInt($event.target.value);
this.$emit("batteryboostlimit-updated", this.selectedLimit);
},
range(start, stop, step = -1) {
return Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step);
},
limitOption(value) {
return { value, name: this.fmtPercentage(value), disabled: value > this.batterySoc };
},
},
emits: ["batteryboost-updated", "batteryboostlimit-updated"],
emits: ["batteryboost-updated"],
};
</script>

<style scoped>
.custom-select-inline {
display: inline-block !important;
}
</style>
7 changes: 0 additions & 7 deletions assets/js/components/LoadpointSettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
v-bind="batteryBoostProps"
class="mt-2"
@batteryboost-updated="changeBatteryBoost"
@batteryboostlimit-updated="changeBatteryBoostLimit"
/>
<h6>
{{ $t("main.loadpointSettings.currents") }}
Expand Down Expand Up @@ -190,8 +189,6 @@ export default {
batteryBoost: Boolean,
batteryBoostAvailable: Boolean,
mode: String,
batteryBoostLimit: Number,
batterySoc: Number,
minSoc: Number,
maxCurrent: Number,
minCurrent: Number,
Expand All @@ -207,7 +204,6 @@ export default {
"maxcurrent-updated",
"mincurrent-updated",
"batteryboost-updated",
"batteryboostlimit-updated",
],
data() {
return {
Expand Down Expand Up @@ -331,9 +327,6 @@ export default {
modalInvisible() {
this.isModalVisible = false;
},
changeBatteryBoostLimit(limit) {
this.$emit("batteryboostlimit-updated", limit);
},
changeBatteryBoost(boost) {
this.$emit("batteryboost-updated", boost);
},
Expand Down
2 changes: 0 additions & 2 deletions assets/js/components/Loadpoints.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
:gridConfigured="gridConfigured"
:pvConfigured="pvConfigured"
:batteryConfigured="batteryConfigured"
:batterySoc="batterySoc"
class="h-100"
:class="{ 'loadpoint-unselected': !selected(index) }"
@click="scrollTo(index)"
Expand Down Expand Up @@ -74,7 +73,6 @@ export default {
gridConfigured: Boolean,
pvConfigured: Boolean,
batteryConfigured: Boolean,
batterySoc: Number,
},
data() {
return { selectedIndex: 0, snapTimeout: null };
Expand Down
1 change: 0 additions & 1 deletion assets/js/components/Vehicle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export default {
effectivePlanSoc: Number,
effectivePlanTime: String,
batteryBoostActive: Boolean,
batteryBoostLimit: Number,
enabled: Boolean,
heating: Boolean,
id: [String, Number],
Expand Down
4 changes: 1 addition & 3 deletions assets/js/components/VehicleStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export default {
props: {
vehicleSoc: Number,
batteryBoostActive: Boolean,
batteryBoostLimit: Number,
charging: Boolean,
chargingPlanDisabled: Boolean,
chargerStatusReason: String,
Expand Down Expand Up @@ -423,8 +422,7 @@ export default {
if (!this.batteryBoostVisible) {
return "";
}
const limit = this.fmtPercentage(this.batteryBoostLimit);
return this.$t("main.vehicleStatus.batteryBoost", { limit });
return this.$t("main.vehicleStatus.batteryBoost");
},
planStartTooltipContent() {
if (!this.planStartVisible) {
Expand Down
27 changes: 13 additions & 14 deletions core/keys/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ package keys

const (
// loadpoint settings
Title = "title" // loadpoint title
Mode = "mode" // charge mode
Priority = "priority" // priority
MinCurrent = "minCurrent" // min current
MaxCurrent = "maxCurrent" // max current
MinSoc = "minSoc" // min soc
LimitSoc = "limitSoc" // limit soc
LimitEnergy = "limitEnergy" // limit energy
EnableThreshold = "enableThreshold"
DisableThreshold = "disableThreshold"
EnableDelay = "enableDelay"
DisableDelay = "disableDelay"
BatteryBoost = "batteryBoost" // boost enabled
BatteryBoostLimit = "batteryBoostLimit" // home battery limit
Title = "title" // loadpoint title
Mode = "mode" // charge mode
Priority = "priority" // priority
MinCurrent = "minCurrent" // min current
MaxCurrent = "maxCurrent" // max current
MinSoc = "minSoc" // min soc
LimitSoc = "limitSoc" // limit soc
LimitEnergy = "limitEnergy" // limit energy
EnableThreshold = "enableThreshold"
DisableThreshold = "disableThreshold"
EnableDelay = "enableDelay"
DisableDelay = "disableDelay"
BatteryBoost = "batteryBoost"

PhasesConfigured = "phasesConfigured" // configured phases (1/3, 0 for auto on 1p3p chargers, nil for plain chargers)
PhasesEnabled = "phasesEnabled" // enabled phases (1/3)
Expand Down
38 changes: 15 additions & 23 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,13 @@ type Loadpoint struct {
MinCurrent_ float64 `mapstructure:"minCurrent"`
MaxCurrent_ float64 `mapstructure:"maxCurrent"`

minCurrent float64 // PV mode: start current Min+PV mode: min current
maxCurrent float64 // Max allowed current. Physically ensured by the charger
configuredPhases int // Charger configured phase mode 0/1/3
limitSoc int // Session limit for soc
limitEnergy float64 // Session limit for energy
smartCostLimit *float64 // always charge if cost is below this value
batteryBoost int // battery boost state
batteryBoostLimit float64 // battery boost home battery limit
minCurrent float64 // PV mode: start current Min+PV mode: min current
maxCurrent float64 // Max allowed current. Physically ensured by the charger
configuredPhases int // Charger configured phase mode 0/1/3
limitSoc int // Session limit for soc
limitEnergy float64 // Session limit for energy
smartCostLimit *float64 // always charge if cost is below this value
batteryBoost int // battery boost state

mode api.ChargeMode
enabled bool // Charger enabled state
Expand Down Expand Up @@ -346,9 +345,6 @@ func (lp *Loadpoint) restoreSettings() {
if v, err := lp.settings.Float(keys.SmartCostLimit); err == nil {
lp.SetSmartCostLimit(&v)
}
if v, err := lp.settings.Float(keys.BatteryBoostLimit); err == nil {
lp.SetBatteryBoostLimit(v)
}

t, err1 := lp.settings.Time(keys.PlanTime)
v, err2 := lp.settings.Float(keys.PlanEnergy)
Expand Down Expand Up @@ -672,7 +668,6 @@ func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Even

// battery boost
lp.publish(keys.BatteryBoost, lp.batteryBoost != boostDisabled)
lp.publish(keys.BatteryBoostLimit, lp.batteryBoostLimit)

// read initial charger state to prevent immediately disabling charger
if enabled, err := lp.charger.Enabled(); err == nil {
Expand Down Expand Up @@ -1299,9 +1294,9 @@ func (lp *Loadpoint) publishTimer(name string, delay time.Duration, action strin
}

// boostPower returns the additional power that the loadpoint should draw from the battery
func (lp *Loadpoint) boostPower(batteryBoostPower float64, boostConditions bool) float64 {
func (lp *Loadpoint) boostPower(batteryBoostPower float64) float64 {
boost := lp.getBatteryBoost()
if boost == boostDisabled || !boostConditions {
if boost == boostDisabled {
return 0
}

Expand All @@ -1322,22 +1317,19 @@ func (lp *Loadpoint) boostPower(batteryBoostPower float64, boostConditions bool)
}

res := batteryBoostPower + delta
lp.log.DEBUG.Printf("pv charge battery boost: %.0fW = -%.0fW battery - %.0fW boost (soc > %.0f%%", -res, batteryBoostPower, delta, lp.GetBatteryBoostLimit())
lp.log.DEBUG.Printf("pv charge battery boost: %.0fW = -%.0fW battery - %.0fW boost", -res, batteryBoostPower, delta)

return res
}

// pvMaxCurrent calculates the maximum target current for PV mode
func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower, batteryBoostPower, batterySoc float64, batteryStart bool) float64 {
func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower, batteryBoostPower float64, batteryStart bool) float64 {
// read only once to simplify testing
minCurrent := lp.effectiveMinCurrent()
maxCurrent := lp.effectiveMaxCurrent()
boostLimit := lp.GetBatteryBoostLimit()

boostConditions := boostLimit > batterySoc

// push demand to drain battery
sitePower -= lp.boostPower(batteryBoostPower, boostConditions)
sitePower -= lp.boostPower(batteryBoostPower)

// switch phases up/down
var scaledTo int
Expand All @@ -1356,7 +1348,7 @@ func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower, batteryBoostPo
targetCurrent := max(effectiveCurrent+deltaCurrent, 0)

// in MinPV mode or under special conditions return at least minCurrent
if battery := batteryStart || boostConditions && lp.charging(); (mode == api.ModeMinPV || battery) && targetCurrent < minCurrent {
if battery := batteryStart && lp.charging(); (mode == api.ModeMinPV || battery) && targetCurrent < minCurrent {
lp.log.DEBUG.Printf("pv charge current: min %.3gA > %.3gA (%.0fW @ %dp, battery: %t)", minCurrent, targetCurrent, sitePower, activePhases, battery)
return minCurrent
}
Expand Down Expand Up @@ -1716,7 +1708,7 @@ func (lp *Loadpoint) phaseSwitchCompleted() bool {
}

// Update is the main control function. It reevaluates meters and charger state
func (lp *Loadpoint) Update(sitePower, batteryBoostPower float64, rates api.Rates, batterySoc float64, batteryStart bool, greenShare float64, effPrice, effCo2 *float64) {
func (lp *Loadpoint) Update(sitePower, batteryBoostPower float64, rates api.Rates, batteryStart bool, greenShare float64, effPrice, effCo2 *float64) {
// smart cost
smartCostActive := lp.smartCostActive(rates)
lp.publish(keys.SmartCostActive, smartCostActive)
Expand Down Expand Up @@ -1841,7 +1833,7 @@ func (lp *Loadpoint) Update(sitePower, batteryBoostPower float64, rates api.Rate
break
}

targetCurrent := lp.pvMaxCurrent(mode, sitePower, batteryBoostPower, batterySoc, batteryStart)
targetCurrent := lp.pvMaxCurrent(mode, sitePower, batteryBoostPower, batteryStart)

if targetCurrent == 0 && lp.vehicleClimateActive() {
targetCurrent = lp.effectiveMinCurrent()
Expand Down
4 changes: 0 additions & 4 deletions core/loadpoint/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ type API interface {
GetBatteryBoost() bool
// SetBatteryBoost sets the battery boost
SetBatteryBoost(enable bool) error
// GetBatteryBoostLimit returns the battery boost limit
GetBatteryBoostLimit() float64
// SetBatteryBoostLimit sets the battery boost limit
SetBatteryBoostLimit(limit float64)

// RemoteControl sets remote status demand
RemoteControl(string, RemoteDemand)
Expand Down
20 changes: 0 additions & 20 deletions core/loadpoint_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,26 +361,6 @@ func (lp *Loadpoint) SetBatteryBoost(enable bool) error {
return nil
}

// GetBatteryBoostLimit gets the battery boost limit
func (lp *Loadpoint) GetBatteryBoostLimit() float64 {
lp.RLock()
defer lp.RUnlock()
return lp.batteryBoostLimit
}

// SetBatteryBoostLimit sets the battery boost limit
func (lp *Loadpoint) SetBatteryBoostLimit(limit float64) {
lp.Lock()
defer lp.Unlock()

// write to settings
lp.settings.SetInt(keys.BatteryBoostLimit, int64(limit))

// apply immediately
lp.batteryBoostLimit = limit
lp.publish(keys.BatteryBoostLimit, limit)
}

// RemoteControl sets remote status demand
func (lp *Loadpoint) RemoteControl(source string, demand loadpoint.RemoteDemand) {
lp.Lock()
Expand Down
Loading

0 comments on commit 7ef2870

Please sign in to comment.