import { type TapoDevice } from "../lib/getPower"; interface PowerCardProps { device: TapoDevice | null; label: string; delay?: number; } function powerColor(watts: number): string { if (watts > 400) return "#ef4444"; if (watts > 200) return "#f59e0b"; return "#3b82f6"; } export default function PowerCard({ device, label, delay = 0 }: PowerCardProps) { const pct = device ? Math.min(100, (device.current_power_w / 500) * 100) : 0; const runtimeHours = device ? Math.floor(device.today_runtime_min / 60) : 0; const runtimeMins = device ? device.today_runtime_min % 60 : 0; return (
{label} {device ? ( {device.on ? "On" : "Off"} ) : null}
{device ? ( <>
{device.current_power_w.toFixed(1)} W
{device.alias} ยท {device.model}
{(device.today_energy_wh / 1000).toFixed(3)} kWh Today
{(device.month_energy_wh / 1000).toFixed(2)} kWh Month
{runtimeHours}h {runtimeMins}m Runtime
) : (
)}
); }