Depending on the time of the day, an update of the prognosis may include estimates for more than 9 hours, but every update will have at least 9 hours into the future.
A persistence configuration is required for this channel.
+Please note that the CO₂ emission channels only apply to Denmark.
+These channels will not be updated when the configured price area is not DK1 or DK2.
+
## Thing Actions
Thing actions can be used to perform calculations as well as import prices directly into rules without relying on persistence.
if (dataset != Dataset.CO2Emission && dataset != Dataset.CO2EmissionPrognosis) {
throw new IllegalArgumentException("Invalid dataset " + dataset + " for getting CO2 emissions");
}
+ if (!"DK1".equals(priceArea) && !"DK2".equals(priceArea)) {
+ throw new IllegalArgumentException("Invalid price area " + priceArea + " for getting CO2 emissions");
+ }
Request request = httpClient.newRequest(ENDPOINT + DATASET_PATH + dataset)
.timeout(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS) //
.param("start", start.toString()) //
return Set.of(EnergiDataServiceActions.class);
}
+ @Override
+ public void channelLinked(ChannelUID channelUID) {
+ super.channelLinked(channelUID);
+
+ if (!"DK1".equals(config.priceArea) && !"DK2".equals(config.priceArea)
+ && (CHANNEL_CO2_EMISSION_PROGNOSIS.equals(channelUID.getId())
+ || CHANNEL_CO2_EMISSION_REALTIME.contains(channelUID.getId()))) {
+ logger.warn("Item linked to channel '{}', but price area {} is not supported for this channel",
+ channelUID.getId(), config.priceArea);
+ }
+ }
+
@Override
public void channelUnlinked(ChannelUID channelUID) {
super.channelUnlinked(channelUID);
private void updateCo2Emissions(Dataset dataset, String channelId, DateQueryParameter dateQueryParameter)
throws InterruptedException, DataServiceException {
+ if (!"DK1".equals(config.priceArea) && !"DK2".equals(config.priceArea)) {
+ // Dataset is only for Denmark.
+ return;
+ }
Map<String, String> properties = editProperties();
CO2EmissionRecord[] emissionRecords = apiController.getCo2Emissions(dataset, config.priceArea,
dateQueryParameter, properties);