This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Resident script pump circulation
#20
(10.03.2018, 17:14)Domoticatorino Wrote: It is a Schneider HL 2.0.1

I mean updated version of above scriptWink I've adjusted it to be more universal, added new variables:
Code:
valveStatesTag = 'circulation_pump' pumpGA = '1/1/10' openingValveTime = 300 -- time for fully open the valve (maximum time for next calculation) minInterval = 30 -- minimum offset for next calculation opened, firstTimestamp = false, 0 valveStates = grp.tag(valveStatesTag) for v = 1, #valveStates, 1 do  valveState = valveStates[v]  if valveState.value then    opened = true    if firstTimestamp > 0 then        if firstTimestamp > valveState.updatetime then firstTimestamp = valveState.updatetime end    else        firstTimestamp = valveState.updatetime    end  end end if opened then    fullyOpened = (os.microtime() - firstTimestamp) >= openingValveTime    if fullyOpened then        grp.checkwrite(pumpGA, true)        nextCalculationAfter = minInterval    else        grp.checkwrite(pumpGA, false)        nextCalculationAfter = openingValveTime + 1 - (os.microtime() - firstTimestamp) -- run a little after possible change    end else    grp.checkwrite(pumpGA, false)    nextCalculationAfter = openingValveTime + 1 end log('Next calculation after: ' .. nextCalculationAfter .. 's.') os.sleep(nextCalculationAfter)
Done is better than perfect
Reply


Messages In This Thread
RE: Resident script pump circulation - by buuuudzik - 10.03.2018, 17:16

Forum Jump: