09.03.2018, 19:13
You can do it also as resident and use tag 'circulation_pump' for valves:
Code:
valveStatesTag = 'circulation_pump'
pumpGA = '1/1/10'
opened, first_timestamp = false, 0
valveStates = grp.tag(valveStatesTag)
for v = 1, #valveStates, 1 do
valveState = valveStates[v]
if valveState.value then
opened = true
if first_timestamp > 0 then
if first_timestamp > valveState.updatetime then first_timestamp = valveState.updatetime end
else
first_timestamp = valveState.updatetime
end
end
end
if opened then
opened_5_minutes = (os.microtime() - first_timestamp) >= 600
if opened_5_minutes then
grp.checkwrite(pumpGA, true)
else
grp.checkwrite(pumpGA, false)
end
else
grp.checkwrite(pumpGA, false)
end
Done is better than perfect