25.03.2021, 14:46
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!
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!