java.lang.Object
io.openems.edge.timeofusetariff.tibber.Utils

public class Utils extends Object
  • Method Details

    • parsePrices

      protected static TimeOfUsePrices parsePrices(String jsonData, String filter) throws OpenemsError.OpenemsNamedException
      Parse the Tibber JSON to TimeOfUsePrices.

      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 JSON
      filter - 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

      protected static String generateGraphQl()
      Generate a GraphQL query.
      Returns:
      a query string