diff --git a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java index 96b69d7429e6e..97322bb4f833e 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java +++ b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.energidataservice.internal.action; -import static org.openhab.binding.energidataservice.internal.EnergiDataServiceBindingConstants.*; +import static org.openhab.binding.energidataservice.internal.EnergiDataServiceBindingConstants.CURRENCY_DKK; import java.math.BigDecimal; import java.time.Duration; @@ -36,8 +36,10 @@ import org.openhab.binding.energidataservice.internal.PriceComponent; import org.openhab.binding.energidataservice.internal.exception.MissingPriceException; import org.openhab.binding.energidataservice.internal.handler.EnergiDataServiceHandler; +import org.openhab.core.automation.Visibility; import org.openhab.core.automation.annotation.ActionInput; import org.openhab.core.automation.annotation.ActionOutput; +import org.openhab.core.automation.annotation.ActionOutputs; import org.openhab.core.automation.annotation.RuleAction; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.unit.Units; @@ -63,8 +65,8 @@ public class EnergiDataServiceActions implements ThingActions { private @Nullable EnergiDataServiceHandler handler; - @RuleAction(label = "@text/action.get-prices.label", description = "@text/action.get-prices.description") - public @ActionOutput(name = "prices", type = "java.util.Map") Map getPrices() { + @RuleAction(label = "@text/action.get-prices.label", description = "@text/action.get-prices.description", visibility = Visibility.HIDDEN) + public @ActionOutput(type = "java.util.Map") Map getPrices() { EnergiDataServiceHandler handler = this.handler; if (handler == null) { logger.warn("EnergiDataServiceActions ThingHandler is null."); @@ -79,8 +81,8 @@ public class EnergiDataServiceActions implements ThingActions { .collect(Collectors.toSet())); } - @RuleAction(label = "@text/action.get-prices.label", description = "@text/action.get-prices.description") - public @ActionOutput(name = "prices", type = "java.util.Map") Map getPrices( + @RuleAction(label = "@text/action.get-prices.label", description = "@text/action.get-prices.description", visibility = Visibility.HIDDEN) + public @ActionOutput(type = "java.util.Map") Map getPrices( @ActionInput(name = "priceComponents", label = "@text/action.get-prices.priceComponents.label", description = "@text/action.get-prices.priceComponents.description") @Nullable String priceComponents) { if (priceComponents == null) { logger.warn("Argument 'priceComponents' is null"); @@ -100,10 +102,10 @@ public class EnergiDataServiceActions implements ThingActions { } @RuleAction(label = "@text/action.calculate-price.label", description = "@text/action.calculate-price.description") - public @ActionOutput(name = "price", type = "java.math.BigDecimal") @Nullable BigDecimal calculatePrice( - @ActionInput(name = "start", type = "java.time.Instant") Instant start, - @ActionInput(name = "end", type = "java.time.Instant") Instant end, - @ActionInput(name = "power", type = "QuantityType") QuantityType power) { + public @ActionOutput(label = "@text/action.calculate-price.output.label", type = "java.math.BigDecimal") @Nullable BigDecimal calculatePrice( + @ActionInput(name = "start", label = "@text/action.calculate-price.input.start.label", type = "java.time.Instant") Instant start, + @ActionInput(name = "end", label = "@text/action.calculate-price.input.end.label", type = "java.time.Instant") Instant end, + @ActionInput(name = "power", label = "@text/action.calculate-price.input.power.label", type = "QuantityType") QuantityType power) { PriceCalculator priceCalculator = new PriceCalculator(getPrices()); try { @@ -115,10 +117,12 @@ public class EnergiDataServiceActions implements ThingActions { } @RuleAction(label = "@text/action.calculate-cheapest-period.label", description = "@text/action.calculate-cheapest-period.description") - public @ActionOutput(name = "result", type = "java.util.Map") Map calculateCheapestPeriod( - @ActionInput(name = "earliestStart", type = "java.time.Instant") Instant earliestStart, - @ActionInput(name = "latestEnd", type = "java.time.Instant") Instant latestEnd, - @ActionInput(name = "duration", type = "java.time.Duration") Duration duration) { + public @ActionOutputs({ + @ActionOutput(name = "CheapestStart", label = "@text/action.calculate-cheapest-period.output.cheapest-start.label", type = "java.time.Instant"), + @ActionOutput(name = "MostExpensiveStart", label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label", type = "java.time.Instant"), }) Map calculateCheapestPeriod( + @ActionInput(name = "earliestStart", label = "@text/action.calculate-cheapest-period.input.earliest-start.label", type = "java.time.Instant") Instant earliestStart, + @ActionInput(name = "latestEnd", label = "@text/action.calculate-cheapest-period.input.latest-end.label", type = "java.time.Instant") Instant latestEnd, + @ActionInput(name = "duration", label = "@text/action.calculate-cheapest-period.input.duration.label", type = "java.time.Duration") Duration duration) { PriceCalculator priceCalculator = new PriceCalculator(getPrices()); try { @@ -143,11 +147,15 @@ public class EnergiDataServiceActions implements ThingActions { } @RuleAction(label = "@text/action.calculate-cheapest-period.label", description = "@text/action.calculate-cheapest-period.description") - public @ActionOutput(name = "result", type = "java.util.Map") Map calculateCheapestPeriod( - @ActionInput(name = "earliestStart", type = "java.time.Instant") Instant earliestStart, - @ActionInput(name = "latestEnd", type = "java.time.Instant") Instant latestEnd, - @ActionInput(name = "duration", type = "java.time.Duration") Duration duration, - @ActionInput(name = "power", type = "QuantityType") QuantityType power) { + public @ActionOutputs({ + @ActionOutput(name = "CheapestStart", label = "@text/action.calculate-cheapest-period.output.cheapest-start.label", type = "java.time.Instant"), + @ActionOutput(name = "LowestPrice", label = "@text/action.calculate-cheapest-period.output.lowest-price.label", type = "java.math.BigDecimal"), + @ActionOutput(name = "MostExpensiveStart", label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label", type = "java.time.Instant"), + @ActionOutput(name = "HighestPrice", label = "@text/action.calculate-cheapest-period.output.highest-price.label", type = "java.math.BigDecimal") }) Map calculateCheapestPeriod( + @ActionInput(name = "earliestStart", label = "@text/action.calculate-cheapest-period.input.earliest-start.label", type = "java.time.Instant") Instant earliestStart, + @ActionInput(name = "latestEnd", label = "@text/action.calculate-cheapest-period.input.latest-end.label", type = "java.time.Instant") Instant latestEnd, + @ActionInput(name = "duration", label = "@text/action.calculate-cheapest-period.input.duration.label", type = "java.time.Duration") Duration duration, + @ActionInput(name = "power", label = "@text/action.calculate-cheapest-period.input.power.label", type = "QuantityType") QuantityType power) { PriceCalculator priceCalculator = new PriceCalculator(getPrices()); try { @@ -159,12 +167,16 @@ public class EnergiDataServiceActions implements ThingActions { } @RuleAction(label = "@text/action.calculate-cheapest-period.label", description = "@text/action.calculate-cheapest-period.description") - public @ActionOutput(name = "result", type = "java.util.Map") Map calculateCheapestPeriod( - @ActionInput(name = "earliestStart", type = "java.time.Instant") Instant earliestStart, - @ActionInput(name = "latestEnd", type = "java.time.Instant") Instant latestEnd, - @ActionInput(name = "totalDuration", type = "java.time.Duration") Duration totalDuration, - @ActionInput(name = "durationPhases", type = "java.util.List") List durationPhases, - @ActionInput(name = "energyUsedPerPhase", type = "QuantityType") QuantityType energyUsedPerPhase) { + public @ActionOutputs({ + @ActionOutput(name = "CheapestStart", label = "@text/action.calculate-cheapest-period.output.cheapest-start.label", type = "java.time.Instant"), + @ActionOutput(name = "LowestPrice", label = "@text/action.calculate-cheapest-period.output.lowest-price.label", type = "java.math.BigDecimal"), + @ActionOutput(name = "MostExpensiveStart", label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label", type = "java.time.Instant"), + @ActionOutput(name = "HighestPrice", label = "@text/action.calculate-cheapest-period.output.highest-price.label", type = "java.math.BigDecimal") }) Map calculateCheapestPeriod( + @ActionInput(name = "earliestStart", label = "@text/action.calculate-cheapest-period.input.earliest-start.label", type = "java.time.Instant") Instant earliestStart, + @ActionInput(name = "latestEnd", label = "@text/action.calculate-cheapest-period.input.latest-end.label", type = "java.time.Instant") Instant latestEnd, + @ActionInput(name = "totalDuration", label = "@text/action.calculate-cheapest-period.input.total-duration.label", type = "java.time.Duration") Duration totalDuration, + @ActionInput(name = "durationPhases", label = "@text/action.calculate-cheapest-period.input.duration-phases.label", type = "java.util.List") List durationPhases, + @ActionInput(name = "energyUsedPerPhase", label = "@text/action.calculate-cheapest-period.input.energy-used-per-phase.label", type = "QuantityType") QuantityType energyUsedPerPhase) { PriceCalculator priceCalculator = new PriceCalculator(getPrices()); try { @@ -177,11 +189,15 @@ public class EnergiDataServiceActions implements ThingActions { } @RuleAction(label = "@text/action.calculate-cheapest-period.label", description = "@text/action.calculate-cheapest-period.description") - public @ActionOutput(name = "result", type = "java.util.Map") Map calculateCheapestPeriod( - @ActionInput(name = "earliestStart", type = "java.time.Instant") Instant earliestStart, - @ActionInput(name = "latestEnd", type = "java.time.Instant") Instant latestEnd, - @ActionInput(name = "durationPhases", type = "java.util.List") List durationPhases, - @ActionInput(name = "powerPhases", type = "java.util.List>") List> powerPhases) { + public @ActionOutputs({ + @ActionOutput(name = "CheapestStart", label = "@text/action.calculate-cheapest-period.output.cheapest-start.label", type = "java.time.Instant"), + @ActionOutput(name = "LowestPrice", label = "@text/action.calculate-cheapest-period.output.lowest-price.label", type = "java.math.BigDecimal"), + @ActionOutput(name = "MostExpensiveStart", label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label", type = "java.time.Instant"), + @ActionOutput(name = "HighestPrice", label = "@text/action.calculate-cheapest-period.output.highest-price.label", type = "java.math.BigDecimal") }) Map calculateCheapestPeriod( + @ActionInput(name = "earliestStart", label = "@text/action.calculate-cheapest-period.input.earliest-start.label", type = "java.time.Instant") Instant earliestStart, + @ActionInput(name = "latestEnd", label = "@text/action.calculate-cheapest-period.input.latest-end.label", type = "java.time.Instant") Instant latestEnd, + @ActionInput(name = "durationPhases", label = "@text/action.calculate-cheapest-period.input.duration-phases.label", type = "java.util.List") List durationPhases, + @ActionInput(name = "powerPhases", label = "@text/action.calculate-cheapest-period.input.power-phases.label", type = "java.util.List>") List> powerPhases) { if (durationPhases.size() != powerPhases.size()) { logger.warn("Number of duration phases ({}) is different from number of consumption phases ({})", durationPhases.size(), powerPhases.size()); diff --git a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties index 51bb80f6dff05..306893d280673 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties +++ b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties @@ -110,9 +110,25 @@ offline.conf-error.invalid-energinet-gln = Invalid Energinet GLN action.calculate-cheapest-period.label = calculate cheapest period action.calculate-cheapest-period.description = calculate cheapest period for using power according to a supplied timetable (excl. VAT) +action.calculate-cheapest-period.output.cheapest-start.label = Cheapest Start +action.calculate-cheapest-period.output.most-expensive-start.label = Most Expensive Start +action.calculate-cheapest-period.output.lowest-price.label = Lowest Price +action.calculate-cheapest-period.output.highest-price.label = Highest Price +action.calculate-cheapest-period.input.earliest-start.label = Earliest Start +action.calculate-cheapest-period.input.latest-end.label = Latest End +action.calculate-cheapest-period.input.duration.label = Duration +action.calculate-cheapest-period.input.power.label = Power +action.calculate-cheapest-period.input.total-duration.label = Total Duration +action.calculate-cheapest-period.input.duration-phases.label = Duration Phases +action.calculate-cheapest-period.input.energy-used-per-phase.label = Energy Used Per Phase +action.calculate-cheapest-period.input.power-phases.label = Power Phases action.calculate-price.label = calculate price action.calculate-price.description = calculate price for power consumption in period excl. VAT +action.calculate-price.output.label = Price +action.calculate-price.input.start.label = Start +action.calculate-price.input.end.label = End +action.calculate-price.input.power.label = Power action.get-prices.label = get prices action.get-prices.description = get hourly prices excl. VAT -action.get-prices.priceComponents.label = price components +action.get-prices.priceComponents.label = Price Components action.get-prices.priceComponents.description = comma-separated list of price components to include in sums