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
#28
(24.04.2018, 17:03)buuuudzik Wrote: You are trying to log value 'ValveStatesEstate' but you hasn't defined stagione so stagione equals nil so else condition is executed.

But generally when you extend this script maybe better would be create some function and do script more elastic also for the futureWink

See below (but still you must define stagione!):

Code:
valveStatesTagEstate = 'pompa_circolazione_giorno_estate' valveStatesTagInverno = 'pompa_circolazione_giorno_inverno' pumpGA = '2/0/1' openingValveTime = 60 -- time for fully open the valve (maximum time for next calculation) minInterval = 30 -- minimum offset for next calculation opened, firstTimestamp = false, 0 function getParamsFromValveStates(valvesTag)     local 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 return opened, firstTimestamp end if not stagione then opened, firstTimestamp = getParamsFromValveStates(valveStatesTagEstate) else opened, firstTimestamp = getParamsFromValveStates(valveStatesTagInverno) 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)

Thank you very much...stupid mistake!! I have to hire you  Wink
Reply


Messages In This Thread
RE: Resident script pump circulation - by Domoticatorino - 24.04.2018, 21:50

Forum Jump: