24.10.2018, 09:26
Hi there,
I have a big problem with the script below. Please consider that I have 3 same script (obviosly with different varables) and everyting works fine. The one below does not work anymore.
I have seen in the obkect list that last update of group address 2/0/2 was dated 16th of September. The other correctly dated today. I cannot understand the reason why it does not work anymore. And nothing changed.
I tried to delate scritp and redo it without success. I tried to do again object 2/0/2 without success. Nothing group address 2/0/2 never update. Could you help me please?
Thanks.
I have a big problem with the script below. Please consider that I have 3 same script (obviosly with different varables) and everyting works fine. The one below does not work anymore.
I have seen in the obkect list that last update of group address 2/0/2 was dated 16th of September. The other correctly dated today. I cannot understand the reason why it does not work anymore. And nothing changed.
I tried to delate scritp and redo it without success. I tried to do again object 2/0/2 without success. Nothing group address 2/0/2 never update. Could you help me please?
Thanks.
Code:
valveStatesTagEstate = 'pompa_circolazione_mansarda_estate'
valveStatesTagInverno = 'pompa_circolazione_mansarda_inverno'
stagione = grp.getvalue('2/0/100')
pumpGA = '2/0/2'
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.')
os.sleep(nextCalculationAfter)