04.03.2024, 23:15
I just realize that TON timer could be omitted - if you agree - as the delay it inserts, is just to clear storage memory if power up is made before UPS shutdown.
So, instead of the TON Timer, we can use a simple contact like "On-Off Switch" or similar (MCB, etc.) that will be always electrically closed. I mean that we are concerned only about the edge down part of the monitored input. Thus, "value == true" part of code needs to be removed.
In my opinion clearing the storage memory in this part of code is not important as it will be overwritten when needed...
Code:
value = event.getvalue()
tag = 'thermostat'
if value then
uptime = os.monotonictime()
if uptime > 3 * 60 then
storage.delete(tag)
end
else
...
So, instead of the TON Timer, we can use a simple contact like "On-Off Switch" or similar (MCB, etc.) that will be always electrically closed. I mean that we are concerned only about the edge down part of the monitored input. Thus, "value == true" part of code needs to be removed.
In my opinion clearing the storage memory in this part of code is not important as it will be overwritten when needed...