after doing some testing, it seems that this setup will mostly work. here’s a version that carries some additional optimisations, for instance this one will keep the target temperature high as long as production of above the threshold. If it drop below, it will switch the temp back to normal.
import org.openhab.core.library.types.*
import java.lang.Math
var Timer tEV_ww_minrun = null
var Timer tEV_ww_waittime = null
var Timer testtimer1 = null
var Timer testtimer2 = null
/* rule "default values"
when System started
then
sendCommand(EV_warmwater,ON)
sendCommand(EV_warmwater_threshhold,1500)
sendCommand(EV_warmwater_exc,55)
sendCommand(EV_warmwater_norm,43)
sendCommand(EV_warmwater_waittime,5)
sendCommand(EV_warmwater_waittime_run,OFF)
sendCommand(EV_warmwater_minrun,30)
sendCommand(EV_warmwater_state,OFF)
sendCommand(se9km_Watt_int,2)
sendCommand(se9km_WattSF_int,3)
testtimer1 = createTimer(now.plusSeconds(90)) [|
sendCommand(se9km_Watt_int,3)
testtimer1 = null
]
testtimer2 = createTimer(now.plusSeconds(180)) [|
sendCommand(se9km_Watt_int,0)
testtimer2 = null
]
end
*/
rule "EV_warmwater"
when Item se9km_Watt received update
then
// check if the logic to dump excess power production into the heating of "hot" warmwater is switched on
if (EV_warmwater.state == ON) {
// check if the photovoltaics plant is currently generating enough energy to that the net export to the grid is higher than
// the excess threshold of 1500 Watts
if ( (se9km_Watt.state as DecimalType).floatValue > (EV_warmwater_threshhold.state as DecimalType).floatValue ) {
// check if there isn't any timer already running
if ((tEV_ww_minrun == null) && (tEV_ww_waittime == null)) {
// create timer to wait for the minimum waittime and check excess energy again
sendCommand(EV_warmwater_waittime_run,ON)
logInfo("[EV]", "Produktion >Schwelle, Starte min-Wait Timer fuer Eigenverbrauchsoptimierung Warmwasser")
tEV_ww_waittime = createTimer(now.plusMinutes((EV_warmwater_waittime.state as DecimalType).intValue)) [|
if ( (se9km_Watt.state as DecimalType).floatValue > (EV_warmwater_threshhold.state as DecimalType).floatValue ) {
//minimum waittime ran out, and excess power is still there, begin dumping excess porwer into warmwater heating
logInfo("[EV]","Produktion >Schwelle, Starte Eigenverbrauchsoptimierung Warmwasser")
sendCommand(HeatPump_warmwater_temperature,(EV_warmwater_exc.state as DecimalType).toString)
sendCommand(EV_warmwater_state,ON)
// create timer to allow the dumping to run for at least the minimum run time
tEV_ww_minrun = createTimer(now.plusMinutes((EV_warmwater_minrun.state as DecimalType).intValue)) [|
//minrun time is done, if production is less than threshhold switch temp back to normal,
//otherwise leave it on high, and we'll check production otside of the timer
if ( (se9km_Watt.state as DecimalType).floatValue < (EV_warmwater_threshhold.state as DecimalType).floatValue ) {
sendCommand(HeatPump_warmwater_temperature,(EV_warmwater_norm.state as DecimalType).toString)
sendCommand(EV_warmwater_state,OFF)
tEV_ww_minrun = null
logInfo("[EV]", "minimale Laufzeit fuer Aufladen WW-Speicher beendet, Produktion < Schwelle")
} else {
logInfo("[EV]", "minimale Laufzeit fuer Aufladen WW-Speicher beendet, Produktion > Schwelle")
tEV_ww_minrun = null
}
]
}
else
// minwait has expired, but the production in now less than threshhold, destroy the minwait timer, to be safe, also
// switch back target temperature to normal
{
if (tEV_ww_waittime != null) {
tEV_ww_waittime.cancel
tEV_ww_waittime = null
sendCommand(HeatPump_warmwater_temperature,(EV_warmwater_norm.state as DecimalType).toString)
sendCommand(EV_warmwater_state,OFF)
logInfo("[EV]","Produktion unter die Schwelle gefallen, min-Wait Timer gecancelt")
sendCommand(EV_warmwater_waittime_run,OFF)
}
}
// normal exit of the minrun timer, destroy it
tEV_ww_waittime = null
sendCommand(EV_warmwater_waittime_run,OFF)
]
}
}
else
// plan is generating less than 1500W
{
// check if we need to cancel the minimal wait timer
if (tEV_ww_waittime != null) {
tEV_ww_waittime.cancel
tEV_ww_waittime = null
logInfo("[EV]","Produktion unter die Schwelle gefallen, min-Wait Timer gecancelt")
sendCommand(EV_warmwater_waittime_run,OFF)
} else {
// minimum wait wasn't running, maybe we're in the minimal running time
if (tEV_ww_minrun == null) {
// we're outside of minimal running time, so we can switch back the target temperature back to normal
logInfo("[EV]","Produktion unter Schwelle gefallen, Brauchwasser-Soll zurueck auf normal")
sendCommand(HeatPump_warmwater_temperature,(EV_warmwater_norm.state as DecimalType).toString)
sendCommand(EV_warmwater_state,OFF)
}
}
}
}
end