package tiko import ( "fmt" "net/http" "net/url" "strconv" "time" ) type HistoryResponse struct { Status string `json:"status"` Response struct { Timestamps []float64 `json:"timestamps"` Values []float64 `json:"values"` Kbox string `json:"kbox"` Version string `json:"version"` MissingData []int `json:"missing_data"` Control []int `json:"control"` EcoMode []int `json:"eco_mode"` Production []int `json:"production"` Resolution string `json:"resolution"` ValuesTargetTemperature []float64 `json:"values_target_temperature"` ValuesMeasuredTemperature []float64 `json:"values_measured_temperature"` Start int64 `json:"start"` End int64 `json:"end"` ValuesList []int `json:"values_list"` } `json:"response"` } func (c *Client) GetRoomHistory(propertyID, roomID int64, startDate, endDate time.Time, resolution string) (*HistoryResponse, error) { if err := c.Init(); err != nil { return nil, err } // Convertir les dates en millisecondes UNIX start := startDate.UnixNano() / int64(time.Millisecond) end := endDate.UnixNano() / int64(time.Millisecond) // Construire l'URL avec les paramètres path := fmt.Sprintf("%s/properties/%d/rooms/%d/history/", baseURL, propertyID, roomID) params := url.Values{} params.Set("start", strconv.FormatInt(start, 10)) params.Set("end", strconv.FormatInt(end, 10)) params.Set("resolution", resolution) url := fmt.Sprintf("%s?%s", path, params.Encode()) // Créer la requête HTTP req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { return nil, err } return Do[HistoryResponse](c, req) }