Fix to take into account user-defined timezone for insertEvents. Add multi OpenDTU TODO.

This commit is contained in:
Pieter Hollander 2024-08-07 18:55:26 +02:00
parent 32bebfdca2
commit 014a5e85a2
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

View file

@ -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