From de79fd4c43411b41ffc087601f79a4cd084fd166 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 29 Jun 2024 10:15:15 +0200 Subject: [PATCH] Send prices to MQTT when having fixed price only --- lib/PriceService/src/PriceService.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/PriceService/src/PriceService.cpp b/lib/PriceService/src/PriceService.cpp index 5a8893b7..dabed5c9 100644 --- a/lib/PriceService/src/PriceService.cpp +++ b/lib/PriceService/src/PriceService.cpp @@ -231,8 +231,6 @@ bool PriceService::loop() { return false; } #endif - if(!config->enabled) - return false; if(strlen(config->area) == 0) return false; if(strlen(config->currency) == 0) @@ -254,12 +252,15 @@ bool PriceService::loop() { } currentDay = tm.Day; currentHour = tm.Hour; - return today != NULL; // Only trigger MQTT publish if we have todays prices. + return today != NULL || (!config->enabled && priceConfig.capacity() != 0); // Only trigger MQTT publish if we have todays prices. } else if(currentHour != tm.Hour) { currentHour = tm.Hour; - return today != NULL; // Only trigger MQTT publish if we have todays prices. + return today != NULL || (!config->enabled && priceConfig.capacity() != 0); // Only trigger MQTT publish if we have todays prices. } + if(!config->enabled) + return false; + bool readyToFetchForTomorrow = tomorrow == NULL && (tm.Hour > 13 || (tm.Hour == 13 && tm.Minute >= tomorrowFetchMinute)) && (lastTomorrowFetch == 0 || now - lastTomorrowFetch > (nextFetchDelayMinutes*60000)); if(today == NULL && (lastTodayFetch == 0 || now - lastTodayFetch > (nextFetchDelayMinutes*60000))) {