diff --git a/assets/js/components/Loadpoint.vue b/assets/js/components/Loadpoint.vue index 04b869af8c..777d072aac 100644 --- a/assets/js/components/Loadpoint.vue +++ b/assets/js/components/Loadpoint.vue @@ -195,6 +195,7 @@ export default { guardAction: String, smartCostLimit: Number, smartCostType: String, + smartCostActive: Boolean, tariffGrid: Number, tariffCo2: Number, currency: String, diff --git a/assets/js/components/Loadpoints.vue b/assets/js/components/Loadpoints.vue index 0a03afb272..283060c6b8 100644 --- a/assets/js/components/Loadpoints.vue +++ b/assets/js/components/Loadpoints.vue @@ -15,6 +15,7 @@ :vehicles="vehicles" :smartCostLimit="smartCostLimit" :smartCostType="smartCostType" + :smartCostActive="smartCostActive" :tariffGrid="tariffGrid" :tariffCo2="tariffCo2" :currency="currency" @@ -51,6 +52,7 @@ export default { vehicles: Array, smartCostLimit: Number, smartCostType: String, + smartCostActive: Boolean, tariffGrid: Number, tariffCo2: Number, currency: String, diff --git a/assets/js/components/Site.vue b/assets/js/components/Site.vue index ed332cd0d5..642e46d157 100644 --- a/assets/js/components/Site.vue +++ b/assets/js/components/Site.vue @@ -23,6 +23,7 @@ :vehicles="vehicles" :smartCostLimit="smartCostLimit" :smartCostType="smartCostType" + :smartCostActive="smartCostActive" :tariffGrid="tariffGrid" :tariffCo2="tariffCo2" :currency="currency" @@ -103,6 +104,7 @@ export default { sponsorTokenExpires: Number, smartCostLimit: Number, smartCostType: String, + smartCostActive: Boolean, }, computed: { energyflow: function () { diff --git a/assets/js/components/Vehicle.vue b/assets/js/components/Vehicle.vue index 617f1e2b00..e9c5192b25 100644 --- a/assets/js/components/Vehicle.vue +++ b/assets/js/components/Vehicle.vue @@ -119,6 +119,7 @@ export default { climaterActive: Boolean, smartCostLimit: Number, smartCostType: String, + smartCostActive: Boolean, tariffGrid: Number, tariffCo2: Number, currency: String, diff --git a/assets/js/components/VehicleStatus.test.js b/assets/js/components/VehicleStatus.test.js index 7612c3b9d2..01ba809a16 100644 --- a/assets/js/components/VehicleStatus.test.js +++ b/assets/js/components/VehicleStatus.test.js @@ -207,8 +207,9 @@ describe("smart grid charging", () => { tariffCo2: 400, smartCostLimit: 500, smartCostType: "co2", + smartCostActive: true, }, - "cleanEnergyCharging" + `cleanEnergyCharging:{"co2":"400 g","limit":"500 g"}` ); }); test("show cheap energy message", () => { @@ -219,9 +220,10 @@ describe("smart grid charging", () => { charging: true, tariffGrid: 0.28, smartCostLimit: 0.29, - currency: "EUR", + currency: "CHF", + smartCostActive: true, }, - "cheapEnergyCharging" + `cheapEnergyCharging:{"price":"28,0 rp","limit":"29,0 rp"}` ); }); }); diff --git a/assets/js/components/VehicleStatus.vue b/assets/js/components/VehicleStatus.vue index 95529d07a0..4e212ace2e 100644 --- a/assets/js/components/VehicleStatus.vue +++ b/assets/js/components/VehicleStatus.vue @@ -28,8 +28,10 @@ export default { climaterActive: Boolean, smartCostLimit: Number, smartCostType: String, + smartCostActive: Boolean, tariffGrid: Number, tariffCo2: Number, + currency: String, }, computed: { phaseTimerActive() { @@ -46,9 +48,6 @@ export default { guardTimerActive() { return this.guardRemainingInterpolated > 0 && this.guardAction === "enable"; }, - isCo2() { - return this.smartCostType === CO2_TYPE; - }, message: function () { const t = (key, data) => { return this.$t(`main.vehicleStatus.${key}`, data); @@ -77,14 +76,17 @@ export default { } } - // clean energy - if (this.charging && this.isCo2 && this.tariffCo2 < this.smartCostLimit) { - return t("cleanEnergyCharging"); - } - - // cheap energy - if (this.charging && !this.isCo2 && this.tariffGrid < this.smartCostLimit) { - return t("cheapEnergyCharging"); + // clean or cheap energy + if (this.charging && this.smartCostActive) { + return this.smartCostType === CO2_TYPE + ? t("cleanEnergyCharging", { + co2: this.fmtCo2Short(this.tariffCo2), + limit: this.fmtCo2Short(this.smartCostLimit), + }) + : t("cheapEnergyCharging", { + price: this.fmtPricePerKWh(this.tariffGrid, this.currency, true), + limit: this.fmtPricePerKWh(this.smartCostLimit, this.currency, true), + }); } if (this.pvTimerActive && !this.enabled && this.pvAction === "enable") { diff --git a/core/site.go b/core/site.go index 7878fc9559..f59f73493d 100644 --- a/core/site.go +++ b/core/site.go @@ -758,6 +758,7 @@ func (site *Site) update(lp Updater) { if err == nil { limit := site.GetSmartCostLimit() autoCharge = limit != 0 && rate.Price <= limit + site.publish("smartCostActive", autoCharge) } else { site.log.ERROR.Println("tariff:", err) } @@ -802,6 +803,7 @@ func (site *Site) prepare() { site.publish("residualPower", site.ResidualPower) site.publish("smartCostLimit", site.SmartCostLimit) site.publish("smartCostType", nil) + site.publish("smartCostActive", false) if tariff := site.GetTariff(PlannerTariff); tariff != nil { site.publish("smartCostType", tariff.Type().String()) } diff --git a/i18n/de.toml b/i18n/de.toml index 8f9293b722..57ac6edaca 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -282,8 +282,8 @@ vehicleTarget = "Fahrzeuglimit: {soc}%" [main.vehicleStatus] charging = "Ladevorgang aktiv …" -cheapEnergyCharging = "Günstige Energie verfügbar. Ladevorgang aktiv …" -cleanEnergyCharging = "Saubere Energie verfügbar. Ladevorgang aktiv …" +cheapEnergyCharging = "Lade günstige Energie: {price} (Grenze < {limit})" +cleanEnergyCharging = "Lade saubere Energie: {co2} (Grenze < {limit})" climating = "Vorklimatisierung erkannt." connected = "Verbunden." disconnected = "Nicht verbunden." diff --git a/i18n/en.toml b/i18n/en.toml index 6430c9e688..f437018f6b 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -279,8 +279,8 @@ vehicleTarget = "Vehicle limit: {soc}%" [main.vehicleStatus] charging = "Charging…" -cheapEnergyCharging = "Cheap energy available. Charging…" -cleanEnergyCharging = "Clean energy available. Charging…" +cheapEnergyCharging = "Charging cheap energy: {price} (limit < {limit})" +cleanEnergyCharging = "Charging clean energy: {co2} (limit < {limit})" climating = "Pre-conditioning detected." connected = "Connected." disconnected = "Disconnected."