diff --git a/bundles/org.openhab.binding.energidataservice/README.md b/bundles/org.openhab.binding.energidataservice/README.md index 75c42747e02b2..a27e32790c6c5 100644 --- a/bundles/org.openhab.binding.energidataservice/README.md +++ b/bundles/org.openhab.binding.energidataservice/README.md @@ -77,7 +77,7 @@ To override filters, the channel `net-tariff` has the following configuration pa | notes | text | Comma-separated list of notes | | no | yes | | start | text | Query start date parameter expressed as either YYYY-MM-DD or dynamically as one of StartOfDay, StartOfMonth or StartOfYear | | no | yes | -The parameters `chargeTypeCodes` and `notes` are logically combined with "AND", so if only one parameter is needed for filter, only provide this parameter and leave the other one empty. +The parameters `chargeTypeCodes` and `notes` are logically combined with "AND", so if only one parameter is needed for the filter, only provide this parameter and leave the other one empty. Using any of these parameters will override the pre-configured filter entirely. The parameter `start` can be used independently to override the query start date parameter. @@ -165,7 +165,7 @@ The result is a `Map` with the following keys: This is a convenience method that can be used when the power consumption is not known. The calculation will assume linear consumption and will find the best timeslot based on that. -The this reason the resulting `Map` will not contain the keys `LowestPrice` and `HighestPrice`. +For this reason the resulting `Map` will not contain the keys `LowestPrice` and `HighestPrice`. Example: @@ -338,15 +338,19 @@ String HourlyPrices "Hourly Prices" { channel="energidataservice:service ### Thing Actions Example +:::: tabs + +::: tab DSL + ```javascript import java.time.Duration import java.util.ArrayList import java.util.Map import java.time.temporal.ChronoUnit -val actions = getActions("energidataservice", "energidataservice:service:energidataservice"); +val actions = getActions("energidataservice", "energidataservice:service:energidataservice") -var priceMap = actions.getPrices(null); +var priceMap = actions.getPrices(null) var hourStart = now.toInstant().truncatedTo(ChronoUnit.HOURS) logInfo("Current total price excl. VAT", priceMap.get(hourStart).toString) @@ -397,3 +401,24 @@ durationPhases.add(Duration.ofMinutes(104)) var Map result = actions.calculateCheapestPeriod(now.toInstant(), now.plusHours(24).toInstant(), Duration.ofMinutes(236), phases, 0.1 | kWh) ``` + +::: + +::: tab JavaScript + +```javascript +edsActions = actions.get("energidataservice", "energidataservice:service:energidataservice"); + +// Get prices and convert to JavaScript Map with Instant string representation as keys. +var priceMap = new Map(); +utils.javaMapToJsMap(edsActions.getPrices()).forEach((value, key) => { + priceMap.set(key.toString(), value); +}); + +var hourStart = time.Instant.now().truncatedTo(time.ChronoUnit.HOURS); +console.log("Current total price excl. VAT: " + priceMap.get(hourStart.toString())); +``` + +::: + +::::