From c81b9799f481be5e84c4913b41dad1cc910baf4b Mon Sep 17 00:00:00 2001 From: Thomas Leber Date: Sun, 13 Oct 2024 14:14:56 +0200 Subject: [PATCH 1/3] [aWATTar] include fees in calculation Signed-off-by: Thomas Leber --- bundles/org.openhab.binding.awattar/README.md | 2 ++ .../binding/awattar/internal/AwattarPrice.java | 4 ++-- .../binding/awattar/internal/api/AwattarApi.java | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.awattar/README.md b/bundles/org.openhab.binding.awattar/README.md index f68bbd6c6fa..c6aa625e504 100644 --- a/bundles/org.openhab.binding.awattar/README.md +++ b/bundles/org.openhab.binding.awattar/README.md @@ -37,6 +37,8 @@ Auto discovery is not supported. | 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. | +Note: The prices include already the 3% and 1.5 €cent per kWh fees for the aWATTar service. + ### Prices Thing The prices thing does not need any configuration. diff --git a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarPrice.java b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarPrice.java index 912350987b1..94c3ef81c28 100644 --- a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarPrice.java +++ b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarPrice.java @@ -23,8 +23,8 @@ import org.openhab.binding.awattar.internal.handler.TimeRange; * * @param netPrice the net price in €/kWh * @param grossPrice the gross price in €/kWh - * @param netTotal the net total price in € - * @param grossTotal the gross total price in € + * @param netTotal the net total price in €/kWh + * @param grossTotal the gross total price in €/kWh * @param timerange the time range of the price */ @NonNullByDefault diff --git a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java index 5c2b6dae5e6..a852973e2dd 100644 --- a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java +++ b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java @@ -62,6 +62,8 @@ public class AwattarApi { private Gson gson; + private String country; + /** * Generic exception for the aWATTar API. */ @@ -82,6 +84,7 @@ public class AwattarApi { public AwattarApi(HttpClient httpClient, ZoneId zone, AwattarBridgeConfiguration config) { this.zone = zone; this.httpClient = httpClient; + this.country = config.country; this.gson = new Gson(); @@ -141,6 +144,18 @@ public class AwattarApi { double netMarket = d.marketprice / 10.0; double grossMarket = netMarket * vatFactor; double netTotal = netMarket + basePrice; + + // in Austria the fee is added as absolute value + if ("AT".equals(country)) { + // add 3% absolute fee for the aWATTar service (Ausgleichskomponente) + 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; result.add(new AwattarPrice(netMarket, grossMarket, netTotal, grossTotal, From 39ab65fdf85bf943bb0b7cf213de97b4d1343340 Mon Sep 17 00:00:00 2001 From: Thomas Leber Date: Sat, 26 Oct 2024 21:04:27 +0200 Subject: [PATCH 2/3] [aWATTar] make service fee configurable Signed-off-by: Thomas Leber --- bundles/org.openhab.binding.awattar/README.md | 5 ++--- .../internal/AwattarBridgeConfiguration.java | 1 + .../awattar/internal/api/AwattarApi.java | 17 +++++------------ .../src/main/resources/OH-INF/config/config.xml | 5 +++++ .../resources/OH-INF/i18n/awattar.properties | 2 ++ .../awattar/internal/api/AwattarApiTest.java | 1 + 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bundles/org.openhab.binding.awattar/README.md b/bundles/org.openhab.binding.awattar/README.md index c6aa625e504..0e04e848d61 100644 --- a/bundles/org.openhab.binding.awattar/README.md +++ b/bundles/org.openhab.binding.awattar/README.md @@ -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. | | 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. | - -Note: The prices include already the 3% and 1.5 €cent per kWh fees for the aWATTar service. +| 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`. | ### Prices Thing @@ -110,7 +109,7 @@ All prices are available in each of the following channel groups: awattar.things: ```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" [] // The car should be loaded for 4 hours during the night Thing bestprice carloader "Car Loader" [ rangeStart="22", rangeDuration="8", length="4", consecutive="true" ] diff --git a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarBridgeConfiguration.java b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarBridgeConfiguration.java index f1f815bc715..bc06c4d5e14 100644 --- a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarBridgeConfiguration.java +++ b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/AwattarBridgeConfiguration.java @@ -23,5 +23,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; public class AwattarBridgeConfiguration { public double basePrice; public double vatPercent; + public double serviceFee; public String country = ""; } diff --git a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java index a852973e2dd..144094a1b34 100644 --- a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java +++ b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/api/AwattarApi.java @@ -57,13 +57,12 @@ public class AwattarApi { private double vatFactor; private double basePrice; + private double serviceFee; private ZoneId zone; private Gson gson; - private String country; - /** * Generic exception for the aWATTar API. */ @@ -84,12 +83,12 @@ public class AwattarApi { public AwattarApi(HttpClient httpClient, ZoneId zone, AwattarBridgeConfiguration config) { this.zone = zone; this.httpClient = httpClient; - this.country = config.country; this.gson = new Gson(); vatFactor = 1 + (config.vatPercent / 100); basePrice = config.basePrice; + serviceFee = config.serviceFee; if (config.country.equals("DE")) { this.url = URL_DE; @@ -145,17 +144,11 @@ public class AwattarApi { double grossMarket = netMarket * vatFactor; double netTotal = netMarket + basePrice; - // in Austria the fee is added as absolute value - if ("AT".equals(country)) { - // add 3% absolute fee for the aWATTar service (Ausgleichskomponente) - netTotal += Math.abs(netTotal) * 0.03; - } else if ("DE".equals(country)) { - // add 3% fee for the aWATTar service (Ausgleichskomponente) - netTotal = netTotal * 1.03; + // add service fee for the aWATTar service (Ausgleichskomponente) + if (serviceFee > 0) { + netTotal += Math.abs(netTotal) * (serviceFee / 100); } - netTotal = netTotal + 1.5; // add 1.5 €/MWh for aWATTar service (Beschaffungskomponente) - double grossTotal = netTotal * vatFactor; result.add(new AwattarPrice(netMarket, grossMarket, netTotal, grossTotal, diff --git a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/config/config.xml index 5fa754579e4..d06508e3464 100644 --- a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/config/config.xml @@ -24,6 +24,11 @@ Specifies the net base price per kWh 0 + + + Specifies the service fee in percent. + 0 + diff --git a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties index 75fceabe8e2..62b523c9e6f 100644 --- a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties +++ b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties @@ -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.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 +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-type.awattar.prices.label = aWATTar Hourly Prices diff --git a/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/api/AwattarApiTest.java b/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/api/AwattarApiTest.java index f543757746d..488ddf69cc9 100644 --- a/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/api/AwattarApiTest.java +++ b/bundles/org.openhab.binding.awattar/src/test/java/org/openhab/binding/awattar/internal/api/AwattarApiTest.java @@ -92,6 +92,7 @@ class AwattarApiTest extends JavaTest { config.basePrice = 0.0; config.vatPercent = 0.0; + config.serviceFee = 0.0; config.country = "DE"; api = new AwattarApi(httpClientMock, ZoneId.of("GMT+2"), config); From c54d85ac1a612a2db49658ec70824d1926ce062f Mon Sep 17 00:00:00 2001 From: Wolfgang Klimt Date: Sun, 1 Dec 2024 14:23:39 +0100 Subject: [PATCH 3/3] Corrected Typo Signed-off-by: Wolfgang Klimt --- .../src/main/resources/OH-INF/i18n/awattar.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties index 62b523c9e6f..e6b4b2780b9 100644 --- a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties +++ b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/i18n/awattar.properties @@ -12,7 +12,7 @@ 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.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 -brifge-type.config.awattar.bridge.serviceFee.label = Service fee +bridge-type.config.awattar.bridge.serviceFee.label = Service fee bridge-type.config.awattar.bridge.serviceFee.description = Specifies the service fee in percent # thing types