After sleeping one night, things start to be a bit more clear in my mind. This is what I’m probably going to do.
-
The script will fetch the spot prices for the next day in the evening. Let this script be called “fetch-spot-prices”.
-
The “fetch-spot-prices” script will use the InfluxDB HTTP API to write the prices with future timestamps as discussed in the thread Iinked in my previous comment. With this approach, the prices will be a true time series, which makes it easy to plot (among other benefits).
-
Once the “fetch-spot-prices” has been executed, a second script will get invoked. Let this script be called “determine-allowed-hours-for-the-water-heater”. This script will read the spot prices from the InfluxDB and determine the hours when the water heater should be “on” and when it should be “off”. The results will be written to another time series with future timestamps.
-
I will create a Water Heater Thing, with a Channel that connects the Thing to a Water Heater Item, which is a Switch Item. The Thing uses the GPIO Binding, which controls the relay.
-
I will have a rule that runs every full hour.
- This rule will check if the Water Heater is already “on”. If yes, and the “allowed-hours-for-the-water-heater” time series says that this hour is not allowed, it will turn the Water Heater Switch Item to “off”.
- Correspondingly, if the Water Heater is “off” and the “allowed-hours-for-the-water-heater” time series says that this hour is allowed, it will turn the Water Heater Switch Item to “on”.
- I will make the Water Heater Switch Item to persist its state as yet another time series, which means that
- I can plot the hourly spot prices
- I can plot the hours that the “determine-allowed-hours-for-the-water-heater” script was saying which ones are allowed
- I can plot the hours when the water heater was actually on / off, because the Water Heater Switch Item can be manually be toggled on/off.
Cheers,
Markus