import { useEffect } from "react";
import { useHomeAssistantStore } from "@/store/homeAssistant";

export default function Timetable() {
    const fetchHomeAssistantData = useHomeAssistantStore(
        (state) => state.fetch,
    );
    const tentTemperature = useHomeAssistantStore(
        (state) => state.tentTemperature,
    );
    const tentHumidity = useHomeAssistantStore((state) => state.tentHumidity);

    useEffect(() => {
        fetchHomeAssistantData();
        const interval = setInterval(() => {
            fetchHomeAssistantData();
        }, 60000);
        return () => clearInterval(interval);
    }, [fetchHomeAssistantData]);

    return (
        <div>
            <h1>Tent</h1>
            <p>Temperature: {tentTemperature}°C</p>
            <p>Humidity: {tentHumidity}%</p>
        </div>
    );
}
