Dash: reminder relative to expiry, alert relative to pod shutdown

This commit is contained in:
jbr7rr 2023-08-29 10:17:47 +02:00
parent baa69829c3
commit 3ce0ef0fdc
7 changed files with 32 additions and 29 deletions

View file

@ -8,7 +8,7 @@
<string name="key_omnipod_common_suspend_delivery_button_enabled" translatable="false">AAPS.Omnipod.suspend_delivery_button_enabled</string>
<string name="key_omnipod_common_time_change_event_enabled" translatable="false">AAPS.Omnipod.time_change_enabled</string>
<string name="key_omnipod_common_expiration_reminder_enabled" translatable="false">AAPS.Omnipod.expiration_reminder_enabled</string>
<string name="key_omnipod_common_expiration_reminder_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_shutdown</string>
<string name="key_omnipod_common_expiration_reminder_hours_before_expiry" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_expiry</string>
<string name="key_omnipod_common_expiration_alarm_enabled" translatable="false">AAPS.Omnipod.expiration_alarm_enabled</string>
<string name="key_omnipod_common_expiration_alarm_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_alarm_hours_before_shutdown</string>
<string name="key_omnipod_common_low_reservoir_alert_enabled" translatable="false">AAPS.Omnipod.low_reservoir_alert_enabled</string>
@ -132,7 +132,7 @@
<string name="omnipod_common_preferences_time_change_enabled">DST/Time zone detection enabled</string>
<string name="omnipod_common_preferences_expiration_reminder_enabled">Expiration reminder enabled</string>
<string name="omnipod_common_preferences_expiration_reminder_enabled_summary">When enabled the pod will beep when the specified time is reached</string>
<string name="omnipod_common_preferences_expiration_reminder_hours_before_shutdown">Reminder at hours before shutdown (80 Hours)</string>
<string name="omnipod_common_preferences_expiration_reminder_hours_before_expiry">Reminder at hours before expiry (72 Hours)</string>
<string name="omnipod_common_preferences_expiration_alarm_enabled">Expiration alert enabled</string>
<string name="omnipod_common_preferences_expiration_alarm_enabled_summary">When enabled the pod will beep when the specified time is reached and every hour after that</string>
<string name="omnipod_common_preferences_expiration_alarm_hours_before_shutdown">Alert at hours before shutdown (80 Hours)</string>

View file

@ -482,7 +482,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
.subscribe(
{
if (it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled)) ||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown)) ||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry)) ||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled)) ||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown)) ||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled)) ||
@ -1224,7 +1224,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun updateAlertConfiguration(): PumpEnactResult {
val expirationReminderEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled, true)
val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown, 7)
val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry, 9)
val expirationAlarmEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled, true)
val expirationAlarmHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown, 8)
val lowReservoirAlertEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled, true)
@ -1250,16 +1250,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
val podLifeLeft = Duration.between(ZonedDateTime.now(), podStateManager.expiry)
val expiryAlertDelay = podLifeLeft.minus(Duration.ofHours(expirationReminderHours.toLong()))
if (expiryAlertDelay.isNegative) {
val expiryReminderDelay = podLifeLeft.minus(Duration.ofHours(expirationReminderHours.toLong()))
if (expiryReminderDelay.isNegative) {
aapsLogger.warn(
LTag.PUMPBTCOMM,
"updateAlertConfiguration negative " +
"expiryAlertDuration=$expiryAlertDelay"
"expiryAlertDuration=$expiryReminderDelay"
)
PumpEnactResult(injector).success(false).enacted(false)
}
val expiryAlarmDelay = podLifeLeft.minus(Duration.ofHours(expirationAlarmHours.toLong()))
// expiry Alarm Delay, add 8 hours (grace period)
val expiryAlarmDelay = podLifeLeft.minus(Duration.ofHours(expirationAlarmHours.toLong())).plus(Duration.ofHours(8))
if (expiryAlarmDelay.isNegative) {
aapsLogger.warn(
LTag.PUMPBTCOMM,
@ -1268,7 +1269,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
)
PumpEnactResult(injector).success(false).enacted(false)
}
val expiryImminentDelay = podLifeLeft.minus(Duration.ofHours(POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING))
val expiryImminentDelay = podLifeLeft.minus(Duration.ofHours(POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING)).plus(Duration.ofHours(8))
if (expiryImminentDelay.isNegative) {
aapsLogger.warn(
LTag.PUMPBTCOMM,
@ -1293,7 +1294,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
expiryAlertDelay.toMinutes().toShort()
expiryReminderDelay.toMinutes().toShort()
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
@ -1301,7 +1302,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
AlertConfiguration(
AlertType.EXPIRATION,
enabled = expirationAlarmEnabled,
durationInMinutes = TimeUnit.HOURS.toMinutes(expirationAlarmHours.toLong()).toShort(),
durationInMinutes = TimeUnit.HOURS.toMinutes((expirationAlarmHours - 1).toLong()).toShort(),
autoOff = false,
AlertTrigger.TimerTrigger(
expiryAlarmDelay.toMinutes().toShort()

View file

@ -424,18 +424,19 @@ class OmnipodDashManagerImpl @Inject constructor(
val expirationAlarmEnabled = userConfiguredExpirationAlarmHours != null && userConfiguredExpirationAlarmHours > 0
val expirationAlarmDelay = podLifeLeft.minus(
Duration.ofHours(userConfiguredExpirationAlarmHours ?: POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT)
)
val expirationImminnentDelay = podLifeLeft.minus(
).plus(Duration.ofHours(8)) // Add 8 hours for grace period
val expirationImminentDelay = podLifeLeft.minus(
Duration.ofHours(POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING)
)
).plus(Duration.ofHours(8)) // Add 8 hours for grace period
val alerts = mutableListOf(
AlertConfiguration(
AlertType.EXPIRATION,
enabled = expirationAlarmEnabled,
durationInMinutes = TimeUnit.HOURS.toMinutes(
durationInMinutes = (TimeUnit.HOURS.toMinutes(
userConfiguredExpirationAlarmHours ?: POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT
).toShort(),
) - 60).toShort(),
autoOff = false,
AlertTrigger.TimerTrigger(
expirationAlarmDelay.toMinutes().toShort()
@ -449,30 +450,31 @@ class OmnipodDashManagerImpl @Inject constructor(
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
expirationImminnentDelay.toMinutes().toShort()
expirationImminentDelay.toMinutes().toShort()
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.XXX4
)
)
val userExpiryAlertDelay = podLifeLeft.minus(
val userExpiryReminderEnabled = userConfiguredExpirationReminderHours != null && userConfiguredExpirationReminderHours > 0
val userExpiryReminderDelay = podLifeLeft.minus(
Duration.ofHours(userConfiguredExpirationReminderHours ?: MAX_POD_LIFETIME.toHours() + 1)
)
if (userExpiryAlertDelay.isNegative) {
if (userExpiryReminderDelay.isNegative) {
logger.warn(
LTag.PUMPBTCOMM,
"createActivationPart2Observables negative " +
"expiryAlertDuration=$userExpiryAlertDelay"
"expiryAlertDuration=$userExpiryReminderDelay"
)
} else {
alerts.add(
AlertConfiguration(
AlertType.USER_SET_EXPIRATION,
enabled = true,
enabled = userExpiryReminderEnabled,
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
userExpiryAlertDelay.toMinutes().toShort()
userExpiryReminderDelay.toMinutes().toShort()
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN

View file

@ -67,7 +67,7 @@ class DashInsertCannulaViewModel @Inject constructor(
basalProgram
)
val expirationReminderEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled, true)
val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown, 9)
val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry, 9)
val expirationReminderHoursBeforeShutdown = if (expirationReminderEnabled)
expirationReminderHours.toLong()

View file

@ -45,8 +45,8 @@
android:dependency="@string/key_omnipod_common_expiration_reminder_enabled"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_shutdown"
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_shutdown"
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_expiry"
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_expiry"
validate:maxNumber="24"
validate:minNumber="2"
validate:testType="numericRange" />
@ -64,7 +64,7 @@
android:inputType="number"
android:key="@string/key_omnipod_common_expiration_alarm_hours_before_shutdown"
android:title="@string/omnipod_common_preferences_expiration_alarm_hours_before_shutdown"
validate:maxNumber="24"
validate:maxNumber="8"
validate:minNumber="1"
validate:testType="numericRange" />

View file

@ -14,7 +14,7 @@ public class OmnipodErosStorageKeys {
public static final int PULSE_LOG_BUTTON_ENABLED = R.string.key_omnipod_eros_pulse_log_button_enabled;
public static final int TIME_CHANGE_EVENT_ENABLED = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_time_change_event_enabled;
public static final int EXPIRATION_REMINDER_ENABLED = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled;
public static final int EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown;
public static final int EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry;
public static final int LOW_RESERVOIR_ALERT_ENABLED = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled;
public static final int LOW_RESERVOIR_ALERT_UNITS = info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_units;
public static final int NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED = R.string.key_omnipod_eros_notification_uncertain_tbr_sound_enabled;

View file

@ -76,8 +76,8 @@
android:dependency="@string/key_omnipod_common_expiration_reminder_enabled"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_shutdown"
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_shutdown"
android:key="@string/key_omnipod_common_expiration_reminder_hours_before_expiry"
android:title="@string/omnipod_common_preferences_expiration_reminder_hours_before_expiry"
validate:maxNumber="24"
validate:minNumber="2"
validate:testType="numericRange" />