4.x ‐ Electricity prices with openHAB Bindings - masipila/openhab-spot-price-optimizer GitHub Wiki

Important note

The version 4.x of openHAB Spot Price Optimizer assumes that the day-ahead electricity prices are stored by an openHAB Binding. These instructions walk you through how to install and configure the EntsoE Binding which is included in openHAB 4.3.0 (or 4.3.0 Milestone 4 to be specific). However, openHAB Spot Price Optimizer will work with other Bindings as well, as long as those persist the data as a proper forecast TimeSeries.

Install and configure the Entso-E Binding

Install the binding

  • Navigate to openHAB Add-on Store / Bindings, and install Entso-E Binding which is available as an official openHAB Distribution binding from release 4.3.0 onwards

Create and configure a Day-Ahead Thing

Create a SpotPrice Item

  • Once you have created the Thing, navigate to the Channels tab and create a new Item
  • The default name that Entso-E Binding suggests is Dayahead_prices_Spot_Price. The following screenshot uses a name SpotPrice so that the name of the Item will be compatible with the other openHAB Spot Price Optimizer documentation. You can use whatever name you prefer, but SpotPrice is recommended so that it will be easier to follow the other instructions in this wiki.
  • The binding uses EUR/kWh as the unit of measure by default. If you want to use the data in c/kWh, leave the dimension field empty as illustrated in the screenshot below. We will apply an inline transformation in the next step to conver the prices from EUR/kWh to c/kWh. image

Optional: Convert the prices from EUR / kWH to c/kWH and apply value added tax

  • Once you have created and saved the Item, you can edit it and apply an inline transformation profile which converts the currency from EUR / kWh to c/kWh and applies value added tax. If you are from a country which does not belong to the Euro zone, you might want to use the currency exchange service and the VAT transformation profile instead (configuring these are out of the scope of this wiki page).
  • On the Thing Channels tab, select the SpotPrice Item you just created so that you can edit this Channel Link.
  • In the Profile section, select Script ECMAScript as the profile scripting language as illustrated in the screenshot below
  • In the Profile Configuration section, configure an inline Thing to Item transformation as illustrated in the screenshot below.
  • | parseFloat(input)*100*1.255 means that the value of each price point is first converted from text to a float number, then multiplied by 100 to convert it from EUR to cents and then multiplied by 1.255 (VAT in Finland is 25.5%) image

Configure the forecast persistence policy for the SpotPrice item

  • The SpotPrice item MUST be configured so that the persistence policy is forecast, and only that.
  • In other words, the SpotPrice item MUST NOT be persisted for example using everyChange, everyUpdate, restoreOnStartup or any other persistence policy. If you have a persistence policy for one of these strategies, you MUST exclude the SpotPrice item from that strategy.

Create an Item Group to help with persistence policy configurations

  • Since you will have several other Items that need to be configured the same way, it is recommended to create an Item Group so that you can configure the persistence policy for the whole group at once.
  • The screenshot below shows how to create an Item Group called AllForecastItems.
  • Once the Group has been created, edit the group and add the SpotPrice item as a Direct Group Member. image

Configure the persistence policy for the Item Group

  • Navigate to Settings / InfluxDB Persistence settings
  • On the top of the page, click the Configure Persistence Policies button
  • Add a new persistence configuration, apply it for AllForecastItems Item Group and set the strategy to be forecast.
  • Important Make sure that AllForecastItems Item Group is excluded from ALL other persistence strategies.
  • The result should look like illustarted in the screenshot below. image

If you would have both forecast and everyChange applied to your SpotPrice item, you would end up having unexpected ghost records in your database as shown below after the hour changes.

PersistedItem (Timestamp=2024-11-29T16:00+02:00[Europe/Helsinki], State=3.8566149999999997),
PersistedItem (Timestamp=2024-11-29T16:59:59.768+02:00[Europe/Helsinki], State=4.13899),
PersistedItem (Timestamp=2024-11-29T16:59:59.770+02:00[Europe/Helsinki], State=3.8566149999999997),
PersistedItem (Timestamp=2024-11-29T17:00+02:00[Europe/Helsinki], State=4.13899),

Verify that you can see price data in your database

  • Check from your database that the binding has saved the price data
  • The screenshot below shows how to see the data in InfluxDB Data Explorer which is by default available in the port 8086 of the influx DB server
  • Remember to adjust the query time range to the future image
  • If you don't see price data in your database, check your logs. You can re-trigger the fetching of the prices by navigating to your Entso-E Thing and re-saving its configuration.
  • If you still don't see your price data, you can request support from the openHAB community forum in the Entso-E Binding's thread.