@@ -107,6 +107,7 @@ struct Alarm: Identifiable, Codable, Equatable {
107107 case missedBolusPrebolusWindow, missedBolusIgnoreSmallBolusUnits
108108 case missedBolusIgnoreUnderGrams, missedBolusIgnoreUnderBG
109109 case bolusCountThreshold, bolusWindowMinutes
110+ case sensorLifetimeDays
110111 }
111112
112113 init ( from decoder: Decoder ) throws {
@@ -137,6 +138,7 @@ struct Alarm: Identifiable, Codable, Equatable {
137138 missedBolusIgnoreUnderBG = try container. decodeIfPresent ( Double . self, forKey: . missedBolusIgnoreUnderBG)
138139 bolusCountThreshold = try container. decodeIfPresent ( Int . self, forKey: . bolusCountThreshold)
139140 bolusWindowMinutes = try container. decodeIfPresent ( Int . self, forKey: . bolusWindowMinutes)
141+ sensorLifetimeDays = try container. decodeIfPresent ( Int . self, forKey: . sensorLifetimeDays)
140142 }
141143
142144 func encode( to encoder: Encoder ) throws {
@@ -165,6 +167,7 @@ struct Alarm: Identifiable, Codable, Equatable {
165167 try container. encodeIfPresent ( missedBolusIgnoreUnderBG, forKey: . missedBolusIgnoreUnderBG)
166168 try container. encodeIfPresent ( bolusCountThreshold, forKey: . bolusCountThreshold)
167169 try container. encodeIfPresent ( bolusWindowMinutes, forKey: . bolusWindowMinutes)
170+ try container. encodeIfPresent ( sensorLifetimeDays, forKey: . sensorLifetimeDays)
168171 }
169172
170173 // ─────────────────────────────────────────────────────────────
@@ -191,6 +194,12 @@ struct Alarm: Identifiable, Codable, Equatable {
191194 /// ...within this many minutes
192195 var bolusWindowMinutes : Int ?
193196
197+ // ─────────────────────────────────────────────────────────────
198+ // Sensor‑Change fields ─
199+ // ─────────────────────────────────────────────────────────────
200+ /// CGM sensor lifetime in days (e.g. 10 for Dexcom G6, 15 for G7 15-day)
201+ var sensorLifetimeDays : Int ?
202+
194203 /// Function for when the alarm is triggered.
195204 /// If this alarm, all alarms is disabled or snoozed, then should not be called. This or all alarmd could be muted, then this function will just generate a notification.
196205 func trigger( config: AlarmConfiguration , now: Date ) {
@@ -318,6 +327,7 @@ struct Alarm: Identifiable, Codable, Equatable {
318327 case . sensorChange:
319328 soundFile = . wakeUpWillYou
320329 threshold = 12
330+ sensorLifetimeDays = 10
321331 case . pumpChange:
322332 soundFile = . wakeUpWillYou
323333 threshold = 12
0 commit comments