Class Utils
java.lang.Object
io.openems.edge.timeofusetariff.tibber.Utils
-
Method Summary
Modifier and TypeMethodDescriptionprotected static long
calculateDelay
(int httpStatusCode, boolean filterIsRequired, boolean unableToUpdatePrices) Calculates the delay until the next scheduled task run based on the HTTP status code and update availability.protected static String
Generate a GraphQL query.protected static TimeOfUsePrices
parsePrices
(String jsonData, String filter) Parse the Tibber JSON toTimeOfUsePrices
.
-
Method Details
-
parsePrices
protected static TimeOfUsePrices parsePrices(String jsonData, String filter) throws OpenemsError.OpenemsNamedException Parse the Tibber JSON toTimeOfUsePrices
.If a filter is supplied, it is checked against 'id' (UUID) and 'appNickname'. If no filter is supplied, the method tries to be smart with finding the one unique correct result, i.e. it ignores empty/null objects.
- Parameters:
jsonData
- the Tibber JSONfilter
- filter for 'id' or 'appNickname'; null/blank for no filter- Returns:
- the
TimeOfUsePrices
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
calculateDelay
protected static long calculateDelay(int httpStatusCode, boolean filterIsRequired, boolean unableToUpdatePrices) Calculates the delay until the next scheduled task run based on the HTTP status code and update availability.- Parameters:
httpStatusCode
- The HTTP status code received from the request.filterIsRequired
- A boolean indicating whether filter is required.unableToUpdatePrices
- A boolean indicating whether the prices couldn't be updated.- Returns:
- The delay in seconds until the next scheduled task run.
-
generateGraphQl
Generate a GraphQL query.- Returns:
- a query string
-