Hello world,
I am trying to make my Smart Grid heat pump smarter. I need to turn off the heating to really start the promised SG function. Therefore, I have added a MQTT relay to the Heat Pump. I need to switch it On or Off it depending on Total exported energy produced from my Photovoltaics. Here, for test purposes it is Import instead of Export.
The principle:
/*if live import is >2 min, >1kW
AlthermaOnOff_state ON
if live import is <0.8kW, >5min
AlthermaOnOff_state OFF*/
var Timer myTimerOn = null
var Timer myTimerOff = null
rule "altherma_sg"
when
Item SolarEdge_Live_Import changed
then
logInfo("altherma_sg.rules", "Rule altherma_sg.rules running")
if(SolarEdge_Live_Import.state > 1|kW) {
logInfo("altherma_sg.rules", "More than 1kW, waiting 2 min")
myTimerOn = createTimer(now.plusMinutes(2), [ |
logInfo("altherma_sg.rules", "running test, if still more than 1kW")
if(SolarEdge_Live_Import.state > 1|kW) {
logInfo("altherma_sg.rules", "still more than 1kW")
AlthermaOnOff_state.sendCommand(ON)
logInfo("altherma_sg.rules", "SG ON, resetting myTimerOn")
myTimerOn = null
}
else if(SolarEdge_Live_Import.state < 0.8|kW) {
logInfo("altherma_sg.rules", "Less than 0.8kW, rescheduling timer +3 min")
myTimerOff = createTimer(now.plusMinutes(3), [ |
logInfo("altherma_sg.rules", "myTimerOff 3 min activated")
AlthermaOnOff_state.sendCommand(OFF)
logInfo("altherma_sg.rules", "SG OFF, resetting myTimerOff")
myTimerOff = null
])
}
])
}
end
I red this: https://www.openhab.org/docs/configuration/actions.html#timers but it seems that I did not get it properly, as OH3 is throwing these errors:
2021-02-16 00:40:51.983 [WARN ] [ore.internal.scheduler.SchedulerImpl] - Scheduled job failed and stopped
java.lang.reflect.UndeclaredThrowableException: null
at com.sun.proxy.$Proxy713.apply(Unknown Source) ~[?:?]
at org.openhab.core.model.script.actions.ScriptExecution.lambda$0(ScriptExecution.java:82) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$12(SchedulerImpl.java:166) ~[bundleFile:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$1(SchedulerImpl.java:76) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?].............
Thank you,
Michal