From a34549e125a0bbc5882921b595f6a535a8bab67e Mon Sep 17 00:00:00 2001 From: Oscar Romeu Date: Mon, 6 Dec 2021 13:33:55 +0100 Subject: [PATCH] Set up polling every 30 minutes max resolution --- examples/influxdb/main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/influxdb/main.go b/examples/influxdb/main.go index 9d31d40..b10c496 100644 --- a/examples/influxdb/main.go +++ b/examples/influxdb/main.go @@ -142,20 +142,29 @@ func main() { Dia: strconv.Itoa(tt.Day()), } + // Get the current minute and round to 30 or 00 + // Opendata precision is rouglhy 30min + var minute string + if (tt.Minute() >= 30) && (tt.Minute() < 45) { + minute = "30" + } else { + minute = "00" + } + timeDate := meteocat.TimeDate{ Hour: strconv.Itoa(tt.Hour()), - Minute: "00", + Minute: minute, Seconds: "00", } + + fmt.Println(timeDate) p, _ := meteocat.NewParameters( meteocat.OptionData(data), meteocat.OptionTimeDate(timeDate), ) d.OpenDataMeasurementAllByStation(p) - log.Info("Gathered data") log.Info(d.OpenData) - log.Info(tt) writeAPI := c.WriteAPI("", "meteocat/autogen")