mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[aWATTar] make service fee configurable
Signed-off-by: Thomas Leber <thomas@tl-photography.at>
This commit is contained in:
parent
c81b9799f4
commit
39ab65fdf8
@ -36,8 +36,7 @@ Auto discovery is not supported.
|
|||||||
| 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. |
|
| 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. |
|
||||||
| 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** |
|
| 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** |
|
||||||
| country | The country prices should be received for. Use `DE` for Germany or `AT` for Austria. `DE` is the default. |
|
| country | The country prices should be received for. Use `DE` for Germany or `AT` for Austria. `DE` is the default. |
|
||||||
|
| 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`. |
|
||||||
Note: The prices include already the 3% and 1.5 €cent per kWh fees for the aWATTar service.
|
|
||||||
|
|
||||||
### Prices Thing
|
### Prices Thing
|
||||||
|
|
||||||
@ -110,7 +109,7 @@ All prices are available in each of the following channel groups:
|
|||||||
awattar.things:
|
awattar.things:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Bridge awattar:bridge:bridge1 "aWATTar Bridge" [ country="DE", vatPercent="19", basePrice="17.22"] {
|
Bridge awattar:bridge:bridge1 "aWATTar Bridge" [ country="DE", vatPercent="19", basePrice="17.22", serviceFee="3" ] {
|
||||||
Thing prices price1 "aWATTar Price" []
|
Thing prices price1 "aWATTar Price" []
|
||||||
// The car should be loaded for 4 hours during the night
|
// The car should be loaded for 4 hours during the night
|
||||||
Thing bestprice carloader "Car Loader" [ rangeStart="22", rangeDuration="8", length="4", consecutive="true" ]
|
Thing bestprice carloader "Car Loader" [ rangeStart="22", rangeDuration="8", length="4", consecutive="true" ]
|
||||||
|
@ -23,5 +23,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
public class AwattarBridgeConfiguration {
|
public class AwattarBridgeConfiguration {
|
||||||
public double basePrice;
|
public double basePrice;
|
||||||
public double vatPercent;
|
public double vatPercent;
|
||||||
|
public double serviceFee;
|
||||||
public String country = "";
|
public String country = "";
|
||||||
}
|
}
|
||||||
|
@ -57,13 +57,12 @@ public class AwattarApi {
|
|||||||
|
|
||||||
private double vatFactor;
|
private double vatFactor;
|
||||||
private double basePrice;
|
private double basePrice;
|
||||||
|
private double serviceFee;
|
||||||
|
|
||||||
private ZoneId zone;
|
private ZoneId zone;
|
||||||
|
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
|
|
||||||
private String country;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic exception for the aWATTar API.
|
* Generic exception for the aWATTar API.
|
||||||
*/
|
*/
|
||||||
@ -84,12 +83,12 @@ public class AwattarApi {
|
|||||||
public AwattarApi(HttpClient httpClient, ZoneId zone, AwattarBridgeConfiguration config) {
|
public AwattarApi(HttpClient httpClient, ZoneId zone, AwattarBridgeConfiguration config) {
|
||||||
this.zone = zone;
|
this.zone = zone;
|
||||||
this.httpClient = httpClient;
|
this.httpClient = httpClient;
|
||||||
this.country = config.country;
|
|
||||||
|
|
||||||
this.gson = new Gson();
|
this.gson = new Gson();
|
||||||
|
|
||||||
vatFactor = 1 + (config.vatPercent / 100);
|
vatFactor = 1 + (config.vatPercent / 100);
|
||||||
basePrice = config.basePrice;
|
basePrice = config.basePrice;
|
||||||
|
serviceFee = config.serviceFee;
|
||||||
|
|
||||||
if (config.country.equals("DE")) {
|
if (config.country.equals("DE")) {
|
||||||
this.url = URL_DE;
|
this.url = URL_DE;
|
||||||
@ -145,17 +144,11 @@ public class AwattarApi {
|
|||||||
double grossMarket = netMarket * vatFactor;
|
double grossMarket = netMarket * vatFactor;
|
||||||
double netTotal = netMarket + basePrice;
|
double netTotal = netMarket + basePrice;
|
||||||
|
|
||||||
// in Austria the fee is added as absolute value
|
// add service fee for the aWATTar service (Ausgleichskomponente)
|
||||||
if ("AT".equals(country)) {
|
if (serviceFee > 0) {
|
||||||
// add 3% absolute fee for the aWATTar service (Ausgleichskomponente)
|
netTotal += Math.abs(netTotal) * (serviceFee / 100);
|
||||||
netTotal += Math.abs(netTotal) * 0.03;
|
|
||||||
} else if ("DE".equals(country)) {
|
|
||||||
// add 3% fee for the aWATTar service (Ausgleichskomponente)
|
|
||||||
netTotal = netTotal * 1.03;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
netTotal = netTotal + 1.5; // add 1.5 €/MWh for aWATTar service (Beschaffungskomponente)
|
|
||||||
|
|
||||||
double grossTotal = netTotal * vatFactor;
|
double grossTotal = netTotal * vatFactor;
|
||||||
|
|
||||||
result.add(new AwattarPrice(netMarket, grossMarket, netTotal, grossTotal,
|
result.add(new AwattarPrice(netMarket, grossMarket, netTotal, grossTotal,
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
<description>Specifies the net base price per kWh</description>
|
<description>Specifies the net base price per kWh</description>
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter name="serviceFee" type="decimal" min="0" max="100">
|
||||||
|
<label>Service Fee</label>
|
||||||
|
<description>Specifies the service fee in percent.</description>
|
||||||
|
<default>0</default>
|
||||||
|
</parameter>
|
||||||
</config-description>
|
</config-description>
|
||||||
|
|
||||||
<config-description uri="thing-type:awattar:bestprice">
|
<config-description uri="thing-type:awattar:bestprice">
|
||||||
|
@ -12,6 +12,8 @@ bridge-type.config.awattar.bridge.basePrice.label = Base price
|
|||||||
bridge-type.config.awattar.bridge.basePrice.description = Specifies the net base price per kWh
|
bridge-type.config.awattar.bridge.basePrice.description = Specifies the net base price per kWh
|
||||||
bridge-type.config.awattar.bridge.timeZone.label = Time zone
|
bridge-type.config.awattar.bridge.timeZone.label = Time zone
|
||||||
bridge-type.config.awattar.bridge.timeZone.description = Time zone to apply to the hour definitions. Default CET aligns to the aWATTar API
|
bridge-type.config.awattar.bridge.timeZone.description = Time zone to apply to the hour definitions. Default CET aligns to the aWATTar API
|
||||||
|
brifge-type.config.awattar.bridge.serviceFee.label = Service fee
|
||||||
|
bridge-type.config.awattar.bridge.serviceFee.description = Specifies the service fee in percent
|
||||||
|
|
||||||
# thing types
|
# thing types
|
||||||
thing-type.awattar.prices.label = aWATTar Hourly Prices
|
thing-type.awattar.prices.label = aWATTar Hourly Prices
|
||||||
|
@ -92,6 +92,7 @@ class AwattarApiTest extends JavaTest {
|
|||||||
|
|
||||||
config.basePrice = 0.0;
|
config.basePrice = 0.0;
|
||||||
config.vatPercent = 0.0;
|
config.vatPercent = 0.0;
|
||||||
|
config.serviceFee = 0.0;
|
||||||
config.country = "DE";
|
config.country = "DE";
|
||||||
|
|
||||||
api = new AwattarApi(httpClientMock, ZoneId.of("GMT+2"), config);
|
api = new AwattarApi(httpClientMock, ZoneId.of("GMT+2"), config);
|
||||||
|
Loading…
Reference in New Issue
Block a user