mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[energidataservice] Add missing JRuby examples (#17002)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
220207eac6
commit
bc8ec426a8
@ -303,6 +303,15 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant
|
||||
|
||||
:::
|
||||
|
||||
::: tab JRuby
|
||||
|
||||
```ruby
|
||||
eds = things["energidataservice:service:energidataservice"]
|
||||
result = eds.calculate_cheapest_period(Instant.now, 2.hours.from_now.to_instant, 90.minutes)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
#### `calculateCheapestPeriod` from Duration and Power
|
||||
@ -337,6 +346,15 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant
|
||||
|
||||
:::
|
||||
|
||||
::: tab JRuby
|
||||
|
||||
```ruby
|
||||
eds = things["energidataservice:service:energidataservice"]
|
||||
result = eds.calculate_cheapest_period(Instant.now, 12.hours.from_now.to_instant, 90.minutes, 250 | "W")
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
#### `calculateCheapestPeriod` from Power Phases
|
||||
@ -416,6 +434,27 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant
|
||||
|
||||
:::
|
||||
|
||||
::: tabs JRuby
|
||||
|
||||
```ruby
|
||||
duration_phases = [37, 8, 4, 2, 4, 36, 41, 104].map { |duration| duration.minutes }
|
||||
power_phases = [
|
||||
162.162 | "W",
|
||||
750 | "W",
|
||||
1500 | "W",
|
||||
3000 | "W",
|
||||
1500 | "W",
|
||||
166.666 | "W",
|
||||
146.341 | "W",
|
||||
0 | "W"
|
||||
]
|
||||
|
||||
eds = things["energidataservice:service:energidataservice"]
|
||||
result = eds.calculate_cheapest_period(Instant.now, 12.hours.from_now.to_instant, duration_phases, power_phases)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
Please note that the total duration will be calculated automatically as a sum of provided duration phases.
|
||||
@ -479,6 +518,17 @@ var result = edsActions.calculateCheapestPeriod(time.Instant.now(), time.Instant
|
||||
|
||||
:::
|
||||
|
||||
::: tabs JRuby
|
||||
|
||||
```ruby
|
||||
duration_phases = [37, 8, 4, 2, 4, 36, 41].map { |duration| duration.minutes }
|
||||
|
||||
eds = things["energidataservice:service:energidataservice"]
|
||||
result = eds.calculate_cheapest_period(Instant.now, 12.hours.from_now.to_instant, 236.minutes, duration_phases, 0.1 | "kWh")
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
### `calculatePrice`
|
||||
@ -514,6 +564,15 @@ var price = edsActions.calculatePrice(time.Instant.now(), time.ZonedDateTime.now
|
||||
|
||||
:::
|
||||
|
||||
::: tab JRuby
|
||||
|
||||
```ruby
|
||||
eds = things["energidataservice:service:energidataservice"]
|
||||
price = eds.calculate_price(Instant.now, 4.hours.from_now.to_instant, 200 | "W")
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
### `getPrices`
|
||||
@ -560,6 +619,15 @@ var priceMap = utils.javaMapToJsMap(edsActions.getPrices("SpotPrice,GridTariff")
|
||||
|
||||
:::
|
||||
|
||||
::: tab JRuby
|
||||
|
||||
```ruby
|
||||
eds = things["energidataservice:service:energidataservice"]
|
||||
price_map = eds.get_prices("SpotPrice,GridTariff")
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
## Full Example
|
||||
|
Loading…
Reference in New Issue
Block a user