]> git.basschouten.com Git - openhab-addons.git/commitdiff
Add language tab for Rule DSL examples (#16960)
authorJacob Laursen <jacob-github@vindvejr.dk>
Sat, 29 Jun 2024 11:12:06 +0000 (13:12 +0200)
committerGitHub <noreply@github.com>
Sat, 29 Jun 2024 11:12:06 +0000 (13:12 +0200)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.energidataservice/README.md

index ed85a08f884b9ec6027ae926c67a77deef51c161..ed764749db2303a51fe9ce19c7d52eaa2f191acd 100644 (file)
@@ -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<String, Object> 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<String, Object> 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<Duration> durationPhases = new ArrayList<Duration>()
 durationPhases.add(Duration.ofMinutes(37))
 durationPhases.add(Duration.ofMinutes(8))
@@ -346,6 +366,10 @@ powerPhases.add(0 | W)
 var Map<String, Object> 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<Duration> durationPhases = new ArrayList<Duration>()
 durationPhases.add(Duration.ofMinutes(37))
 durationPhases.add(Duration.ofMinutes(8))
@@ -382,6 +410,10 @@ durationPhases.add(Duration.ofMinutes(41))
 var Map<String, Object> 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