Forecast: solar adjust details (#19724)
This commit is contained in:
parent
10c0028a97
commit
5ef4b50e1f
13 changed files with 45 additions and 14 deletions
|
|
@ -396,7 +396,12 @@ export default {
|
|||
return !!this.forecast?.solar;
|
||||
},
|
||||
solarForecastRemainingToday() {
|
||||
return this.forecast?.solar?.today?.energy || undefined;
|
||||
if (!this.forecast?.solar) {
|
||||
return undefined;
|
||||
}
|
||||
const { today, scale } = this.forecast.solar || {};
|
||||
const factor = this.$hiddenFeatures() && settings.solarAdjusted && scale ? scale : 1;
|
||||
return today.energy * factor;
|
||||
},
|
||||
solarForecastIcon() {
|
||||
return this.solarForecastExists ? "forecast" : undefined;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
/>
|
||||
<div class="form-check-label">
|
||||
<label for="solarForecastAdjust"
|
||||
><small>🧪 {{ $t("forecast.solarAdjust") }}</small></label
|
||||
><small>🧪 {{ solarAdjustText }}</small></label
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -104,6 +104,17 @@ export default defineComponent({
|
|||
? adjustedSolar(this.forecast.solar)
|
||||
: this.forecast.solar;
|
||||
},
|
||||
solarAdjustText() {
|
||||
let percent = "";
|
||||
|
||||
const scale = this.forecast.solar?.scale;
|
||||
if (scale) {
|
||||
const percentDiff = scale * 100 - 100;
|
||||
percent = ` (${this.fmtPercentage(percentDiff, 0, true)})`;
|
||||
}
|
||||
|
||||
return this.$t("forecast.solarAdjust", { percent });
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
isModalVisible: function (newVal) {
|
||||
|
|
|
|||
|
|
@ -341,12 +341,13 @@ export default {
|
|||
}
|
||||
return result;
|
||||
},
|
||||
fmtPercentage: function (value, digits = 0) {
|
||||
return new Intl.NumberFormat(this.$i18n?.locale, {
|
||||
fmtPercentage: function (value, digits = 0, forceSign = false) {
|
||||
const sign = forceSign && value > 0 ? "+" : "";
|
||||
return `${sign}${new Intl.NumberFormat(this.$i18n?.locale, {
|
||||
style: "percent",
|
||||
minimumFractionDigits: digits,
|
||||
maximumFractionDigits: digits,
|
||||
}).format(value / 100);
|
||||
}).format(value / 100)}`;
|
||||
},
|
||||
hasLeadingPercentageSign: function () {
|
||||
return ["tr", "ar"].includes(this.$i18n?.locale);
|
||||
|
|
|
|||
|
|
@ -169,3 +169,17 @@ describe("getShortenedWeekdaysLabel", () => {
|
|||
expect(fmt.getShortenedWeekdaysLabel([0, 2, 3, 5, 6])).eq("Di, Mi, Fr – So");
|
||||
});
|
||||
});
|
||||
|
||||
describe("fmtPercentage", () => {
|
||||
test("should format percentage", () => {
|
||||
expect(fmt.fmtPercentage(0)).eq("0 %");
|
||||
expect(fmt.fmtPercentage(100)).eq("100 %");
|
||||
expect(fmt.fmtPercentage(100, 1)).eq("100,0 %");
|
||||
});
|
||||
test("should force signed", () => {
|
||||
expect(fmt.fmtPercentage(100, 0, true)).eq("+100 %");
|
||||
expect(fmt.fmtPercentage(100, 0, false)).eq("100 %");
|
||||
expect(fmt.fmtPercentage(-100, 0, true)).eq("-100 %");
|
||||
expect(fmt.fmtPercentage(-100, 0, false)).eq("-100 %");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ modalUpdateStatusStart = "Installation gestartet:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Vorhersage"
|
||||
solarAdjust = "Solarprognose anhand der realen Produktionsdaten anpassen."
|
||||
solarAdjust = "Solarprognose anhand der realen Produktionsdaten anpassen{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Durchschnitt"
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ modalUpdateStatusStart = "Installation started:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Forecast"
|
||||
solarAdjust = "Adjust solar forecast based on real production data."
|
||||
solarAdjust = "Adjust solar forecast based on real production data{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Average"
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ modalUpdateStatusStart = "L'installation a commencé:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Prévisions"
|
||||
solarAdjust = "Ajuster la prévision solaire basé sur la production réelle."
|
||||
solarAdjust = "Ajuster la prévision solaire basé sur la production réelle{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Moyenne"
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ modalUpdateStatusStart = "Installatioun ugefaang:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Prognose"
|
||||
solarAdjust = "Solarprognose unhand vun de reale Produktionsdaten upassen."
|
||||
solarAdjust = "Solarprognose unhand vun de reale Produktionsdaten upassen{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Moyenne"
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ modalUpdateStatusStart = "Instaliavimas pradėtas:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Prognozė"
|
||||
solarAdjust = "Pakoreguoti saulės prognozę remiantis faktiškais gamybos duomenimis."
|
||||
solarAdjust = "Pakoreguoti saulės prognozę remiantis faktiškais gamybos duomenimis{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Vidurkis"
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ modalUpdateStatusStart = "Instalação iniciada:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Previsões"
|
||||
solarAdjust = "Ajustar a previsão solar com base em dados reais de produção."
|
||||
solarAdjust = "Ajustar a previsão solar com base em dados reais de produção{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Média"
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ modalUpdateStatusStart = "Installationen har börjat:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Prognos"
|
||||
solarAdjust = "Justera solprognosen baserat på verkliga produktionsvärden."
|
||||
solarAdjust = "Justera solprognosen baserat på verkliga produktionsvärden{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Genomsnitt"
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ modalUpdateStatusStart = "Kurulum başladı:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "“Öngörü”"
|
||||
solarAdjust = "Güneş enerjisi tahminlerini gerçek üretim verilerine göre ayarla."
|
||||
solarAdjust = "Güneş enerjisi tahminlerini gerçek üretim verilerine göre ayarla{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "“Ortalama”"
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ modalUpdateStatusStart = "Встановлення розпочато:"
|
|||
|
||||
[forecast]
|
||||
modalTitle = "Прогноз"
|
||||
solarAdjust = "Скоригуйте сонячний прогноз на основі реальних даних виробництва."
|
||||
solarAdjust = "Скоригуйте сонячний прогноз на основі реальних даних виробництва{percent}."
|
||||
|
||||
[forecast.co2]
|
||||
average = "Середній"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue