Skip to content

Commit c147475

Browse files
[aWATTar] include fees in calculation (openhab#17557)
* [aWATTar] include fees in calculation Signed-off-by: Thomas Leber <[email protected]>
1 parent e95fb3c commit c147475

File tree

7 files changed

+21
-3
lines changed

7 files changed

+21
-3
lines changed

bundles/org.openhab.binding.awattar/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Auto discovery is not supported.
3636
| basePrice | The net(!) base price you have to pay for every kWh. Optional, but you most probably want to set it based on you delivery contract. |
3737
| timeZone | The time zone the hour definitions of the things below refer to. Default is `CET`, as it corresponds to the aWATTar API. It is strongly recommended not to change this. However, if you do so, be aware that the prices delivered by the API will not cover a whole calendar day in this timezone. **Advanced** |
3838
| country | The country prices should be received for. Use `DE` for Germany or `AT` for Austria. `DE` is the default. |
39+
| serviceFee | The service fee in percent. Will be added to the total price. Will be calculated on top of the absolute price per hour. Default is `0`. |
3940

4041
### Prices Thing
4142

@@ -108,7 +109,7 @@ All prices are available in each of the following channel groups:
108109
awattar.things:
109110

110111
```java
111-
Bridge awattar:bridge:bridge1 "aWATTar Bridge" [ country="DE", vatPercent="19", basePrice="17.22"] {
112+
Bridge awattar:bridge:bridge1 "aWATTar Bridge" [ country="DE", vatPercent="19", basePrice="17.22", serviceFee="3" ] {
112113
Thing prices price1 "aWATTar Price" []
113114
// The car should be loaded for 4 hours during the night
114115
Thing bestprice carloader "Car Loader" [ rangeStart="22", rangeDuration="8", length="4", consecutive="true" ]

bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarBridgeConfiguration.java

+1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
public class AwattarBridgeConfiguration {
2424
public double basePrice;
2525
public double vatPercent;
26+
public double serviceFee;
2627
public String country = "";
2728
}

bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarPrice.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*
2424
* @param netPrice the net price in €/kWh
2525
* @param grossPrice the gross price in €/kWh
26-
* @param netTotal the net total price in €
27-
* @param grossTotal the gross total price in €
26+
* @param netTotal the net total price in €/kWh
27+
* @param grossTotal the gross total price in €/kWh
2828
* @param timerange the time range of the price
2929
*/
3030
@NonNullByDefault

bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java

+8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class AwattarApi {
5757

5858
private double vatFactor;
5959
private double basePrice;
60+
private double serviceFee;
6061

6162
private AwattarTimeProvider timeProvider;
6263

@@ -87,6 +88,7 @@ public AwattarApi(HttpClient httpClient, AwattarTimeProvider timeProvider, Awatt
8788

8889
vatFactor = 1 + (config.vatPercent / 100);
8990
basePrice = config.basePrice;
91+
serviceFee = config.serviceFee;
9092

9193
if (config.country.equals("DE")) {
9294
this.url = URL_DE;
@@ -141,6 +143,12 @@ public SortedSet<AwattarPrice> getData() throws AwattarApiException {
141143
double netMarket = d.marketprice / 10.0;
142144
double grossMarket = netMarket * vatFactor;
143145
double netTotal = netMarket + basePrice;
146+
147+
// add service fee for the aWATTar service (Ausgleichskomponente)
148+
if (serviceFee > 0) {
149+
netTotal += Math.abs(netTotal) * (serviceFee / 100);
150+
}
151+
144152
double grossTotal = netTotal * vatFactor;
145153

146154
result.add(new AwattarPrice(netMarket, grossMarket, netTotal, grossTotal,

bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/config/config.xml

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
<description>Specifies the net base price per kWh</description>
2525
<default>0</default>
2626
</parameter>
27+
<parameter name="serviceFee" type="decimal" min="0" max="100">
28+
<label>Service Fee</label>
29+
<description>Specifies the service fee in percent.</description>
30+
<default>0</default>
31+
</parameter>
2732
</config-description>
2833

2934
<config-description uri="thing-type:awattar:bestprice">

bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bridge-type.config.awattar.bridge.basePrice.label = Base price
1212
bridge-type.config.awattar.bridge.basePrice.description = Specifies the net base price per kWh
1313
bridge-type.config.awattar.bridge.timeZone.label = Time zone
1414
bridge-type.config.awattar.bridge.timeZone.description = Time zone to apply to the hour definitions. Default CET aligns to the aWATTar API
15+
bridge-type.config.awattar.bridge.serviceFee.label = Service fee
16+
bridge-type.config.awattar.bridge.serviceFee.description = Specifies the service fee in percent
1517

1618
# thing types
1719
thing-type.awattar.prices.label = aWATTar Hourly Prices

bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/api/AwattarApiTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public void setUp() throws IOException, ExecutionException, InterruptedException
9595

9696
config.basePrice = 0.0;
9797
config.vatPercent = 0.0;
98+
config.serviceFee = 0.0;
9899
config.country = "DE";
99100

100101
api = new AwattarApi(httpClientMock, timeProviderMock, config);

0 commit comments

Comments
 (0)