diff --git a/bundles/org.openhab.binding.tibber/README.md b/bundles/org.openhab.binding.tibber/README.md index aea0907244626..e92e0aa369dd5 100644 --- a/bundles/org.openhab.binding.tibber/README.md +++ b/bundles/org.openhab.binding.tibber/README.md @@ -79,6 +79,14 @@ After initial setup the average values will stay NULL until the next day because Please note time series are not supported by the default [rrd4j](https://www.openhab.org/addons/persistence/rrd4j/) persistence. The items connected to the above channels needs to be stored in e.g. [InfluxDB](https://www.openhab.org/addons/persistence/influxdb/) or [InMemory](https://www.openhab.org/addons/persistence/inmemory/). +#### Trigger Channels + +Channel `event` can trigger the following events: + +| Event | Description | +|----------------------|--------------------------------| +| DAY_AHEAD_AVAILABLE | Day-ahead prices are available | + ### `live` group Live information from Tibber Pulse. @@ -475,3 +483,14 @@ Number:Energy Tibber_API_Total_Production "Total Productio Number:Energy Tibber_API_Daily_Production "Daily Production" {channel="tibber:tibberapi:xyz:statistics#daily-production"} Number:Energy Tibber_API_Last_Hour_Production "Last Hour Production" {channel="tibber:tibberapi:xyz:statistics#last-hour-production"} ``` + +### Rule listen to day-ahead price update + +```java +rule "Tibber day-ahead prices available" +when + Channel 'tibber:tibberapi:xyz:price#event' triggered +then + logInfo("Tibber Update","Price event {}", receivedEvent) +end +``` diff --git a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/TibberBindingConstants.java b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/TibberBindingConstants.java index 442d20a089d63..579792c40c8ce 100644 --- a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/TibberBindingConstants.java +++ b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/TibberBindingConstants.java @@ -52,6 +52,7 @@ public class TibberBindingConstants { public static final String CHANNEL_TAX = "tax"; public static final String CHANNEL_PRICE_LEVELS = "level"; public static final String CHANNEL_AVERAGE = "average"; + public static final String CHANNEL_EVENT = "event"; // live channels public static final String CHANNEL_CONSUMPTION = "consumption"; @@ -78,6 +79,9 @@ public class TibberBindingConstants { public static final String CHANNEL_DAILY_PRODUCTION = "daily-production"; public static final String CHANNEL_LAST_HOUR_PRODUCTION = "last-hour-production"; + // List of all events + public static final String EVENT_DAY_AHEAD_AVAILABLE = "DAY_AHEAD_AVAILABLE"; + public static final Map PRICE_COST_CHANNELS = Map.of( CHANNEL_GROUP_PRICE + ChannelUID.CHANNEL_GROUP_SEPARATOR + CHANNEL_TOTAL_PRICE, "price", CHANNEL_GROUP_PRICE + ChannelUID.CHANNEL_GROUP_SEPARATOR + CHANNEL_SPOT_PRICE, "price", diff --git a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java index 8c87c858d67d5..596491c610942 100644 --- a/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java +++ b/bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java @@ -373,6 +373,7 @@ private void updateSpotPrices() { if (!priceInfo.isEmpty()) { try { + boolean updateTrigger = false; // now check if tomorrows prices are updated for the given hour if (tibberConfig.updateHour <= Instant.now().atZone(timeZoneProvider.getTimeZone()).getHour()) { JsonArray tomorrowPrices = priceInfo.getAsJsonArray("tomorrow"); @@ -383,6 +384,7 @@ private void updateSpotPrices() { } else { logger.debug("update found - continue"); retryCounter = 0; + updateTrigger = true; } } JsonArray spotPrices = new JsonArray(); @@ -435,6 +437,10 @@ private void updateSpotPrices() { }); averageCache = avgSeries; sendTimeSeries(new ChannelUID(thing.getUID(), CHANNEL_GROUP_PRICE, CHANNEL_AVERAGE), avgSeries); + if (updateTrigger) { + triggerChannel(new ChannelUID(thing.getUID(), CHANNEL_GROUP_PRICE, CHANNEL_EVENT), + EVENT_DAY_AHEAD_AVAILABLE); + } updateStatus(ThingStatus.ONLINE); } catch (JsonSyntaxException | DateTimeParseException e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, diff --git a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/i18n/tibber.properties b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/i18n/tibber.properties index 3401cf013eff9..2b526c73e4de8 100644 --- a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/i18n/tibber.properties +++ b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/i18n/tibber.properties @@ -91,6 +91,8 @@ channel-type.tibber.energy-detailed.label = Total Consumption channel-type.tibber.energy-detailed.description = Consumption at given time interval (e.g. hourly, daily, last meter reading, accumulated since midnight) channel-type.tibber.energy.label = Total Consumption channel-type.tibber.energy.description = Consumption at given time interval (e.g. hourly, daily, last meter reading, accumulated since midnight) +channel-type.tibber.event.label = Event +channel-type.tibber.event.description = Event triggered channel-type.tibber.power.label = Power Consumption/Production channel-type.tibber.power.description = Power consumption/production for given time interval channel-type.tibber.price-level.label = Price Level diff --git a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/channel-types.xml index d29155b58d3f6..516dcf0754034 100644 --- a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/channel-types.xml @@ -90,4 +90,14 @@ + + trigger + + Event triggered + + + + + + diff --git a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/price-group.xml b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/price-group.xml index e98015c0d9cee..b9b01b1ce8541 100644 --- a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/price-group.xml +++ b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/price-group.xml @@ -31,6 +31,7 @@ Average price from last 24 hours + diff --git a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/thing-types.xml index fbdb66681af55..3557442b96b52 100644 --- a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/thing-types.xml @@ -16,7 +16,7 @@ Tibber - 6 + 7 diff --git a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/update/instructions.xml index eed653d8b3ed3..bb5871671921d 100644 --- a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/update/instructions.xml +++ b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/update/instructions.xml @@ -208,6 +208,12 @@ (DEPRECATED) Use total channel from price group + + + + tibber:event + +