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
#26
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

if stagione == false then
    valveStatesEstate = grp.tag(valveStatesTagEstate)
    for v = 1, #valveStatesEstate, 1 do
     valveStateEstate = valveStatesEstate[v]
     if valveStateEstate.value then
       opened = true
       if firstTimestamp > 0 then
         if firstTimestamp > valveStateEstate.updatetime then firstTimestamp = valveStateEstate.updatetime end
       else
         firstTimestamp = valveStateEstate.updatetime
       end
     end
 end
else
   valveStatesInverno = grp.tag(valveStatesTagInverno)
   for v = 1, #valveStatesInverno, 1 do
     valveStateInverno = valveStatesInverno[v]
     if valveStateInverno.value then
       opened = true
       if firstTimestamp > 0 then
         if firstTimestamp > valveStateInverno.updatetime then firstTimestamp = valveStateInverno.updatetime end
       else
         firstTimestamp = valveStateInverno.updatetime
       end
     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.')
log(valveStatesEstate)
os.sleep(nextCalculationAfter)
Hi,
In your opinion what is wrong in this script above. I add a condition to separate winter condition from summer condition.

I log variable log(valveStatesEstate) but the result is nil. Objects tags are correct and in other 2 scripts (the same) everything works fine.

I cannot understand the reason why it does not working. I expect to read TRUE in log (valveStateEstate).

Thank you for your help.
Reply


Messages In This Thread
RE: Resident script pump circulation - by Domoticatorino - 24.04.2018, 15:30

Forum Jump: