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.

Too long since last update
#1
Hi, 

I would like to do the following: 
- tag all temperature readings
- search up these temperature readings that are tagged
- get the oldest timestamp 
- if timestamp is older than two hours 
= write a boolean 1 on a group address 

This way I could indicate that there is a sensor on my installation that is not sending the current temperature anymore. 

Hope this could be done with a script. In advance thanks.  Cool

-CDG
Reply
#2
Hi,

I think you need something like this:

Code:
output = false
max_timestamp = os.time() - 7200 -- 2 hours in seconds
for _, object in ipairs(grp.tag('temperature')) do
 if object.updatetime < max_timestamp then
   output = true
   break
 end
end
grp.checkwrite('1/1/1', output)

BR,

Erwin
Reply
#3
That did the trick! Thank you very much.  Smile
Reply


Forum Jump: