diff --git a/bin/mm-format-ns-treatments.sh b/bin/mm-format-ns-treatments.sh index 8fac046c5..d104254dd 100755 --- a/bin/mm-format-ns-treatments.sh +++ b/bin/mm-format-ns-treatments.sh @@ -18,6 +18,11 @@ EOT # | json -e "this.type = 'mm://openaps/$self'" \ model=$(jq -r . $MODEL) +#load ns event preferences +PREF=${4-preferences.json} +rewind_indicates_cartridge_change=$(jq -r .rewind_indicates_cartridge_change $PREF) +prime_indicates_pump_site_change=$(jq -r .prime_indicates_pump_site_change $PREF) +battery_indicates_battery_change=$(jq -r .battery_indicates_battery_change $PREF) run_remote_command "oref0-normalize-temps $HISTORY" \ | jq '[ .[] @@ -25,10 +30,13 @@ run_remote_command "oref0-normalize-temps $HISTORY" \ | .created_at = if .created_at then .created_at else .timestamp end | .enteredBy = "openaps://medtronic/'$model'" | if .glucose and (.glucoseType | not) and .glucose > 0 then .glucoseType = .enteredBy else . end + | if ._type == "Rewind" and "'$rewind_indicates_cartridge_change'" == "true" then .eventType = "Insulin Change" else . end + | if ._type == "Prime" and .type == "fixed" and "'$prime_indicates_pump_site_change'" == "true" then .eventType = "Site Change" else . end + | if ._type == "Battery" and "'$battery_indicates_battery_change'" == "true" then .eventType = "Pump Battery Change" else . end | .eventType = if .eventType then .eventType else "Note" end | if ._type == "AlarmSensor" and .alarm_description then .notes = .alarm_description else . end | ( if .notes then .notes else "" end ) as $note - | if ( .eventType == "Note" ) and ( .alarm_description | not ) then .notes = ( [ ._type, "'" $model "'", $note ] | join("") ) else . end + | if ( .eventType == "Note" or .eventType == "Insulin Change" or .eventType == "Site Change" or .eventType == "Pump Battery Change" ) and ( .alarm_description | not ) then .notes = ( [ ._type, "'" $model "'", $note ] | join("") ) else . end ]' \ > $OUTPUT diff --git a/examples/profile.json b/examples/profile.json index a79a4119d..125c7e96f 100644 --- a/examples/profile.json +++ b/examples/profile.json @@ -63,6 +63,9 @@ "enableSMB_with_COB": true, "enableSMB_with_temptarget": false, "enableSMB_after_carbs": true, + "prime_indicates_pump_site_change": false, + "rewind_indicates_cartridge_change": false, + "battery_indicates_battery_change": false, "maxSMBBasalMinutes": 75, "curve": "rapid-acting", "useCustomPeakTime": false,