mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-13 15:37:03 +00:00
Some adjustments for fetching exchange rate
This commit is contained in:
parent
6bdd7855a7
commit
8a0c0298ab
@ -16,7 +16,7 @@ public:
|
||||
|
||||
private:
|
||||
uint8_t scale = 0;
|
||||
float value = 1.0;
|
||||
float value = 0;
|
||||
|
||||
char buf[128];
|
||||
uint8_t pos = 0;
|
||||
|
||||
@ -302,7 +302,11 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) url: %s\n"), buf);
|
||||
if(retrieve(buf, &p)) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) got exchange rate %.4f\n"), p.getValue());
|
||||
currencyMultiplier /= p.getValue();
|
||||
if(p.getValue() > 0.0) {
|
||||
currencyMultiplier /= p.getValue();
|
||||
} else {
|
||||
currencyMultiplier = 0;
|
||||
}
|
||||
} else {
|
||||
currencyMultiplier = 0;
|
||||
return 0;
|
||||
@ -312,10 +316,14 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t
|
||||
currencyMultiplier = 0;
|
||||
return 0;
|
||||
}
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) Resulting currency multiplier: %.4f\n"), currencyMultiplier);
|
||||
tmElements_t tm;
|
||||
breakTime(t, tm);
|
||||
lastCurrencyFetch = now + (SECS_PER_DAY * 1000) - (((((tm.Hour * 60) + tm.Minute) * 60) + tm.Second) * 1000) + 3600000;
|
||||
if(currencyMultiplier != 0) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) Resulting currency multiplier: %.4f\n"), currencyMultiplier);
|
||||
tmElements_t tm;
|
||||
breakTime(t, tm);
|
||||
lastCurrencyFetch = now + (SECS_PER_DAY * 1000) - (((((tm.Hour * 60) + tm.Minute) * 60) + tm.Second) * 1000) + 3600000;
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("(EntsoeApi) Multiplier ended in success, but without value\n"));
|
||||
}
|
||||
}
|
||||
return currencyMultiplier;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user