For customers using electricity for heating, a reduced electricity tax rate may apply after consuming the first 4000 kWh within a year.
When you are entitled to reduced electricity tax, this option should be set.
-This will ensure that thing action calculations use the reduced electricity tax rate when price elements are not explicitly provided.
+This will ensure that thing action calculations use the reduced electricity tax rate when price components are not explicitly provided.
It will not impact channels, see [Electricity Tax](#electricity-tax) for further information.
## Channels
## Thing Actions
Thing actions can be used to perform calculations as well as import prices directly into rules without deserializing JSON from the [hourly-prices](#hourly-prices) channel.
-This is more convenient, much faster, and provides automatic summation of the price elements of interest.
+This is more convenient, much faster, and provides automatic summation of the price components of interest.
Actions use cached data for performing operations.
Since data is only fetched when an item is linked to a channel, there might not be any cached data available.
| Parameter | Type | Description |
|--------------------|-----------------------------|--------------------------------------------------------|
-| priceElements | `String` | Comma-separated list of price elements to include |
+| priceComponents | `String` | Comma-separated list of price components to include |
**Result:** `Map<Instant, BigDecimal>`
-The parameter `priceElements` is a case-insensitive comma-separated list of price elements to include in the returned hourly prices.
-These elements can be requested:
+The parameter `priceComponents` is a case-insensitive comma-separated list of price components to include in the returned hourly prices.
+These components can be requested:
-| Price element | Description |
+| Price component | Description |
|-----------------------|-------------------------|
| SpotPrice | Spot price |
| NetTariff | Net tariff |
| ReducedElectricityTax | Reduced electricity tax |
| TransmissionNetTariff | Transmission net tariff |
-Using `null` as parameter returns the total prices including all price elements.
+Using `null` as parameter returns the total prices including all price components.
If **Reduced Electricity Tax** is set in Thing configuration, `ElectricityTax` will be excluded, otherwise `ReducedElectricityTax`.
This logic ensures consistent and comparable results not affected by artifical changes in the rate for electricity tax two times per year.
private @Nullable EnergiDataServiceHandler handler;
- private enum PriceElement {
+ private enum PriceComponent {
SPOT_PRICE("spotprice", null),
NET_TARIFF("nettariff", DatahubTariff.NET_TARIFF),
SYSTEM_TARIFF("systemtariff", DatahubTariff.SYSTEM_TARIFF),
REDUCED_ELECTRICITY_TAX("reducedelectricitytax", DatahubTariff.REDUCED_ELECTRICITY_TAX),
TRANSMISSION_NET_TARIFF("transmissionnettariff", DatahubTariff.TRANSMISSION_NET_TARIFF);
- private static final Map<String, PriceElement> NAME_MAP = Stream.of(values())
- .collect(Collectors.toMap(PriceElement::toString, Function.identity()));
+ private static final Map<String, PriceComponent> NAME_MAP = Stream.of(values())
+ .collect(Collectors.toMap(PriceComponent::toString, Function.identity()));
private String name;
private @Nullable DatahubTariff datahubTariff;
- private PriceElement(String name, @Nullable DatahubTariff datahubTariff) {
+ private PriceComponent(String name, @Nullable DatahubTariff datahubTariff) {
this.name = name;
this.datahubTariff = datahubTariff;
}
return name;
}
- public static PriceElement fromString(final String name) {
- PriceElement myEnum = NAME_MAP.get(name.toLowerCase());
+ public static PriceComponent fromString(final String name) {
+ PriceComponent myEnum = NAME_MAP.get(name.toLowerCase());
if (null == myEnum) {
throw new IllegalArgumentException(String.format("'%s' has no corresponding value. Accepted values: %s",
name, Arrays.asList(values())));
boolean isReducedElectricityTax = handler.isReducedElectricityTax();
- return getPrices(Arrays.stream(PriceElement.values())
- .filter(element -> element != (isReducedElectricityTax ? PriceElement.ELECTRICITY_TAX
- : PriceElement.REDUCED_ELECTRICITY_TAX))
+ return getPrices(Arrays.stream(PriceComponent.values())
+ .filter(component -> component != (isReducedElectricityTax ? PriceComponent.ELECTRICITY_TAX
+ : PriceComponent.REDUCED_ELECTRICITY_TAX))
.collect(Collectors.toSet()));
}
@RuleAction(label = "@text/action.get-prices.label", description = "@text/action.get-prices.description")
public @ActionOutput(name = "prices", type = "java.util.Map<java.time.Instant, java.math.BigDecimal>") Map<Instant, BigDecimal> getPrices(
- @ActionInput(name = "priceElements", label = "@text/action.get-prices.priceElements.label", description = "@text/action.get-prices.priceElements.description") @Nullable String priceElements) {
- if (priceElements == null) {
- logger.warn("Argument 'priceElements' is null");
+ @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");
return Map.of();
}
- Set<PriceElement> priceElementsSet;
+ Set<PriceComponent> priceComponentsSet;
try {
- priceElementsSet = new HashSet<PriceElement>(
- Arrays.stream(priceElements.split(",")).map(PriceElement::fromString).toList());
+ priceComponentsSet = new HashSet<PriceComponent>(
+ Arrays.stream(priceComponents.split(",")).map(PriceComponent::fromString).toList());
} catch (IllegalArgumentException e) {
logger.warn("{}", e.getMessage());
return Map.of();
}
- return getPrices(priceElementsSet);
+ return getPrices(priceComponentsSet);
}
@RuleAction(label = "@text/action.calculate-price.label", description = "@text/action.calculate-price.description")
}
}
- private Map<Instant, BigDecimal> getPrices(Set<PriceElement> priceElements) {
+ private Map<Instant, BigDecimal> getPrices(Set<PriceComponent> priceComponents) {
EnergiDataServiceHandler handler = this.handler;
if (handler == null) {
logger.warn("EnergiDataServiceActions ThingHandler is null.");
Map<Instant, BigDecimal> prices;
boolean spotPricesRequired;
- if (priceElements.contains(PriceElement.SPOT_PRICE)) {
- if (priceElements.size() > 1 && !handler.getCurrency().equals(CURRENCY_DKK)) {
+ if (priceComponents.contains(PriceComponent.SPOT_PRICE)) {
+ if (priceComponents.size() > 1 && !handler.getCurrency().equals(CURRENCY_DKK)) {
logger.warn("Cannot calculate sum when spot price currency is {}", handler.getCurrency());
return Map.of();
}
prices = new HashMap<>();
}
- for (PriceElement priceElement : PriceElement.values()) {
- DatahubTariff datahubTariff = priceElement.getDatahubTariff();
+ for (PriceComponent priceComponent : PriceComponent.values()) {
+ DatahubTariff datahubTariff = priceComponent.getDatahubTariff();
if (datahubTariff == null) {
continue;
}
- if (priceElements.contains(priceElement)) {
+ if (priceComponents.contains(priceComponent)) {
Map<Instant, BigDecimal> tariffMap = handler.getTariffs(datahubTariff);
mergeMaps(prices, tariffMap, !spotPricesRequired);
}
* Static get prices method for DSL rule compatibility.
*
* @param actions
- * @param priceElements Comma-separated list of price elements to include in prices.
+ * @param priceComponents Comma-separated list of price components to include in prices.
* @return Map of prices
*/
- public static Map<Instant, BigDecimal> getPrices(@Nullable ThingActions actions, @Nullable String priceElements) {
+ public static Map<Instant, BigDecimal> getPrices(@Nullable ThingActions actions, @Nullable String priceComponents) {
if (actions instanceof EnergiDataServiceActions serviceActions) {
- if (priceElements != null && !priceElements.isBlank()) {
- return serviceActions.getPrices(priceElements);
+ if (priceComponents != null && !priceComponents.isBlank()) {
+ return serviceActions.getPrices(priceComponents);
} else {
return serviceActions.getPrices();
}