From 536712dab34440611b4f907dfb4a80a59bd32eb8 Mon Sep 17 00:00:00 2001 From: Maschga <88616799+Maschga@users.noreply.github.com> Date: Wed, 4 Sep 2024 20:10:50 +0200 Subject: [PATCH] Add support for megawatt (#15818) --- assets/js/components/BatterySettingsModal.vue | 8 +- assets/js/components/ChargingPlan.vue | 2 +- assets/js/components/ChargingPlanPreview.vue | 2 +- .../components/ChargingPlanSettingsEntry.vue | 2 +- assets/js/components/ChargingPlanWarnings.vue | 4 +- assets/js/components/ChargingSessionModal.vue | 17 +++- assets/js/components/Config/DeviceTags.vue | 8 +- .../js/components/Energyflow/Energyflow.vue | 33 ++++--- .../components/Energyflow/EnergyflowEntry.vue | 4 +- .../components/Energyflow/Visualization.vue | 8 +- assets/js/components/LimitEnergySelect.vue | 4 +- assets/js/components/Loadpoint.vue | 8 +- .../js/components/LoadpointSettingsModal.vue | 8 +- assets/js/components/Savings.vue | 14 ++- assets/js/components/Vehicle.vue | 5 +- assets/js/mixins/formatter.js | 44 ++++++--- assets/js/mixins/formatter.test.js | 91 +++++++++++++------ assets/js/utils/energyOptions.js | 10 +- assets/js/views/ChargingSessions.vue | 6 +- 19 files changed, 179 insertions(+), 99 deletions(-) diff --git a/assets/js/components/BatterySettingsModal.vue b/assets/js/components/BatterySettingsModal.vue index a5554035b..edc5916f7 100644 --- a/assets/js/components/BatterySettingsModal.vue +++ b/assets/js/components/BatterySettingsModal.vue @@ -256,7 +256,7 @@ import "@h2d2/shopicons/es/regular/home"; import SmartCostLimit from "./SmartCostLimit.vue"; import CustomSelect from "./CustomSelect.vue"; import GenericModal from "./GenericModal.vue"; -import formatter from "../mixins/formatter"; +import formatter, { POWER_UNIT } from "../mixins/formatter"; import collector from "../mixins/collector"; import api from "../api"; import smartCostAvailable from "../utils/smartCostAvailable"; @@ -363,13 +363,13 @@ export default { .filter(({ capacity }) => capacity > 0) .map(({ soc, capacity }) => { const multipleBatteries = this.battery.length > 1; - const energy = this.fmtKWh( + const energy = this.fmtWh( (capacity / 100) * soc * 1e3, - true, + POWER_UNIT.KW, !multipleBatteries, 1 ); - const total = this.fmtKWh(capacity * 1e3, true, true, 1); + const total = this.fmtWh(capacity * 1e3, POWER_UNIT.KW, true, 1); const name = multipleBatteries ? "↳ " : ""; const formattedSoc = multipleBatteries ? ` (${this.fmtSoc(soc)})` : ""; const formattedEnergy = this.$t("batterySettings.capacity", { diff --git a/assets/js/components/ChargingPlan.vue b/assets/js/components/ChargingPlan.vue index cf7400836..94cc8c29a 100644 --- a/assets/js/components/ChargingPlan.vue +++ b/assets/js/components/ChargingPlan.vue @@ -196,7 +196,7 @@ export default { return fmtEnergy( this.planEnergy, optionStep(this.capacity || 100), - this.fmtKWh, + this.fmtWh, this.$t("main.targetEnergy.noLimit") ); }, diff --git a/assets/js/components/ChargingPlanPreview.vue b/assets/js/components/ChargingPlanPreview.vue index bc22005f2..dcddc3824 100644 --- a/assets/js/components/ChargingPlanPreview.vue +++ b/assets/js/components/ChargingPlanPreview.vue @@ -69,7 +69,7 @@ export default { }, fmtPower() { if (this.duration > 0 && this.power > 0) { - return `@ ${this.fmtKw(this.power)}`; + return `@ ${this.fmtW(this.power)}`; } return null; }, diff --git a/assets/js/components/ChargingPlanSettingsEntry.vue b/assets/js/components/ChargingPlanSettingsEntry.vue index 50bfd04de..ff37f27ec 100644 --- a/assets/js/components/ChargingPlanSettingsEntry.vue +++ b/assets/js/components/ChargingPlanSettingsEntry.vue @@ -175,7 +175,7 @@ export default { 0, this.capacity || 100, this.socPerKwh, - this.fmtKWh, + this.fmtWh, this.fmtPercentage, "-" ); diff --git a/assets/js/components/ChargingPlanWarnings.vue b/assets/js/components/ChargingPlanWarnings.vue index 619bf863e..d44914342 100644 --- a/assets/js/components/ChargingPlanWarnings.vue +++ b/assets/js/components/ChargingPlanWarnings.vue @@ -100,13 +100,13 @@ export default { if (this.socBasedPlanning) { return this.fmtSoc(this.effectiveLimitSoc); } - return this.fmtKWh(this.limitEnergy * 1e3); + return this.fmtWh(this.limitEnergy * 1e3); }, goalFmt: function () { if (this.socBasedPlanning) { return this.fmtSoc(this.effectivePlanSoc); } - return this.fmtKWh(this.planEnergy * 1e3); + return this.fmtWh(this.planEnergy * 1e3); }, costLimitExists: function () { return this.smartCostLimit !== 0; diff --git a/assets/js/components/ChargingSessionModal.vue b/assets/js/components/ChargingSessionModal.vue index a712cb765..213c5d363 100644 --- a/assets/js/components/ChargingSessionModal.vue +++ b/assets/js/components/ChargingSessionModal.vue @@ -68,10 +68,17 @@ {{ $t("sessions.energy") }}