From 04daf551fbeb2baf36c5cd51c6894d6494e14d66 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sun, 16 Jan 2022 17:04:58 +0100 Subject: [PATCH] Fixed incorrect time diff for price fetch --- src/entsoe/EntsoeApi.cpp | 4 ++-- src/entsoe/EntsoeApi.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/entsoe/EntsoeApi.cpp b/src/entsoe/EntsoeApi.cpp index 0994bb3f..1eeec954 100644 --- a/src/entsoe/EntsoeApi.cpp +++ b/src/entsoe/EntsoeApi.cpp @@ -19,7 +19,7 @@ EntsoeApi::EntsoeApi(RemoteDebug* Debug) { TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; tz = new Timezone(CEST, CET); - tomorrowFetchMillis = random(3600000,3780000); // Random between 13:30 and 14:00 + tomorrowFetchMillis = 36000000 + (random(1800) * 1000); // Random between 13:30 and 14:00 } void EntsoeApi::setup(EntsoeConfig& config) { @@ -64,7 +64,7 @@ float EntsoeApi::getValueForHour(time_t cur, uint8_t hour) { return ENTSOE_NO_VALUE; } multiplier *= getCurrencyMultiplier(tomorrow->getCurrency(), config->currency); - } else { + } else if(pos > 0) { if(today == NULL) return ENTSOE_NO_VALUE; value = today->getPoint(pos); diff --git a/src/entsoe/EntsoeApi.h b/src/entsoe/EntsoeApi.h index c4ad9407..9ec5d788 100644 --- a/src/entsoe/EntsoeApi.h +++ b/src/entsoe/EntsoeApi.h @@ -35,7 +35,7 @@ private: WiFiClientSecure client; HTTPClient https; - uint32_t tomorrowFetchMillis = 3600000; // Number of ms before midnight. Default fetch 10hrs before midnight (14:00 CE(S)T) + uint32_t tomorrowFetchMillis = 36000000; // Number of ms before midnight. Default fetch 10hrs before midnight (14:00 CE(S)T) uint64_t midnightMillis = 0; uint64_t lastTodayFetch = 0; uint64_t lastTomorrowFetch = 0;