Skip to content

Commit 519a039

Browse files
authored
Add language tab for Rule DSL examples (openhab#16960)
Signed-off-by: Jacob Laursen <[email protected]>
1 parent 80bd5bf commit 519a039

File tree

1 file changed

+54
-6
lines changed
  • bundles/org.openhab.binding.energidataservice

1 file changed

+54
-6
lines changed

bundles/org.openhab.binding.energidataservice/README.md

+54-6
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,18 @@ For this reason the resulting `Map` will not contain the keys `LowestPrice` and
283283

284284
Example:
285285

286-
```javascript
286+
:::: tabs
287+
288+
::: tab DSL
289+
290+
```java
287291
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90))
288292
```
289293

294+
:::
295+
296+
::::
297+
290298
#### `calculateCheapestPeriod` from Duration and Power
291299

292300
| Parameter | Type | Description |
@@ -301,10 +309,18 @@ As a result the price is also included in the result.
301309

302310
Example:
303311

304-
```javascript
312+
:::: tabs
313+
314+
::: tab DSL
315+
316+
```java
305317
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90), 250 | W)
306318
```
307319

320+
:::
321+
322+
::::
323+
308324
#### `calculateCheapestPeriod` from Power Phases
309325

310326
| Parameter | Type | Description |
@@ -322,7 +338,11 @@ This can be considered as different phases of using power, so each list member r
322338

323339
Example:
324340

325-
```javascript
341+
:::: tabs
342+
343+
::: tab DSL
344+
345+
```java
326346
val ArrayList<Duration> durationPhases = new ArrayList<Duration>()
327347
durationPhases.add(Duration.ofMinutes(37))
328348
durationPhases.add(Duration.ofMinutes(8))
@@ -346,6 +366,10 @@ powerPhases.add(0 | W)
346366
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), durationPhases, powerPhases)
347367
```
348368

369+
:::
370+
371+
::::
372+
349373
Please note that the total duration will be calculated automatically as a sum of provided duration phases.
350374
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.
351375
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
368392

369393
Example:
370394

371-
```javascript
395+
:::: tabs
396+
397+
::: tab DSL
398+
399+
```java
372400
val ArrayList<Duration> durationPhases = new ArrayList<Duration>()
373401
durationPhases.add(Duration.ofMinutes(37))
374402
durationPhases.add(Duration.ofMinutes(8))
@@ -382,6 +410,10 @@ durationPhases.add(Duration.ofMinutes(41))
382410
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(236), phases, 0.1 | kWh)
383411
```
384412

413+
:::
414+
415+
::::
416+
385417
### `calculatePrice`
386418

387419
| Parameter | Type | Description |
@@ -397,10 +429,18 @@ Returns `null` if the calculation cannot be performed due to missing price data
397429

398430
Example:
399431

400-
```javascript
432+
:::: tabs
433+
434+
::: tab DSL
435+
436+
```java
401437
var price = actions.calculatePrice(now.toInstant(), now.plusHours(4).toInstant, 200 | W)
402438
```
403439

440+
:::
441+
442+
::::
443+
404444
### `getPrices`
405445

406446
| Parameter | Type | Description |
@@ -427,10 +467,18 @@ This logic ensures consistent and comparable results not affected by artifical c
427467

428468
Example:
429469

430-
```javascript
470+
:::: tabs
471+
472+
::: tab DSL
473+
474+
```java
431475
var priceMap = actions.getPrices("SpotPrice,GridTariff")
432476
```
433477

478+
:::
479+
480+
::::
481+
434482
## Full Example
435483

436484
### Thing Configuration

0 commit comments

Comments
 (0)