Alarms, state & notification delivery
Model an alarm as a state machine, not a repeated email.
Proposed rule contract
Rule: measurement + comparison + threshold
+ duration + recovery threshold + recipient policyA temperature rule might require a threshold to remain exceeded for a configured period. Track the first qualifying observation, subsequent evidence and the transition into an active alarm. Define how gaps in data affect that duration; silence is not evidence of a safe condition.
Recovery and repetition
Use a separate recovery threshold or minimum recovery duration to reduce oscillation. Create one alarm instance per active episode. Acknowledgement records that a person saw it; recovery records that the rule is no longer active. Neither implies the other.
Delivery is a separate record
Store channel, recipient reference, provider message ID, attempt count and result. Retries should reuse a stable notification identity. Bound reminders and escalation frequency. Email/SMS acceptance by a provider is not proof that a person received or acted on the message.
Missing data
Add independent stale-device and gateway-health rules. Display last-seen time and measurement quality alongside values. Define the operational response with the customer before enabling alerts.