diff --git a/lib/EntsoePriceApi/include/EntsoeApi.h b/lib/EntsoePriceApi/include/EntsoeApi.h
index 43f3811c..7ff12fba 100644
--- a/lib/EntsoePriceApi/include/EntsoeApi.h
+++ b/lib/EntsoePriceApi/include/EntsoeApi.h
@@ -29,6 +29,8 @@ public:
float getValueForHour(int8_t);
float getValueForHour(time_t, int8_t);
+ int16_t getLastError();
+
private:
RemoteDebug* debugger;
EntsoeConfig* config = NULL;
@@ -54,6 +56,8 @@ private:
float currencyMultiplier = 0;
+ int16_t lastError = 0;
+
PricesContainer* fetchPrices(time_t);
bool retrieve(const char* url, Stream* doc);
float getCurrencyMultiplier(const char* from, const char* to);
diff --git a/lib/EntsoePriceApi/src/EntsoeApi.cpp b/lib/EntsoePriceApi/src/EntsoeApi.cpp
index 32af0385..3efe4d5f 100644
--- a/lib/EntsoePriceApi/src/EntsoeApi.cpp
+++ b/lib/EntsoePriceApi/src/EntsoeApi.cpp
@@ -164,8 +164,13 @@ bool EntsoeApi::loop() {
return true;
} else {
if(today == NULL && (lastTodayFetch == 0 || now - lastTodayFetch > 60000)) {
- lastTodayFetch = now;
- today = fetchPrices(t);
+ try {
+ lastTodayFetch = now;
+ today = fetchPrices(t);
+ } catch(const std::exception& e) {
+ if(lastError == 0) lastError = 900;
+ today = NULL;
+ }
return today != NULL;
}
@@ -175,9 +180,14 @@ bool EntsoeApi::loop() {
&& midnightMillis - now < tomorrowFetchMillis
&& (lastTomorrowFetch == 0 || now - lastTomorrowFetch > 900000)
) {
- breakTime(t+SECS_PER_DAY, tm); // Break UTC tomorrow to find UTC midnight
- lastTomorrowFetch = now;
- tomorrow = fetchPrices(t+SECS_PER_DAY);
+ try {
+ breakTime(t+SECS_PER_DAY, tm); // Break UTC tomorrow to find UTC midnight
+ lastTomorrowFetch = now;
+ tomorrow = fetchPrices(t+SECS_PER_DAY);
+ } catch(const std::exception& e) {
+ if(lastError == 0) lastError = 900;
+ tomorrow = NULL;
+ }
return tomorrow != NULL;
}
}
@@ -207,8 +217,10 @@ bool EntsoeApi::retrieve(const char* url, Stream* doc) {
printD("Receiving data");
http.writeToStream(doc);
http.end();
+ lastError = 0;
return true;
} else {
+ lastError = status;
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Communication error, returned status: %d\n", status);
printE(http.errorToString(status));
printD(http.getString());
@@ -326,7 +338,9 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) {
printD("Receiving data");
data = http.getString();
http.end();
+ lastError = 0;
} else {
+ lastError = status;
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Communication error, returned status: %d\n", status);
printE(http.errorToString(status));
printD(http.getString());
@@ -355,8 +369,10 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) {
for(uint8_t i = 0; i < 24; i++) {
ret->points[i] = ntohl(ret->points[i]);
}
+ lastError = 0;
return ret;
} else {
+ lastError = gcmRet;
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Error code while decrypting prices: %d\n", gcmRet);
}
}
@@ -392,3 +408,7 @@ void EntsoeApi::debugPrint(byte *buffer, int start, int length) {
}
debugger->println("");
}
+
+int16_t EntsoeApi::getLastError() {
+ return lastError;
+}
\ No newline at end of file
diff --git a/lib/SvelteUi/app/src/lib/Header.svelte b/lib/SvelteUi/app/src/lib/Header.svelte
index bb41bf27..024b4498 100644
--- a/lib/SvelteUi/app/src/lib/Header.svelte
+++ b/lib/SvelteUi/app/src/lib/Header.svelte
@@ -2,7 +2,7 @@
import { Link } from "svelte-navigator";
import { sysinfoStore, getGitHubReleases, gitHubReleaseStore } from './DataStores.js';
import { upgrade, getNextVersion } from './UpgradeHelper';
- import { boardtype, hanError, mqttError } from './Helpers.js';
+ import { boardtype, hanError, mqttError, priceError } from './Helpers.js';
import GitHubLogo from './../assets/github.svg';
import Uptime from "./Uptime.svelte";
import Badge from './Badge.svelte';
@@ -59,10 +59,13 @@