I think i resolved it, using lua, hope i am not going off-topic here.
I started off with 2 scripts like suggested by simonrg above.
During that i found the data for the weather station i use is updated every 10 minutes and also because i preferred to keep it all in one script i decided to use a different approach and created one script that is triggered by time (or better: ran every minute). Simonrg's suggestion about the shared variable inspired me. What i came up with is below. The idea is a uservar gets reset every day at 5am and decremented every minute the pump is on until its 0. If the next day at 4am the uservar is above 0 and the pump isnt running, it turns it on. Only if the temperature allows for it and the uservar has been decremented till 0, the pump will be turned off.
The only downside to this approach is 30 entries in the log every minute from 4:00am when its making up for the time it hasnt run and the uservar is decremented.
Its basically now a set of 4 "if-do" rules that are pretty self-explanatory when you see it below (i added some comments). I have not been able to test it extensively yet but i feel pretty confident this will work.
Code: Select all
commandArray = {}
time=os.date("*t")
if (otherdevices['Kitchen Floorheater pump'] == 'On' and uservariables['floorheaterpumpminruntime'] > 0)
then --if the pump is on decrement the floorheaterpumpminruntime uservar, but not below 0.
commandArray['Variable:floorheaterpumpminruntime']=tostring(uservariables['floorheaterpumpminruntime']-1)
end
if (otherdevices_temperature['WU Bennekel Temp'] > 17 and otherdevices['Kitchen Floorheater pump'] == 'On' and uservariables['floorheaterpumpminruntime'] == 0 )
then --if temp > 17, pump is on and minimum runtime has been reached: turn pump off.
commandArray['Kitchen Floorheater pump']='Off'
end
if (otherdevices_temperature['WU Bennekel Temp'] <= 17 and otherdevices['Kitchen Floorheater pump'] == 'Off')
then --if temp < 17 and pump is off turn pump on.
commandArray['Kitchen Floorheater pump']='On'
end
if (time.hour == 4 and time.min == 0 and uservariables['floorheaterpumpminruntime'] > 0 and otherdevices['Kitchen Floorheater pump'] == 'Off')
then --if its 4:00, minimum pump runtime has not been reached and the pump is off: turn it on.
commandArray['Kitchen Floorheater pump']="On"
end
if (time.hour == 5 and time.min == 0)
then --if its 5:00 reset the floorheaterpumpminruntime uservar to 30.
commandArray['Variable:floorheaterpumpminruntime']='30'
end
return commandArray
Thanks for the input.