### Channel Group `electricity`
-| Channel | Type | Description | Advanced |
-|--------------------------|--------|----------------------------------------------------------------------------------------|----------|
-| spot-price | Number | Current spot price in DKK or EUR per kWh | no |
-| grid-tariff | Number | Current grid tariff in DKK per kWh. Only available when `gridCompanyGLN` is configured | no |
-| system-tariff | Number | Current system tariff in DKK per kWh | no |
-| transmission-grid-tariff | Number | Current transmission grid tariff in DKK per kWh | no |
-| electricity-tax | Number | Current electricity tax in DKK per kWh | no |
-| reduced-electricity-tax | Number | Current reduced electricity tax in DKK per kWh. For electric heating customers only | no |
-| hourly-prices | String | JSON array with hourly prices from 24 hours ago and onward | yes |
+| Channel | Type | Description | Advanced |
+|--------------------------|--------------------|--------------------------------------------------------------------------------|----------|
+| spot-price | Number:EnergyPrice | Spot price in DKK or EUR per kWh | no |
+| grid-tariff | Number:EnergyPrice | Grid tariff in DKK per kWh. Only available when `gridCompanyGLN` is configured | no |
+| system-tariff | Number:EnergyPrice | System tariff in DKK per kWh | no |
+| transmission-grid-tariff | Number:EnergyPrice | Transmission grid tariff in DKK per kWh | no |
+| electricity-tax | Number:EnergyPrice | Electricity tax in DKK per kWh | no |
+| reduced-electricity-tax | Number:EnergyPrice | Reduced electricity tax in DKK per kWh. For electric heating customers only | no |
+| hourly-prices | String | JSON array with hourly prices from 24 hours ago and onward | yes |
_Please note:_ There is no channel providing the total price.
Instead, create a group item with `SUM` as aggregate function and add the individual price items as children.
import org.openhab.binding.energidataservice.internal.retry.RetryPolicyFactory;
import org.openhab.binding.energidataservice.internal.retry.RetryStrategy;
import org.openhab.core.i18n.TimeZoneProvider;
-import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.dimension.EnergyPrice;
+import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
return;
}
BigDecimal spotPrice = cacheManager.getSpotPrice();
- updateState(CHANNEL_SPOT_PRICE, spotPrice != null ? new DecimalType(spotPrice) : UnDefType.UNDEF);
+ updateState(CHANNEL_SPOT_PRICE,
+ spotPrice != null ? getEnergyPrice(spotPrice, config.getCurrency()) : UnDefType.UNDEF);
}
private void updateCurrentTariff(String channelId, @Nullable BigDecimal tariff) {
if (!isLinked(channelId)) {
return;
}
- updateState(channelId, tariff != null ? new DecimalType(tariff) : UnDefType.UNDEF);
+ updateState(channelId, tariff != null ? getEnergyPrice(tariff, CURRENCY_DKK) : UnDefType.UNDEF);
+ }
+
+ private QuantityType<EnergyPrice> getEnergyPrice(BigDecimal price, Currency currency) {
+ return new QuantityType<>(price + " " + currency.getSymbol() + "/kWh");
}
private void updateHourlyPrices() {
for (Entry<Instant, BigDecimal> spotPrice : spotPrices) {
Instant hourStart = spotPrice.getKey();
if (isLinked(CHANNEL_SPOT_PRICE)) {
- spotPriceTimeSeries.add(hourStart, new DecimalType(spotPrice.getValue()));
+ spotPriceTimeSeries.add(hourStart, getEnergyPrice(spotPrice.getValue(), config.getCurrency()));
}
for (Map.Entry<DatahubTariff, TimeSeries> entry : datahubTimeSeriesMap.entrySet()) {
DatahubTariff datahubTariff = entry.getKey();
BigDecimal tariff = cacheManager.getTariff(datahubTariff, hourStart);
if (tariff != null) {
TimeSeries timeSeries = entry.getValue();
- timeSeries.add(hourStart, new DecimalType(tariff));
+ timeSeries.add(hourStart, getEnergyPrice(tariff, CURRENCY_DKK));
}
}
}
<channels>
<channel id="spot-price" typeId="spot-price">
<label>Spot Price</label>
- <description>Current spot price in DKK or EUR per kWh.</description>
+ <description>Spot price in DKK or EUR per kWh.</description>
</channel>
<channel id="grid-tariff" typeId="datahub-price">
<label>Grid Tariff</label>
- <description>Current grid tariff in DKK per kWh.</description>
+ <description>Grid tariff in DKK per kWh.</description>
</channel>
<channel id="system-tariff" typeId="datahub-price">
<label>System Tariff</label>
- <description>Current system tariff in DKK per kWh.</description>
+ <description>System tariff in DKK per kWh.</description>
</channel>
<channel id="transmission-grid-tariff" typeId="datahub-price">
<label>Transmission Grid Tariff</label>
- <description>Current transmission grid tariff in DKK per kWh.</description>
+ <description>Transmission grid tariff in DKK per kWh.</description>
</channel>
<channel id="electricity-tax" typeId="datahub-price">
<label>Electricity Tax</label>
- <description>Current electricity tax in DKK per kWh.</description>
+ <description>Electricity tax in DKK per kWh.</description>
</channel>
<channel id="reduced-electricity-tax" typeId="datahub-price">
<label>Reduced Electricity Tax</label>
- <description>Current reduced electricity tax in DKK per kWh. For electric heating customers only.</description>
+ <description>Reduced electricity tax in DKK per kWh. For electric heating customers only.</description>
</channel>
<channel id="hourly-prices" typeId="hourly-prices"/>
</channels>
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="spot-price">
- <item-type>Number</item-type>
+ <item-type>Number:EnergyPrice</item-type>
<label>Spot Price</label>
<description>Spot price.</description>
<category>Price</category>
- <state readOnly="true" pattern="%.9f"></state>
+ <state readOnly="true" pattern="%.9f %unit%"></state>
</channel-type>
<channel-type id="datahub-price">
- <item-type>Number</item-type>
+ <item-type>Number:EnergyPrice</item-type>
<label>Datahub Price</label>
<description>Datahub price.</description>
<category>Price</category>
- <state readOnly="true" pattern="%.6f"></state>
+ <state readOnly="true" pattern="%.6f %unit%"></state>
<config-description-ref uri="channel-type:energidataservice:datahub-price"/>
</channel-type>
</channel-groups>
<properties>
- <property name="thingTypeVersion">2</property>
+ <property name="thingTypeVersion">3</property>
</properties>
<config-description-ref uri="thing-type:energidataservice:service"/>
<remove-channel id="transmission-net-tariff" groupIds="electricity"/>
</instruction-set>
+ <instruction-set targetVersion="3">
+ <update-channel id="spot-price" groupIds="electricity">
+ <type>energidataservice:spot-price</type>
+ <label>Spot Price</label>
+ <description>Spot price in DKK or EUR per kWh.</description>
+ </update-channel>
+ <update-channel id="grid-tariff" groupIds="electricity">
+ <type>energidataservice:datahub-price</type>
+ <label>Grid Tariff</label>
+ <description>Grid tariff in DKK per kWh.</description>
+ </update-channel>
+ <update-channel id="system-tariff" groupIds="electricity">
+ <type>energidataservice:datahub-price</type>
+ <label>System Tariff</label>
+ <description>System tariff in DKK per kWh.</description>
+ </update-channel>
+ <update-channel id="transmission-grid-tariff" groupIds="electricity">
+ <type>energidataservice:datahub-price</type>
+ <label>Transmission Grid Tariff</label>
+ <description>Transmission grid tariff in DKK per kWh.</description>
+ </update-channel>
+ <update-channel id="electricity-tax" groupIds="electricity">
+ <type>energidataservice:datahub-price</type>
+ <label>Electricity Tax</label>
+ <description>Electricity tax in DKK per kWh.</description>
+ </update-channel>
+ <update-channel id="reduced-electricity-tax" groupIds="electricity">
+ <type>energidataservice:datahub-price</type>
+ <label>Reduced Electricity Tax</label>
+ <description>Reduced electricity tax in DKK per kWh. For electric heating customers only.</description>
+ </update-channel>
+ </instruction-set>
+
</thing-type>
</update:update-descriptions>