Optimal Window: run devices in the cheapest window of any forecast [5.2.0.0;6.0.0.0)

finds the best time window in any forecast item and switches your device on when the window starts and off when it ends. cheapest electricity, lowest CO2, most PV, whatever forecast you have.

this is the add-on from my pull request #21896. until it is merged you can get it here, when it is in a release i will unpublish this entry.

What it can do

  • a trigger “an optimal window starts or ends”, a condition “it is within the optimal window” and a rule template “Run during optimal window”
  • works with any Number item that has a forecast, e.g. prices from aWATTar, Energy-Charts, ENTSO-E, Energi Data Service or Tibber, CO2 intensity or a PV forecast
  • lowest or highest values, one block or split into several parts
  • the length is in minutes and does not have to match the forecast, e.g. 1h40m with 15 minute prices
  • preferStart for devices that are often done early, like a boiler
  • status items if you want to see it in the UI: active, start, end, countdown, remaining, the window as text and the average value
  • a window that started is not interrupted by new prices and runs only once per range

What you need

the forecast is read from persistence, so persist the forecast item with the forecast strategy. the persistence service has to store future values, e.g. InfluxDB, JDBC or In-Memory (rrd4j does not):

Items {
    Electricity_Price : strategy = forecast
}

Quick start

  1. Settings → Rules → Add Rule, take the template “Run during optimal window”
  2. select the item to switch, the forecast item and the length, e.g. 4h
  3. save

the item gets ON when the window starts and OFF when it ends.

Example in a YAML file

this is more or less what runs my water boiler: cheapest 4 hours between 04:00 and midnight, no ON when we are on holiday:

version: 1
rules:
  optimalwindow:boiler:
    label: Optimal window water boiler
    triggers:
      - id: "1"
        type: optimalwindow.WindowTrigger
        config:
          forecastItem: Electricity_Price
          rangeStart: "04:00"
          rangeDuration: 20h
          length: 4h
          activeItem: Boiler_WindowActive
          windowTextItem: Boiler_WindowText
    conditions:
      - id: "3"
        type: script.ScriptCondition
        config:
          type: application/javascript
          script: |
            !(command.toString() === 'ON' && items.Scenario.state === 'Holiday')
    actions:
      - id: "2"
        type: core.ItemCommandAction
        config:
          itemName: Boiler_Relay

everything else is in the README.

Credits

the calculation is based on the BestPrice logic of the aWATTar binding by Wolfgang Klimt, Jan N. Klug and Hilbrand Bouwkamp. thx!

Changelog

Version 0.1

  • initial release

Resources

Cool Icon :slight_smile:

I have to admit that i let the AI create that on the basis of the other logos :slight_smile:

For more background info, why this automation was created, check: