diff --git a/main.go b/main.go index add372e..abce7c6 100644 --- a/main.go +++ b/main.go @@ -214,6 +214,8 @@ func handleMessage(message []byte, db *sql.DB) { // Check conditions for recording data for _, inverter := range liveData.Inverters { // Record events data + // Optional debugging code: + // log.Println("Events data:", "age", inverter.DataAge, "event number", inverter.Events, "previous event count", getPreviousEventsCount(db, inverter.Serial)) if inverter.DataAge == 0 && inverter.Events > 0 && inverter.Events > getPreviousEventsCount(db, inverter.Serial) { // Query the endpoint for events events, err := queryEventsEndpoint(inverter.Serial) @@ -472,6 +474,7 @@ func queryEventsEndpoint(inverterSerial string) (*EventsResponse, error) { // Additionally, this function requires OpenDTU to be set to "Clear Eventlog at midnight" for each inverter. // "Clear Eventlog at midnight" should be set to ON in "Inverter settings" -> "pencil" -> "Advanced". // To account for possible time drifts, the first and last 10 minutes of the day are excluded. +// // Longest day NL: sun up 4:16, sun down 22:50 // Shortest day NL: sun up 8:44, sun down 16:25 func getPreviousEventsCount(db *sql.DB, inverterSerial string) int {