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.
+#### Trigger Channels
+
+Advanced channel `event` can trigger the following events:
+
+| Event | Description |
+|----------------------|--------------------------------|
+| DAY_AHEAD_AVAILABLE | Day-ahead prices are available |
+
## Thing Actions
Thing actions can be used to perform calculations as well as import prices directly into rules without relying on persistence.
:::
::::
+
+### Trigger Channel Example
+
+:::: tabs
+
+::: tab DSL
+
+```javascript
+rule "Day-ahead event"
+when
+ Channel 'energidataservice:service:energidataservice:electricity#event' triggered 'DAY_AHEAD_AVAILABLE'
+then
+ logInfo("Day-ahead", "Day-ahead prices for the next day are now available")
+end
+```
+
+:::
+
+::: tab JavaScript
+
+```javascript
+rules.when()
+ .channel('energidataservice:service:energidataservice:electricity#event').triggered('DAY_AHEAD_AVAILABLE')
+ .then(event =>
+ {
+ console.log('Day-ahead prices for the next day are now available');
+ })
+ .build("Day-ahead event");
+```
+
+:::
+
+::::
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "co2-emission-prognosis";
public static final String CHANNEL_CO2_EMISSION_REALTIME = CHANNEL_GROUP_ELECTRICITY
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "co2-emission-realtime";
+ public static final String CHANNEL_EVENT = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR + "event";
public static final Set<String> ELECTRICITY_CHANNELS = Set.of(CHANNEL_SPOT_PRICE, CHANNEL_GRID_TARIFF,
CHANNEL_SYSTEM_TARIFF, CHANNEL_TRANSMISSION_GRID_TARIFF, CHANNEL_ELECTRICITY_TAX,
public static final String PROPERTY_LAST_CALL = "lastCall";
public static final String PROPERTY_NEXT_CALL = "nextCall";
+ // List of all events
+ public static final String EVENT_DAY_AHEAD_AVAILABLE = "DAY_AHEAD_AVAILABLE";
+
// List of supported currencies
public static final Currency CURRENCY_DKK = Currency.getInstance("DKK");
public static final Currency CURRENCY_EUR = Currency.getInstance("EUR");
private void refreshElectricityPrices() {
RetryStrategy retryPolicy;
try {
+ boolean spotPricesDownloaded = false;
if (isLinked(CHANNEL_SPOT_PRICE)) {
- downloadSpotPrices();
+ spotPricesDownloaded = downloadSpotPrices();
}
for (DatahubTariff datahubTariff : DatahubTariff.values()) {
if (numberOfFutureSpotPrices >= 13 || (numberOfFutureSpotPrices == 12
&& now.isAfter(DAILY_REFRESH_TIME_CET.minusHours(1)) && now.isBefore(DAILY_REFRESH_TIME_CET))) {
+ if (spotPricesDownloaded) {
+ triggerChannel(CHANNEL_EVENT, EVENT_DAY_AHEAD_AVAILABLE);
+ }
retryPolicy = RetryPolicyFactory.atFixedTime(DAILY_REFRESH_TIME_CET, NORD_POOL_TIMEZONE);
} else {
logger.warn("Spot prices are not available, retry scheduled (see details in Thing properties)");
reschedulePriceRefreshJob(retryPolicy);
}
- private void downloadSpotPrices() throws InterruptedException, DataServiceException {
+ private boolean downloadSpotPrices() throws InterruptedException, DataServiceException {
if (cacheManager.areSpotPricesFullyCached()) {
logger.debug("Cached spot prices still valid, skipping download.");
- return;
+ return false;
}
DateQueryParameter start;
if (cacheManager.areHistoricSpotPricesCached()) {
} finally {
updateProperties(properties);
}
+ return true;
}
private void downloadTariffs(DatahubTariff datahubTariff) throws InterruptedException, DataServiceException {
channel-type.energidataservice.co2-emission.description = CO₂ emission in g/kWh.
channel-type.energidataservice.datahub-price.label = Datahub Price
channel-type.energidataservice.datahub-price.description = Datahub price.
+channel-type.energidataservice.event.label = Event
+channel-type.energidataservice.event.description = Event triggered
channel-type.energidataservice.spot-price.label = Spot Price
channel-type.energidataservice.spot-price.description = Spot price.
<label>CO₂ Emission Realtime</label>
<description>Near up-to-date history for CO₂ emission from electricity consumed in Denmark in g/kWh.</description>
</channel>
+ <channel id="event" typeId="event"/>
</channels>
</channel-group-type>
<state readOnly="true" pattern="%.1f %unit%"></state>
</channel-type>
+ <channel-type id="event" advanced="true">
+ <kind>trigger</kind>
+ <label>Event</label>
+ <description>Event triggered</description>
+ <event>
+ <options>
+ <option value="DAY_AHEAD_AVAILABLE">Day-ahead prices are available</option>
+ </options>
+ </event>
+ </channel-type>
+
</thing:thing-descriptions>
</channel-groups>
<properties>
- <property name="thingTypeVersion">5</property>
+ <property name="thingTypeVersion">6</property>
</properties>
<config-description-ref uri="thing-type:energidataservice:service"/>
</add-channel>
</instruction-set>
+ <instruction-set targetVersion="6">
+ <add-channel id="event" groupIds="electricity">
+ <type>energidataservice:event</type>
+ </add-channel>
+ </instruction-set>
+
</thing-type>
</update:update-descriptions>