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.

Comparing value with average tendence
#1
I am monitoring the temperature in a device, and I should set an alarm if this temperature varies more than X degrees (variation) in last 4 days. 
So, (for example every hour) I have to compare the "actual temperature" with the "average temperature in last 4 days". 
But some times, the device is switched off, so its temperature is 0, and I don't want to use this value to calculate the average temperature.

To calculate the average temp, I think I should use something like:



If device if ON, then
average_temp = (average_temp + actual_temp) / 2
else
average_temp = average_temp


I should save the average_temp as a variable so the script knows its value everytime.

Later, I will have to compare the average_temp with the actual_temp and the variation_value and, if needed, start an alarm.

Can someone help me with the LUA programming?

Thanks!
Reply


Messages In This Thread
Comparing value with average tendence - by jmedrano - 25.03.2021, 14:46

Forum Jump: