diff --git a/frontend-node/src/app/vehicle/page.tsx b/frontend-node/src/app/vehicle/page.tsx index c5ba398..7f38d6e 100644 --- a/frontend-node/src/app/vehicle/page.tsx +++ b/frontend-node/src/app/vehicle/page.tsx @@ -31,6 +31,7 @@ export default function PageVehicle() { const [tibberToken, setTibberToken] = useState('') const [vehicleState, setVehicleState] = useState({} as any) const [chargingEvents, setChargingEvents] = useState([] as any) + const [maxChargingPower, setMaxChargingPower] = useState('0 kW') useEffect(() => { const searchParams = new URLSearchParams(window.location.search); @@ -82,6 +83,7 @@ export default function PageVehicle() { const e = await getAPI("/api/1/tesla/my_vehicle/" + vin); setVehicleDetails(e.vehicle); setVehicleState(e.state); + updateMaxChargingPower(e.vehicle.max_amps, e.vehicle.num_phases); //loadVehicleState(e.vin); loadLatestChargingEvents(e.vehicle.vin); setVehicle(e.vehicle); @@ -138,7 +140,7 @@ export default function PageVehicle() { return 'Unknown'; } - function getMaxChargingPower() { + function updateMaxChargingPower(maxAmps: number, numPhases: number) { let i = 0; if (maxAmps !== undefined && maxAmps !== undefined) { i = maxAmps!; @@ -149,9 +151,10 @@ export default function PageVehicle() { } let p = i * phases * 230; if (p > 1000) { - return Math.round(p / 1000) + " kW"; + setMaxChargingPower(Math.round(p / 1000) + " kW"); + return; } - return p + " W"; + setMaxChargingPower(p + " W"); } function manualControlTestDrive() { @@ -209,7 +212,7 @@ export default function PageVehicle() {