evcc-io/assets/js/utils/convertRates.ts
Maschga e7a5860f5e
Chore: Typescript: Rewrite Energyflow (#20814)
Co-authored-by: Michael Geers <michael@geers.tv>
2025-04-28 22:22:49 +02:00

15 lines
390 B
TypeScript

import type { Rate } from "../types/evcc";
import type { ForecastSlot } from "../components/Forecast/types";
function convertRate(slot: ForecastSlot): Rate {
return {
start: new Date(slot.start),
end: new Date(slot.end),
value: slot.value,
};
}
export default function convertRates(slots: ForecastSlot[] | null): Rate[] {
if (!slots) return [];
return slots.map(convertRate);
}