mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
Add language tab for Rule DSL examples (#16960)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
7fe38a0099
commit
9b01c43471
@ -283,10 +283,18 @@ For this reason the resulting `Map` will not contain the keys `LowestPrice` and
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
:::: tabs
|
||||||
|
|
||||||
|
::: tab DSL
|
||||||
|
|
||||||
|
```java
|
||||||
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90))
|
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::::
|
||||||
|
|
||||||
#### `calculateCheapestPeriod` from Duration and Power
|
#### `calculateCheapestPeriod` from Duration and Power
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
@ -301,10 +309,18 @@ As a result the price is also included in the result.
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
:::: tabs
|
||||||
|
|
||||||
|
::: tab DSL
|
||||||
|
|
||||||
|
```java
|
||||||
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90), 250 | W)
|
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(90), 250 | W)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::::
|
||||||
|
|
||||||
#### `calculateCheapestPeriod` from Power Phases
|
#### `calculateCheapestPeriod` from Power Phases
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
@ -322,7 +338,11 @@ This can be considered as different phases of using power, so each list member r
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
:::: tabs
|
||||||
|
|
||||||
|
::: tab DSL
|
||||||
|
|
||||||
|
```java
|
||||||
val ArrayList<Duration> durationPhases = new ArrayList<Duration>()
|
val ArrayList<Duration> durationPhases = new ArrayList<Duration>()
|
||||||
durationPhases.add(Duration.ofMinutes(37))
|
durationPhases.add(Duration.ofMinutes(37))
|
||||||
durationPhases.add(Duration.ofMinutes(8))
|
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)
|
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.
|
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.
|
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`.
|
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:
|
Example:
|
||||||
|
|
||||||
```javascript
|
:::: tabs
|
||||||
|
|
||||||
|
::: tab DSL
|
||||||
|
|
||||||
|
```java
|
||||||
val ArrayList<Duration> durationPhases = new ArrayList<Duration>()
|
val ArrayList<Duration> durationPhases = new ArrayList<Duration>()
|
||||||
durationPhases.add(Duration.ofMinutes(37))
|
durationPhases.add(Duration.ofMinutes(37))
|
||||||
durationPhases.add(Duration.ofMinutes(8))
|
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)
|
var Map<String, Object> result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(12).toInstant(), Duration.ofMinutes(236), phases, 0.1 | kWh)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::::
|
||||||
|
|
||||||
### `calculatePrice`
|
### `calculatePrice`
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
@ -397,10 +429,18 @@ Returns `null` if the calculation cannot be performed due to missing price data
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
:::: tabs
|
||||||
|
|
||||||
|
::: tab DSL
|
||||||
|
|
||||||
|
```java
|
||||||
var price = actions.calculatePrice(now.toInstant(), now.plusHours(4).toInstant, 200 | W)
|
var price = actions.calculatePrice(now.toInstant(), now.plusHours(4).toInstant, 200 | W)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::::
|
||||||
|
|
||||||
### `getPrices`
|
### `getPrices`
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
@ -427,10 +467,18 @@ This logic ensures consistent and comparable results not affected by artifical c
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
:::: tabs
|
||||||
|
|
||||||
|
::: tab DSL
|
||||||
|
|
||||||
|
```java
|
||||||
var priceMap = actions.getPrices("SpotPrice,GridTariff")
|
var priceMap = actions.getPrices("SpotPrice,GridTariff")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::::
|
||||||
|
|
||||||
## Full Example
|
## Full Example
|
||||||
|
|
||||||
### Thing Configuration
|
### Thing Configuration
|
||||||
|
Loading…
Reference in New Issue
Block a user