I have this alarm script monitoring fermenter temps which I have set to email. My issue is that when I have a temp issue I receive way too many emails. Can someone assist with a good way to quiet this? Maybe with a wait command?
Code:[Alarm-Setup] new value alarm_low new value alarm_high new value alarm_counter new value alarm_threshold new string FV-1_alarm_status "FV-1" target = "FV-1 PT100" value alarm_low = "FV-1" target - 3 alarm_high = "FV-1" target + 3 alarm_threshold = 6 // Timespan multiplier for sleep command alarm_counter precision = 0 [Alarm-Check] if "FV-1 PT100" value <= "FV-1" target if "FV-1 PT100" value > alarm_low FV-1_alarm_status = "SYSTEM OK" "FV-1 TEMP ALARM" active = false sleep 500 goto "Alarm-Check" endif endif if "FV-1 PT100" value >= "FV-1" target if "FV-1 PT100" value < alarm_high FV-1_alarm_status = "SYSTEM OK" sleep 500 goto "Alarm-Check" endif endif [Alarm-Count] if "FV-1 PT100" value <= alarm_low if alarm_counter < alarm_threshold alarm_counter += 1 print alarm_counter "FV-1 TEMP ALARM" active = false FV-1_alarm_status = "ALARM DELAY" sleep 10000 // Defines alarm_threshold timespan goto "Alarm-Count" endif endif if "FV-1 PT100" value >= alarm_high if alarm_counter < alarm_threshold alarm_counter += 1 print alarm_counter "FV-1 TEMP ALARM" active = false FV-1_alarm_status = "ALARM DELAY" sleep 10000 // Defines alarm_threshold timespan goto "Alarm-Count" endif endif [Alarm-Fault] if "FV-1 PT100" value <= alarm_low "FV-1 TEMP ALARM" active = true FV-1_alarm_status = "LOW FV TEMP" sleep 10000 goto "Alarm-Count" endif if "FV-1 PT100" value >= alarm_high "FV-1 TEMP ALARM" active = true FV-1_alarm_status = "HIGH FV TEMP" sleep 10000 goto "Alarm-Count" else alarm_counter = 0 goto "Alarm-Check" endif
The reason is because the alarm will repeatedly get triggered when the temp is below your alarm threshold. There is no check to trigger the alarm one time only (ie, when the threshold is first crossed). To fix this, add a boolean variable (e.g. "trigger"). Check for trigger being true after checking the temperature is out of range. If trigger is false, then make it true and activate the alarm. If it is true, then skip activating the alarm. For example, for your last block (this assumes you declared trigger as a boolean up top):
Code:
if "FV-1 PT100" value >= alarm_high
if trigger = false
"FV-1 TEMP ALARM" active = true
trigger = true
FV-1_alarm_status = "HIGH FV TEMP"
endif
sleep 10000
goto "Alarm-Count"
else
alarm_counter = 0
trigger = false
goto "Alarm-Check"
endif