From 014a5e85a2290b88ed93c0ee368b7a2dcfa40094 Mon Sep 17 00:00:00 2001 From: Pieter Hollander Date: Wed, 7 Aug 2024 18:55:26 +0200 Subject: [PATCH] Fix to take into account user-defined timezone for insertEvents. Add multi OpenDTU TODO. --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index ac98c20..295ed2a 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ // Idea: Gather settings only on start-up. // TODO: Only update meter readings such as yieldday, yieldtotal on-change. // TODO: Add a health check endpoint, potentially log to it. +// TODO: Add support for monitoring multiple OpenDTU's at once. package main import ( @@ -563,7 +564,9 @@ func getPreviousEventsCount(db *sql.DB, inverterSerial string) int { } func insertEvents(db *sql.DB, inverterSerial string, events *EventsResponse) { - timestamp := time.Now() + timeZone := config.TZ + loc, _ := time.LoadLocation(timeZone) + timestamp := time.Now().In(loc) for _, event := range events.Events { // Insert events data into the events table