Class ExchangeRateApi
java.lang.Object
io.openems.edge.timeofusetariff.entsoe.ExchangeRateApi
A utility class for fetching exchange rates from a web API.
Day ahead prices retrieved from ENTSO-E are usually in EUR and might have to be converted to the user's currency using the exchange rates provided by Exchange Rate API. For more information on the ExchangeRate API, visit: https://exchangerate.host/#/docs
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static double
getExchangeRate
(String accessKey, String source, Currency target) Fetches the exchange rate from exchangerate.host.protected static double
parseResponse
(String response, String source, Currency target) Parses the response string from exchangerate.host.
-
Constructor Details
-
ExchangeRateApi
public ExchangeRateApi()
-
-
Method Details
-
getExchangeRate
protected static double getExchangeRate(String accessKey, String source, Currency target) throws IOException, OpenemsError.OpenemsNamedException Fetches the exchange rate from exchangerate.host.- Parameters:
accessKey
- personal API access key.source
- the source currency (e.g. EUR)target
- the target currency (e.g. SEK)- Returns:
- the exchange rate.
- Throws:
IOException
- on error.OpenemsError.OpenemsNamedException
- on error
-
parseResponse
protected static double parseResponse(String response, String source, Currency target) throws OpenemsError.OpenemsNamedException Parses the response string from exchangerate.host.- Parameters:
response
- the response stringsource
- the source currency (e.g. EUR)target
- the target currency (e.g. SEK)- Returns:
- the exchange rate.
- Throws:
OpenemsError.OpenemsNamedException
- on error.
-