12
12
*/
13
13
package org .openhab .binding .energidataservice .internal .action ;
14
14
15
- import static org .openhab .binding .energidataservice .internal .EnergiDataServiceBindingConstants .* ;
15
+ import static org .openhab .binding .energidataservice .internal .EnergiDataServiceBindingConstants .CURRENCY_DKK ;
16
16
17
17
import java .math .BigDecimal ;
18
18
import java .time .Duration ;
36
36
import org .openhab .binding .energidataservice .internal .PriceComponent ;
37
37
import org .openhab .binding .energidataservice .internal .exception .MissingPriceException ;
38
38
import org .openhab .binding .energidataservice .internal .handler .EnergiDataServiceHandler ;
39
+ import org .openhab .core .automation .Visibility ;
39
40
import org .openhab .core .automation .annotation .ActionInput ;
40
41
import org .openhab .core .automation .annotation .ActionOutput ;
42
+ import org .openhab .core .automation .annotation .ActionOutputs ;
41
43
import org .openhab .core .automation .annotation .RuleAction ;
42
44
import org .openhab .core .library .types .QuantityType ;
43
45
import org .openhab .core .library .unit .Units ;
@@ -63,8 +65,8 @@ public class EnergiDataServiceActions implements ThingActions {
63
65
64
66
private @ Nullable EnergiDataServiceHandler handler ;
65
67
66
- @ RuleAction (label = "@text/action.get-prices.label" , description = "@text/action.get-prices.description" )
67
- public @ ActionOutput (name = "prices" , type = "java.util.Map<java.time.Instant, java.math.BigDecimal>" ) Map <Instant , BigDecimal > getPrices () {
68
+ @ RuleAction (label = "@text/action.get-prices.label" , description = "@text/action.get-prices.description" , visibility = Visibility . HIDDEN )
69
+ public @ ActionOutput (type = "java.util.Map<java.time.Instant, java.math.BigDecimal>" ) Map <Instant , BigDecimal > getPrices () {
68
70
EnergiDataServiceHandler handler = this .handler ;
69
71
if (handler == null ) {
70
72
logger .warn ("EnergiDataServiceActions ThingHandler is null." );
@@ -79,8 +81,8 @@ public class EnergiDataServiceActions implements ThingActions {
79
81
.collect (Collectors .toSet ()));
80
82
}
81
83
82
- @ RuleAction (label = "@text/action.get-prices.label" , description = "@text/action.get-prices.description" )
83
- public @ ActionOutput (name = "prices" , type = "java.util.Map<java.time.Instant, java.math.BigDecimal>" ) Map <Instant , BigDecimal > getPrices (
84
+ @ RuleAction (label = "@text/action.get-prices.label" , description = "@text/action.get-prices.description" , visibility = Visibility . HIDDEN )
85
+ public @ ActionOutput (type = "java.util.Map<java.time.Instant, java.math.BigDecimal>" ) Map <Instant , BigDecimal > getPrices (
84
86
@ ActionInput (name = "priceComponents" , label = "@text/action.get-prices.priceComponents.label" , description = "@text/action.get-prices.priceComponents.description" ) @ Nullable String priceComponents ) {
85
87
if (priceComponents == null ) {
86
88
logger .warn ("Argument 'priceComponents' is null" );
@@ -100,10 +102,10 @@ public class EnergiDataServiceActions implements ThingActions {
100
102
}
101
103
102
104
@ RuleAction (label = "@text/action.calculate-price.label" , description = "@text/action.calculate-price.description" )
103
- public @ ActionOutput (name = "price" , type = "java.math.BigDecimal" ) @ Nullable BigDecimal calculatePrice (
104
- @ ActionInput (name = "start" , type = "java.time.Instant" ) Instant start ,
105
- @ ActionInput (name = "end" , type = "java.time.Instant" ) Instant end ,
106
- @ ActionInput (name = "power" , type = "QuantityType<Power>" ) QuantityType <Power > power ) {
105
+ public @ ActionOutput (label = "@text/action.calculate- price.output.label " , type = "java.math.BigDecimal" ) @ Nullable BigDecimal calculatePrice (
106
+ @ ActionInput (name = "start" , label = "@text/action.calculate-price.input.start.label" , type = "java.time.Instant" ) Instant start ,
107
+ @ ActionInput (name = "end" , label = "@text/action.calculate-price.input.end.label" , type = "java.time.Instant" ) Instant end ,
108
+ @ ActionInput (name = "power" , label = "@text/action.calculate-price.input.power.label" , type = "QuantityType<Power>" ) QuantityType <Power > power ) {
107
109
PriceCalculator priceCalculator = new PriceCalculator (getPrices ());
108
110
109
111
try {
@@ -115,10 +117,12 @@ public class EnergiDataServiceActions implements ThingActions {
115
117
}
116
118
117
119
@ RuleAction (label = "@text/action.calculate-cheapest-period.label" , description = "@text/action.calculate-cheapest-period.description" )
118
- public @ ActionOutput (name = "result" , type = "java.util.Map<String, Object>" ) Map <String , Object > calculateCheapestPeriod (
119
- @ ActionInput (name = "earliestStart" , type = "java.time.Instant" ) Instant earliestStart ,
120
- @ ActionInput (name = "latestEnd" , type = "java.time.Instant" ) Instant latestEnd ,
121
- @ ActionInput (name = "duration" , type = "java.time.Duration" ) Duration duration ) {
120
+ public @ ActionOutputs ({
121
+ @ ActionOutput (name = "CheapestStart" , label = "@text/action.calculate-cheapest-period.output.cheapest-start.label" , type = "java.time.Instant" ),
122
+ @ ActionOutput (name = "MostExpensiveStart" , label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label" , type = "java.time.Instant" ), }) Map <String , Object > calculateCheapestPeriod (
123
+ @ ActionInput (name = "earliestStart" , label = "@text/action.calculate-cheapest-period.input.earliest-start.label" , type = "java.time.Instant" ) Instant earliestStart ,
124
+ @ ActionInput (name = "latestEnd" , label = "@text/action.calculate-cheapest-period.input.latest-end.label" , type = "java.time.Instant" ) Instant latestEnd ,
125
+ @ ActionInput (name = "duration" , label = "@text/action.calculate-cheapest-period.input.duration.label" , type = "java.time.Duration" ) Duration duration ) {
122
126
PriceCalculator priceCalculator = new PriceCalculator (getPrices ());
123
127
124
128
try {
@@ -143,11 +147,15 @@ public class EnergiDataServiceActions implements ThingActions {
143
147
}
144
148
145
149
@ RuleAction (label = "@text/action.calculate-cheapest-period.label" , description = "@text/action.calculate-cheapest-period.description" )
146
- public @ ActionOutput (name = "result" , type = "java.util.Map<String, Object>" ) Map <String , Object > calculateCheapestPeriod (
147
- @ ActionInput (name = "earliestStart" , type = "java.time.Instant" ) Instant earliestStart ,
148
- @ ActionInput (name = "latestEnd" , type = "java.time.Instant" ) Instant latestEnd ,
149
- @ ActionInput (name = "duration" , type = "java.time.Duration" ) Duration duration ,
150
- @ ActionInput (name = "power" , type = "QuantityType<Power>" ) QuantityType <Power > power ) {
150
+ public @ ActionOutputs ({
151
+ @ ActionOutput (name = "CheapestStart" , label = "@text/action.calculate-cheapest-period.output.cheapest-start.label" , type = "java.time.Instant" ),
152
+ @ ActionOutput (name = "LowestPrice" , label = "@text/action.calculate-cheapest-period.output.lowest-price.label" , type = "java.math.BigDecimal" ),
153
+ @ ActionOutput (name = "MostExpensiveStart" , label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label" , type = "java.time.Instant" ),
154
+ @ ActionOutput (name = "HighestPrice" , label = "@text/action.calculate-cheapest-period.output.highest-price.label" , type = "java.math.BigDecimal" ) }) Map <String , Object > calculateCheapestPeriod (
155
+ @ ActionInput (name = "earliestStart" , label = "@text/action.calculate-cheapest-period.input.earliest-start.label" , type = "java.time.Instant" ) Instant earliestStart ,
156
+ @ ActionInput (name = "latestEnd" , label = "@text/action.calculate-cheapest-period.input.latest-end.label" , type = "java.time.Instant" ) Instant latestEnd ,
157
+ @ ActionInput (name = "duration" , label = "@text/action.calculate-cheapest-period.input.duration.label" , type = "java.time.Duration" ) Duration duration ,
158
+ @ ActionInput (name = "power" , label = "@text/action.calculate-cheapest-period.input.power.label" , type = "QuantityType<Power>" ) QuantityType <Power > power ) {
151
159
PriceCalculator priceCalculator = new PriceCalculator (getPrices ());
152
160
153
161
try {
@@ -159,12 +167,16 @@ public class EnergiDataServiceActions implements ThingActions {
159
167
}
160
168
161
169
@ RuleAction (label = "@text/action.calculate-cheapest-period.label" , description = "@text/action.calculate-cheapest-period.description" )
162
- public @ ActionOutput (name = "result" , type = "java.util.Map<String, Object>" ) Map <String , Object > calculateCheapestPeriod (
163
- @ ActionInput (name = "earliestStart" , type = "java.time.Instant" ) Instant earliestStart ,
164
- @ ActionInput (name = "latestEnd" , type = "java.time.Instant" ) Instant latestEnd ,
165
- @ ActionInput (name = "totalDuration" , type = "java.time.Duration" ) Duration totalDuration ,
166
- @ ActionInput (name = "durationPhases" , type = "java.util.List<java.time.Duration>" ) List <Duration > durationPhases ,
167
- @ ActionInput (name = "energyUsedPerPhase" , type = "QuantityType<Energy>" ) QuantityType <Energy > energyUsedPerPhase ) {
170
+ public @ ActionOutputs ({
171
+ @ ActionOutput (name = "CheapestStart" , label = "@text/action.calculate-cheapest-period.output.cheapest-start.label" , type = "java.time.Instant" ),
172
+ @ ActionOutput (name = "LowestPrice" , label = "@text/action.calculate-cheapest-period.output.lowest-price.label" , type = "java.math.BigDecimal" ),
173
+ @ ActionOutput (name = "MostExpensiveStart" , label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label" , type = "java.time.Instant" ),
174
+ @ ActionOutput (name = "HighestPrice" , label = "@text/action.calculate-cheapest-period.output.highest-price.label" , type = "java.math.BigDecimal" ) }) Map <String , Object > calculateCheapestPeriod (
175
+ @ ActionInput (name = "earliestStart" , label = "@text/action.calculate-cheapest-period.input.earliest-start.label" , type = "java.time.Instant" ) Instant earliestStart ,
176
+ @ ActionInput (name = "latestEnd" , label = "@text/action.calculate-cheapest-period.input.latest-end.label" , type = "java.time.Instant" ) Instant latestEnd ,
177
+ @ ActionInput (name = "totalDuration" , label = "@text/action.calculate-cheapest-period.input.total-duration.label" , type = "java.time.Duration" ) Duration totalDuration ,
178
+ @ ActionInput (name = "durationPhases" , label = "@text/action.calculate-cheapest-period.input.duration-phases.label" , type = "java.util.List<java.time.Duration>" ) List <Duration > durationPhases ,
179
+ @ ActionInput (name = "energyUsedPerPhase" , label = "@text/action.calculate-cheapest-period.input.energy-used-per-phase.label" , type = "QuantityType<Energy>" ) QuantityType <Energy > energyUsedPerPhase ) {
168
180
PriceCalculator priceCalculator = new PriceCalculator (getPrices ());
169
181
170
182
try {
@@ -177,11 +189,15 @@ public class EnergiDataServiceActions implements ThingActions {
177
189
}
178
190
179
191
@ RuleAction (label = "@text/action.calculate-cheapest-period.label" , description = "@text/action.calculate-cheapest-period.description" )
180
- public @ ActionOutput (name = "result" , type = "java.util.Map<String, Object>" ) Map <String , Object > calculateCheapestPeriod (
181
- @ ActionInput (name = "earliestStart" , type = "java.time.Instant" ) Instant earliestStart ,
182
- @ ActionInput (name = "latestEnd" , type = "java.time.Instant" ) Instant latestEnd ,
183
- @ ActionInput (name = "durationPhases" , type = "java.util.List<java.time.Duration>" ) List <Duration > durationPhases ,
184
- @ ActionInput (name = "powerPhases" , type = "java.util.List<QuantityType<Power>>" ) List <QuantityType <Power >> powerPhases ) {
192
+ public @ ActionOutputs ({
193
+ @ ActionOutput (name = "CheapestStart" , label = "@text/action.calculate-cheapest-period.output.cheapest-start.label" , type = "java.time.Instant" ),
194
+ @ ActionOutput (name = "LowestPrice" , label = "@text/action.calculate-cheapest-period.output.lowest-price.label" , type = "java.math.BigDecimal" ),
195
+ @ ActionOutput (name = "MostExpensiveStart" , label = "@text/action.calculate-cheapest-period.output.most-expensive-start.label" , type = "java.time.Instant" ),
196
+ @ ActionOutput (name = "HighestPrice" , label = "@text/action.calculate-cheapest-period.output.highest-price.label" , type = "java.math.BigDecimal" ) }) Map <String , Object > calculateCheapestPeriod (
197
+ @ ActionInput (name = "earliestStart" , label = "@text/action.calculate-cheapest-period.input.earliest-start.label" , type = "java.time.Instant" ) Instant earliestStart ,
198
+ @ ActionInput (name = "latestEnd" , label = "@text/action.calculate-cheapest-period.input.latest-end.label" , type = "java.time.Instant" ) Instant latestEnd ,
199
+ @ ActionInput (name = "durationPhases" , label = "@text/action.calculate-cheapest-period.input.duration-phases.label" , type = "java.util.List<java.time.Duration>" ) List <Duration > durationPhases ,
200
+ @ ActionInput (name = "powerPhases" , label = "@text/action.calculate-cheapest-period.input.power-phases.label" , type = "java.util.List<QuantityType<Power>>" ) List <QuantityType <Power >> powerPhases ) {
185
201
if (durationPhases .size () != powerPhases .size ()) {
186
202
logger .warn ("Number of duration phases ({}) is different from number of consumption phases ({})" ,
187
203
durationPhases .size (), powerPhases .size ());
0 commit comments