Add language tab for Rule DSL examples (#16960)

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-06-29 13:12:06 +02:00 committed by GitHub
parent 80bd5bfcb3
commit 519a03944f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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