diff --git a/assets/js/components/Battery/BatteryExperimental.vue b/assets/js/components/Battery/BatteryExperimental.vue index 187defdd5..e70144406 100644 --- a/assets/js/components/Battery/BatteryExperimental.vue +++ b/assets/js/components/Battery/BatteryExperimental.vue @@ -117,8 +117,8 @@ export default defineComponent({ return this.gridChargePossible || this.gridChargeLimit !== null; }, gridChargeTariff() { - const { forecast, smartCostType } = this.state; - return smartCostType === SMART_COST_TYPE.CO2 ? forecast?.co2 : forecast?.grid; + const { co2, grid } = store.uiForecast.value; + return this.state.smartCostType === SMART_COST_TYPE.CO2 ? co2 : grid; }, smartCostLimitProps() { return { diff --git a/assets/js/components/BottomTabs/Bar.vue b/assets/js/components/BottomTabs/Bar.vue index 15085db8a..ca456f318 100644 --- a/assets/js/components/BottomTabs/Bar.vue +++ b/assets/js/components/BottomTabs/Bar.vue @@ -53,7 +53,6 @@ import MoreItem from "./MoreItem.vue"; import { defineComponent, type PropType } from "vue"; import type { FatalError, - Forecast, Sponsor, EvOpt, AuthProviders, @@ -74,7 +73,6 @@ export default defineComponent({ battery: { type: Object as PropType }, batteryGridChargeActive: Boolean, batteryMode: { type: String as PropType }, - forecast: { type: Object as PropType }, vehicles: { type: Object as PropType>, default: () => ({}) }, authProviders: { type: Object as PropType, default: () => ({}) }, sponsor: { type: Object as PropType, default: () => ({}) }, diff --git a/assets/js/components/ChargingPlans/ChargingPlan.vue b/assets/js/components/ChargingPlans/ChargingPlan.vue index 96eeda0bc..2c6c29c66 100644 --- a/assets/js/components/ChargingPlans/ChargingPlan.vue +++ b/assets/js/components/ChargingPlans/ChargingPlan.vue @@ -38,7 +38,7 @@ import formatter from "@/mixins/formatter"; import minuteTicker from "@/mixins/minuteTicker"; import { optionStep, fmtEnergy } from "@/utils/energyOptions.ts"; import { defineComponent, type PropType } from "vue"; -import type { CURRENCY, Forecast, PlanStrategy, Vehicle } from "@/types/evcc"; +import type { CURRENCY, UiForecast, PlanStrategy, Vehicle } from "@/types/evcc"; export default defineComponent({ name: "ChargingPlan", @@ -71,7 +71,7 @@ export default defineComponent({ vehicleSoc: Number, vehicleLimitSoc: Number, vehicleNotReachable: Boolean, - forecast: Object as PropType, + forecast: Object as PropType, }, emits: ["open-modal"], data() { diff --git a/assets/js/components/ChargingPlans/ChargingPlanModal.vue b/assets/js/components/ChargingPlans/ChargingPlanModal.vue index 9a4784ebe..ba86cf036 100644 --- a/assets/js/components/ChargingPlans/ChargingPlanModal.vue +++ b/assets/js/components/ChargingPlans/ChargingPlanModal.vue @@ -48,7 +48,7 @@ import PlansSettings from "./PlansSettings.vue"; import api from "@/api"; import type { CURRENCY, - Forecast, + UiForecast, PlanStrategy, RepeatingPlan, SMART_COST_TYPE, @@ -70,7 +70,7 @@ export default defineComponent({ vehicles: { type: Array as PropType, default: () => [] }, smartCostType: String as PropType, currency: String as PropType, - forecast: Object as PropType, + forecast: Object as PropType, }, data() { return { diff --git a/assets/js/components/ChargingPlans/PlansSettings.vue b/assets/js/components/ChargingPlans/PlansSettings.vue index 0f28eb8ff..fe71da0c2 100644 --- a/assets/js/components/ChargingPlans/PlansSettings.vue +++ b/assets/js/components/ChargingPlans/PlansSettings.vue @@ -73,7 +73,7 @@ import { debounceLeading } from "@/utils/debounceLeading"; import { defineComponent, type PropType } from "vue"; import type { CURRENCY, - Forecast, + UiForecast, PlanResponse, PlanStrategy, PlanWrapper, @@ -115,7 +115,7 @@ export default defineComponent({ vehicle: Object as PropType, vehicleLimitSoc: Number, planOverrun: Number, - forecast: Object as PropType, + forecast: Object as PropType, }, emits: [ "static-plan-removed", diff --git a/assets/js/components/Energyflow/Energyflow.vue b/assets/js/components/Energyflow/Energyflow.vue index 4ced5d80e..6113693ec 100644 --- a/assets/js/components/Energyflow/Energyflow.vue +++ b/assets/js/components/Energyflow/Energyflow.vue @@ -328,7 +328,7 @@ import { type Battery, type Meter, type CURRENCY, - type Forecast, + type UiForecast, type UiLoadpoint, } from "@/types/evcc"; @@ -371,7 +371,7 @@ export default defineComponent({ prioritySoc: { type: Number }, bufferSoc: { type: Number }, bufferStartSoc: { type: Number }, - forecast: { type: Object as PropType, default: () => ({}) }, + forecast: { type: Object as PropType, default: () => ({}) }, }, data: () => { return { diff --git a/assets/js/components/Forecast/Chart.vue b/assets/js/components/Forecast/Chart.vue index 39905f6df..27f4115e1 100644 --- a/assets/js/components/Forecast/Chart.vue +++ b/assets/js/components/Forecast/Chart.vue @@ -42,7 +42,7 @@ import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm"; import { registerChartComponents, commonOptions } from "../Sessions/chartConfig"; import formatter, { POWER_UNIT } from "@/mixins/formatter"; import colors, { lighterColor } from "@/colors"; -import type { CURRENCY, ForecastSlot, SolarDetails, TimeseriesEntry } from "@/types/evcc"; +import type { CURRENCY, UiForecastSlot, UiSolarDetails, UiTimeseriesEntry } from "@/types/evcc"; import { ForecastType, highestSlotIndexByDay } from "@/utils/forecast"; registerChartComponents([ @@ -64,9 +64,9 @@ export default defineComponent({ components: { Bar }, mixins: [formatter], props: { - grid: { type: Array as PropType }, - solar: { type: Object as PropType }, - co2: { type: Array as PropType }, + grid: { type: Array as PropType }, + solar: { type: Object as PropType }, + co2: { type: Array as PropType }, currency: { type: String as PropType }, selected: { type: String as PropType }, }, @@ -452,7 +452,7 @@ export default defineComponent({ now.setMilliseconds(0); this.startDate = now; }, - filterSlots(slots: ForecastSlot[] = []) { + filterSlots(slots: UiForecastSlot[] = []) { if (!slots) { return undefined; } @@ -462,7 +462,7 @@ export default defineComponent({ new Date(slot.end) >= this.startDate && new Date(slot.start) <= this.endDate ); }, - filterEntries(entries: TimeseriesEntry[] = []) { + filterEntries(entries: UiTimeseriesEntry[] = []) { return entries.filter( (entry) => new Date(entry.ts) >= this.startDate && new Date(entry.ts) <= this.endDate @@ -491,7 +491,7 @@ export default defineComponent({ }, 100); } }, - yMax(slots: ForecastSlot[] = []): number | undefined { + yMax(slots: UiForecastSlot[] = []): number | undefined { const max = this.maxValue(slots); if (!max) return undefined; const fixedValues = slots.every((slot) => slot.value === max); @@ -499,29 +499,29 @@ export default defineComponent({ const topSpace = fixedValues ? 3 : 1.15; return max * topSpace; }, - yMaxEntry(entries: TimeseriesEntry[] = [], scale: number = 1): number | undefined { + yMaxEntry(entries: UiTimeseriesEntry[] = [], scale: number = 1): number | undefined { const maxValue = this.maxEntryValue(entries); if (!maxValue) return undefined; // use scale and unscaled to determine max scale return Math.max(maxValue * scale, maxValue) * 1.15; }, - maxIndex(slots: ForecastSlot[] = []) { + maxIndex(slots: UiForecastSlot[] = []) { return slots.reduce((max, slot, index) => { return slot.value > (slots[max]?.value || 0) ? index : max; }, 0); }, - minIndex(slots: ForecastSlot[] = []) { + minIndex(slots: UiForecastSlot[] = []) { return slots.reduce((min, slot, index) => { return slot.value < (slots[min]?.value || 0) ? index : min; }, 0); }, - maxValue(slots: ForecastSlot[] = []) { + maxValue(slots: UiForecastSlot[] = []) { return slots[this.maxIndex(slots)]?.value || null; }, - maxEntryValue(entries: TimeseriesEntry[] = []) { + maxEntryValue(entries: UiTimeseriesEntry[] = []) { return entries[this.maxEntryIndex(entries)]?.val || null; }, - maxEntryIndex(entries: TimeseriesEntry[] = []) { + maxEntryIndex(entries: UiTimeseriesEntry[] = []) { return entries.reduce((max, entry, index) => { return entry.val > (entries[max]?.val || 0) ? index : max; }, 0); diff --git a/assets/js/components/Forecast/GridDetails.vue b/assets/js/components/Forecast/GridDetails.vue index 012febe7f..c9c567d25 100644 --- a/assets/js/components/Forecast/GridDetails.vue +++ b/assets/js/components/Forecast/GridDetails.vue @@ -50,7 +50,7 @@