diff --git a/assets/js/components/Loadpoint.vue b/assets/js/components/Loadpoint.vue
index b79270b07..45b3ef944 100644
--- a/assets/js/components/Loadpoint.vue
+++ b/assets/js/components/Loadpoint.vue
@@ -64,7 +64,7 @@ export default {
vehiclePresent: Boolean,
climater: String,
range: Number,
- chargeEstimate: Number,
+ chargeRemainingDuration: Number,
// other information
phases: Number,
diff --git a/assets/js/components/LoadpointDetails.stories.js b/assets/js/components/LoadpointDetails.stories.js
index 17f0f42e6..5396ec845 100644
--- a/assets/js/components/LoadpointDetails.stories.js
+++ b/assets/js/components/LoadpointDetails.stories.js
@@ -32,7 +32,7 @@ Vehicle.args = {
chargedEnergy: 11e3,
chargeDuration: 95 * 60,
vehiclePresent: true,
- chargeEstimate: 5 * 3600,
+ chargeRemainingDuration: 5 * 3600,
};
export const VehicleRange = Template.bind({});
@@ -42,7 +42,7 @@ VehicleRange.args = {
chargeDuration: 95 * 60,
vehiclePresent: true,
range: 240.123,
- chargeEstimate: 5 * 3600,
+ chargeRemainingDuration: 5 * 3600,
};
export const VehicleClimater = Template.bind({});
@@ -52,7 +52,7 @@ VehicleClimater.args = {
chargeDuration: 95 * 60,
vehiclePresent: true,
range: 240.123,
- chargeEstimate: 5 * 3600,
+ chargeRemainingDuration: 5 * 3600,
climater: "on",
};
@@ -63,7 +63,7 @@ VehicleTimer.args = {
chargeDuration: 95 * 60,
vehiclePresent: true,
range: 240.123,
- chargeEstimate: 5 * 3600,
+ chargeRemainingDuration: 5 * 3600,
timerSet: true,
timerActive: true,
};
diff --git a/assets/js/components/LoadpointDetails.vue b/assets/js/components/LoadpointDetails.vue
index b00760a08..60061fab2 100644
--- a/assets/js/components/LoadpointDetails.vue
+++ b/assets/js/components/LoadpointDetails.vue
@@ -53,8 +53,10 @@
{{ $t("main.loadpointDetails.remaining") }}
- {{ fmtShortDuration(chargeEstimate) }}
- {{ fmtShortDurationUnit(chargeEstimate) }}
+ {{ fmtShortDuration(chargeRemainingDuration) }}
+ {{
+ fmtShortDurationUnit(chargeRemainingDuration)
+ }}
@@ -70,7 +72,7 @@ export default {
props: {
chargedEnergy: Number,
chargeDuration: Number,
- chargeEstimate: Number,
+ chargeRemainingDuration: Number,
chargePower: Number,
climater: String,
vehiclePresent: Boolean,
diff --git a/assets/js/components/Site.stories.js b/assets/js/components/Site.stories.js
index f9854e62e..b6304485f 100644
--- a/assets/js/components/Site.stories.js
+++ b/assets/js/components/Site.stories.js
@@ -47,7 +47,7 @@ Single.args = {
vehicleSoc: 66,
targetSoC: 90,
range: 344,
- chargeEstimate: 999,
+ chargeRemainingDuration: 999,
chargePower: 11232,
chargeDuration: 123982,
chargedEnergy: 23213,
@@ -76,7 +76,7 @@ Multi.args = {
vehicleSoc: 66,
targetSoC: 90,
range: 344,
- chargeEstimate: 999,
+ chargeRemainingDuration: 999,
chargePower: 11232,
chargeDuration: 123982,
chargedEnergy: 23213,
@@ -96,7 +96,7 @@ Multi.args = {
socCharge: 22,
targetSoC: 100,
range: 34,
- chargeEstimate: 22,
+ chargeRemainingDuration: 22,
chargePower: 1423,
chargeDuration: 243,
chargedEnergy: 235,
diff --git a/core/loadpoint.go b/core/loadpoint.go
index c2694b1c3..93c52d21c 100644
--- a/core/loadpoint.go
+++ b/core/loadpoint.go
@@ -129,9 +129,12 @@ type LoadPoint struct {
pvTimer time.Time // PV enabled/disable timer
phaseTimer time.Time // 1p3p switch timer
- vehicleSoc float64 // Vehicle SoC
- chargedEnergy float64 // Charged energy while connected in Wh
- chargeDuration time.Duration // Charge duration
+ // charge progress
+ vehicleSoc float64 // Vehicle SoC
+ chargeDuration time.Duration // Charge duration
+ chargedEnergy float64 // Charged energy while connected in Wh
+ chargeRemainingDuration time.Duration // Remaining charge duration
+ chargeRemainingEnergy float64 // Remaining charge energy in Wh
tasks []func() error // task list for repeated execution
}
@@ -1158,14 +1161,13 @@ func (lp *LoadPoint) publishSoCAndRange() {
lp.log.DEBUG.Printf("vehicle soc: %.0f%%", lp.vehicleSoc)
lp.publish("vehicleSoc", lp.vehicleSoc)
- chargeEstimate := time.Duration(-1)
if lp.charging() {
- chargeEstimate = lp.socEstimator.RemainingChargeDuration(lp.chargePower, lp.SoC.Target)
+ lp.setRemainingDuration(lp.socEstimator.RemainingChargeDuration(lp.chargePower, lp.SoC.Target))
+ } else {
+ lp.setRemainingDuration(-1)
}
- lp.publish("chargeEstimate", chargeEstimate)
- chargeRemainingEnergy := 1e3 * lp.socEstimator.RemainingChargeEnergy(lp.SoC.Target)
- lp.publish("chargeRemainingEnergy", chargeRemainingEnergy)
+ lp.setRemainingEnergy(1e3 * lp.socEstimator.RemainingChargeEnergy(lp.SoC.Target))
} else {
if errors.Is(err, api.ErrMustRetry) {
lp.socUpdated = time.Time{}
@@ -1188,7 +1190,7 @@ func (lp *LoadPoint) publishSoCAndRange() {
// reset if poll: connected/charging and not connected
if lp.SoC.Poll.Mode != pollAlways && !lp.connected() {
lp.publish("vehicleSoc", -1)
- lp.publish("chargeEstimate", time.Duration(-1))
+ lp.publish("chargeRemainingDuration", time.Duration(-1))
// range
lp.publish("range", -1)
diff --git a/core/loadpoint/api.go b/core/loadpoint/api.go
index 8a9293f27..8521e7e7a 100644
--- a/core/loadpoint/api.go
+++ b/core/loadpoint/api.go
@@ -13,31 +13,69 @@ type Controller interface {
// API is the external loadpoint API
type API interface {
+ // Name returns the defined loadpoint name
Name() string
+ // HasChargeMeter determines if a physical charge meter is attached
HasChargeMeter() bool
+ //
// status
+ //
+
+ // GetStatus returns the charging status
GetStatus() api.ChargeStatus
+ //
// settings
+ //
+
+ // GetMode returns the charge mode
GetMode() api.ChargeMode
+ // SetMode sets the charge mode
SetMode(api.ChargeMode)
+ // GetTargetSoC returns the charge target soc
GetTargetSoC() int
+ // SetTargetSoC sets the charge target soc
SetTargetSoC(int) error
+ // GetMinSoC returns the charge minimum soc
GetMinSoC() int
+ // SetMinSoC sets the charge minimum soc
SetMinSoC(int) error
+ // GetPhases returns the enabled phases
GetPhases() int
+ // SetPhases sets the enabled phases
SetPhases(int) error
+ // SetTargetCharge sets the charge targetSoC
SetTargetCharge(time.Time, int)
+ // RemoteControl sets remote status demand
RemoteControl(string, RemoteDemand)
- // energy
+ //
+ // power and energy
+ //
+
+ // GetChargePower returns the current charging power
GetChargePower() float64
+ // GetMinCurrent returns the min charging current
GetMinCurrent() float64
+ // SetMinCurrent returns the min charging current
SetMinCurrent(float64)
+ // GetMaxCurrent returns the max charging current
GetMaxCurrent() float64
+ // SetMaxCurrent returns the max charging current
SetMaxCurrent(float64)
+ // GetMinPower returns the min charging power for a single phase
GetMinPower() float64
+ // GetMaxPower returns the max charging power taking active phases into account
GetMaxPower() float64
+
+ //
+ // charge progress
+ //
+
+ // GetRemainingDuration is the estimated remaining charging duration
+ GetRemainingDuration() time.Duration
+ // GetRemainingEnergy is the remaining charge energy in Wh
+ GetRemainingEnergy() float64
}
diff --git a/core/loadpoint_api.go b/core/loadpoint_api.go
index 155d807ed..8690ab001 100644
--- a/core/loadpoint_api.go
+++ b/core/loadpoint_api.go
@@ -206,3 +206,39 @@ func (lp *LoadPoint) GetMinPower() float64 {
func (lp *LoadPoint) GetMaxPower() float64 {
return Voltage * lp.GetMaxCurrent() * float64(lp.GetPhases())
}
+
+// setRemainingDuration sets the estimated remaining charging duration
+func (lp *LoadPoint) setRemainingDuration(chargeRemainingDuration time.Duration) {
+ lp.Lock()
+ defer lp.Unlock()
+
+ if lp.chargeRemainingDuration != chargeRemainingDuration {
+ lp.chargeRemainingDuration = chargeRemainingDuration
+ lp.publish("chargeRemainingDuration", chargeRemainingDuration)
+ }
+}
+
+// GetRemainingDuration is the estimated remaining charging duration
+func (lp *LoadPoint) GetRemainingDuration() time.Duration {
+ lp.Lock()
+ defer lp.Unlock()
+ return lp.chargeRemainingDuration
+}
+
+// setRemainingEnergy sets the remaining charge energy in Wh
+func (lp *LoadPoint) setRemainingEnergy(chargeRemainingEnergy float64) {
+ lp.Lock()
+ defer lp.Unlock()
+
+ if lp.chargeRemainingEnergy != chargeRemainingEnergy {
+ lp.chargeRemainingEnergy = chargeRemainingEnergy
+ lp.publish("chargeRemainingEnergy", chargeRemainingEnergy)
+ }
+}
+
+// GetRemainingEnergy is the remaining charge energy in Wh
+func (lp *LoadPoint) GetRemainingEnergy() float64 {
+ lp.Lock()
+ defer lp.Unlock()
+ return lp.chargeRemainingEnergy
+}
diff --git a/dist/index.html b/dist/index.html
index 5b307b143..db9709e2b 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -1,4 +1,4 @@
-evcc
\ No newline at end of file
+ };