From 519a03944f25f5080dcb4c4dd3c40276ed19a2ea Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 29 Jun 2024 13:12:06 +0200 Subject: [PATCH] Add language tab for Rule DSL examples (#16960) Signed-off-by: Jacob Laursen --- .../README.md | 60 +++++++++++++++++-- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.energidataservice/README.md b/bundles/org.openhab.binding.energidataservice/README.md index ed85a08f884..ed764749db2 100644 --- a/bundles/org.openhab.binding.energidataservice/README.md +++ b/bundles/org.openhab.binding.energidataservice/README.md @@ -283,10 +283,18 @@ For this reason the resulting `Map` will not contain the keys `LowestPrice` and Example: -```javascript +:::: tabs + +::: tab DSL + +```java var Map result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90)) ``` +::: + +:::: + #### `calculateCheapestPeriod` from Duration and Power | Parameter | Type | Description | @@ -301,10 +309,18 @@ As a result the price is also included in the result. Example: -```javascript +:::: tabs + +::: tab DSL + +```java var Map result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90), 250 | W) ``` +::: + +:::: + #### `calculateCheapestPeriod` from Power Phases | Parameter | Type | Description | @@ -322,7 +338,11 @@ This can be considered as different phases of using power, so each list member r Example: -```javascript +:::: tabs + +::: tab DSL + +```java val ArrayList durationPhases = new ArrayList() durationPhases.add(Duration.ofMinutes(37)) durationPhases.add(Duration.ofMinutes(8)) @@ -346,6 +366,10 @@ powerPhases.add(0 | W) var Map result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), durationPhases, powerPhases) ``` +::: + +:::: + Please note that the total duration will be calculated automatically as a sum of provided duration phases. Therefore, if the total duration is longer than the sum of phase durations, the remaining duration must be provided as last item with a corresponding 0 W power item. This is to ensure that the full program will finish before the provided `latestEnd`. @@ -368,7 +392,11 @@ Since a last phase may use no significant energy, the total duration must be pro Example: -```javascript +:::: tabs + +::: tab DSL + +```java val ArrayList durationPhases = new ArrayList() durationPhases.add(Duration.ofMinutes(37)) durationPhases.add(Duration.ofMinutes(8)) @@ -382,6 +410,10 @@ durationPhases.add(Duration.ofMinutes(41)) var Map result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(236), phases, 0.1 | kWh) ``` +::: + +:::: + ### `calculatePrice` | Parameter | Type | Description | @@ -397,10 +429,18 @@ Returns `null` if the calculation cannot be performed due to missing price data Example: -```javascript +:::: tabs + +::: tab DSL + +```java var price = actions.calculatePrice(now.toInstant(), now.plusHours(4).toInstant, 200 | W) ``` +::: + +:::: + ### `getPrices` | Parameter | Type | Description | @@ -427,10 +467,18 @@ This logic ensures consistent and comparable results not affected by artifical c Example: -```javascript +:::: tabs + +::: tab DSL + +```java var priceMap = actions.getPrices("SpotPrice,GridTariff") ``` +::: + +:::: + ## Full Example ### Thing Configuration