Alarm consistency by imbercal · Pull Request #509 · loopandlearn/LoopFollow

This PR corrects the language in alarm editor UI text to accurately reflect the underlying comparison logic. Several alarms use <= or >= comparisons but their UI text implied strict < or > comparisons, which could mislead users about exactly when alarms would trigger.

Problem

Most alarms use logic like level >= limit or level <= limit, but the UI language in .footer strings and titles often said "above" or "below" without indicating that the threshold value itself would also trigger the alarm.

For example:

  • Battery alarm logic: level <= limit (fires at 20% if threshold is 20%)
  • Battery alarm text: "drops below this level" (implies it wouldn't fire at exactly 20%)

Summary of Issues Found

Alarm Component Previous Text Logic Mismatch
Phone Battery Footer "drops below" <= Missing "or equal to"
Pump Battery Footer "drops below" <= Missing "or equal to"
COB InfoBanner "exceeds" >= "exceeds" implies > not >=
COB Footer "is above" >= Missing "or equal to"
RecBolus Footer "is above" >= Missing "or equal to"
RecBolus Title "More than" >= "More than" implies > not >=
MissedBolus (carbs) Footer "below" ignores <= Missing "or equal to"
MissedBolus (bolus) Footer "below" ignores <= Missing "or equal to"

Changes

PhoneBatteryAlarmEditor.swift

  • Footer: "drops below" → "drops to or below"

PumpBatteryAlarmEditor.swift

  • Footer: "drops below" → "drops to or below"

COBAlarmEditor.swift

  • InfoBanner: "exceeds" → "reaches or exceeds"
  • Footer: "is above" → "is at or above"
  • Title: "Above" → "At or Above"

RecBolusAlarmEditor.swift

  • Footer: "is above" → "is at or above"
  • Title: "More than" → "At or Above"

MissedBolusAlarmEditor.swift

  • Ignore small boluses footer: "below" → "at or below"
  • Ignore small boluses title: "Ignore below" → "Ignore at or below"
  • Ignore small carbs footer: "below" → "at or below"
  • Ignore small carbs title: "Below" → "At or Below"

Logic Reference

Alarm Condition File Logic Now Matches UI
Phone Battery PhoneBatteryCondition.swift level <= limit "to or below"
Pump Battery PumpBatteryCondition.swift level <= limit "to or below"
COB COBCondition.swift:12 cob >= threshold "at or above"
RecBolus RecBolusCondition.swift:16 rec >= threshold "at or above"
MissedBolus (carbs) MissedBolusCondition.swift:37 carb.grams > minCarbGr (ignores <=) "at or below"
MissedBolus (bolus) MissedBolusCondition.swift:55 bolus.units > minBolusU (ignores <=) "at or below"

Not Changed

The MissedBolus "Ignore low BG" section was already correct:

  • Footer: "Only alert if the current BG is above this value."
  • Logic: Fires when BG > threshold (strict greater than)

Testing

  1. Open each alarm editor and verify the updated text displays correctly:
    • Settings → Alarms → [Add or edit each alarm type]
    • Low Battery (Phone)
    • Low Battery (Pump)
    • COB Alert
    • Rec. Bolus
    • Missed Bolus Alert

Note - no logic has been changed (so there are all 4 options, >, <, >=, <=) - whether it should be standardised so all alarms are >= or <= and the text updated to reflect that?

Closes: #507