From: jimtng <2554958+jimtng@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:31:37 +0000 (+1000) Subject: [energidataservice] Add missing JRuby examples (#17002) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=d6e8bee5a3d883ebb217485f36523132511bd900;p=openhab-addons.git [energidataservice] Add missing JRuby examples (#17002) Signed-off-by: Jimmy Tanagra --- diff --git a/bundles/org.openhab.binding.energidataservice/README.md b/bundles/org.openhab.binding.energidataservice/README.md index d42cc438d9..c9008a14df 100644 --- a/bundles/org.openhab.binding.energidataservice/README.md +++ b/bundles/org.openhab.binding.energidataservice/README.md @@ -303,6 +303,15 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant ::: +::: tab JRuby + +```ruby +eds = things["energidataservice:service:energidataservice"] +result = eds.calculate_cheapest_period(Instant.now, 2.hours.from_now.to_instant, 90.minutes) +``` + +::: + :::: #### `calculateCheapestPeriod` from Duration and Power @@ -337,6 +346,15 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant ::: +::: tab JRuby + +```ruby +eds = things["energidataservice:service:energidataservice"] +result = eds.calculate_cheapest_period(Instant.now, 12.hours.from_now.to_instant, 90.minutes, 250 | "W") +``` + +::: + :::: #### `calculateCheapestPeriod` from Power Phases @@ -416,6 +434,27 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant ::: +::: tabs JRuby + +```ruby +duration_phases = [37, 8, 4, 2, 4, 36, 41, 104].map { |duration| duration.minutes } +power_phases = [ + 162.162 | "W", + 750 | "W", + 1500 | "W", + 3000 | "W", + 1500 | "W", + 166.666 | "W", + 146.341 | "W", + 0 | "W" +] + +eds = things["energidataservice:service:energidataservice"] +result = eds.calculate_cheapest_period(Instant.now, 12.hours.from_now.to_instant, duration_phases, power_phases) +``` + +::: + :::: Please note that the total duration will be calculated automatically as a sum of provided duration phases. @@ -479,6 +518,17 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant ::: +::: tabs JRuby + +```ruby +duration_phases = [37, 8, 4, 2, 4, 36, 41].map { |duration| duration.minutes } + +eds = things["energidataservice:service:energidataservice"] +result = eds.calculate_cheapest_period(Instant.now, 12.hours.from_now.to_instant, 236.minutes, duration_phases, 0.1 | "kWh") +``` + +::: + :::: ### `calculatePrice` @@ -514,6 +564,15 @@ var price = edsActions.calculatePrice(time.Instant.now(), time.ZonedDateTime.now ::: +::: tab JRuby + +```ruby +eds = things["energidataservice:service:energidataservice"] +price = eds.calculate_price(Instant.now, 4.hours.from_now.to_instant, 200 | "W") +``` + +::: + :::: ### `getPrices` @@ -560,6 +619,15 @@ var priceMap = utils.javaMapToJsMap(edsActions.getPrices("SpotPrice,GridTariff") ::: +::: tab JRuby + +```ruby +eds = things["energidataservice:service:energidataservice"] +price_map = eds.get_prices("SpotPrice,GridTariff") +``` + +::: + :::: ## Full Example