Skip to content

Commit

Permalink
Nighscout fixes
Browse files Browse the repository at this point in the history
* Upload SMB boluses as Entry Type "SMB" in Nightscout.
* Change "freeaps-x" to "iAPS" in "Entered By:"
* Change from "freeaps-x-remote" to simply "remote" for remote commands

(cherry picked from commit 0f8736be187a84909ab139a9107678541e758680)
  • Loading branch information
Jon-b-m committed Sep 25, 2023
1 parent fbffdf9 commit 24c5abb
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable {
rawRate: nil,
absolute: nil,
rate: nil,
eventType: .bolus,
eventType: (event.isSMB ?? false) ? .smb : .bolus,
createdAt: event.timestamp,
enteredBy: NigtscoutTreatment.local,
bolus: event,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,9 @@ Enact a temp Basal or a temp target */
/* Manual temp basal mode */
"Manual" = "Manual";

/* An Automatic delivered bolus (SMB) */
"SMB" = "SMB";

/* Status highlight when manual temp basal is running. */
"Manual Basal" = "Manual Basal";

Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/AlertEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct AlertEntry: JSON, Codable, Hashable {
let contentBody: String?
var errorMessage: String?

static let manual = "freeaps-x"
static let manual = "iAPS"

static func == (lhs: AlertEntry, rhs: AlertEntry) -> Bool {
lhs.issuedDate == rhs.issuedDate
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/Announcement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Announcement: JSON {
let enteredBy: String
let notes: String

static let remote = "freeaps-x-remote"
static let remote = "remote"

var action: AnnouncementAction? {
let components = notes.replacingOccurrences(of: " ", with: "").split(separator: ":")
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/CarbsEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct CarbsEntry: JSON, Equatable, Hashable {
let isFPU: Bool?
let fpuID: String?

static let manual = "freeaps-x"
static let manual = "iAPS"
static let appleHealth = "applehealth"

static func == (lhs: CarbsEntry, rhs: CarbsEntry) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/NightscoutTreatment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct NigtscoutTreatment: JSON, Hashable, Equatable {
let targetTop: Decimal?
let targetBottom: Decimal?

static let local = "freeaps-x"
static let local = "iAPS"

static let empty = NigtscoutTreatment(from: "{}")!

Expand Down
1 change: 1 addition & 0 deletions FreeAPS/Sources/Models/PumpHistoryEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct PumpHistoryEvent: JSON, Equatable {

enum EventType: String, JSON {
case bolus = "Bolus"
case smb = "SMB"
case mealBulus = "Meal Bolus"
case correctionBolus = "Correction Bolus"
case snackBolus = "Snack Bolus"
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/TempTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct TempTarget: JSON, Identifiable, Equatable, Hashable {
let enteredBy: String?
let reason: String?

static let manual = "freeaps-x"
static let manual = "iAPS"
static let custom = "Temp target"
static let cancel = "Cancel"

Expand Down
9 changes: 6 additions & 3 deletions FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ enum DataTable {
duration: Decimal? = nil,
id: String? = nil,
idPumpEvent: String? = nil,
isFPU: Bool? = false,
isFPU: Bool? = nil,
fpuID: String? = nil,
note: String? = nil,
isSMB: Bool? = nil
Expand Down Expand Up @@ -137,7 +137,10 @@ enum DataTable {
case .bolus:
return numberFormatter
.string(from: amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") +
((isSMB ?? false) ? " 🤖" : " " + NSLocalizedString("Manual", comment: "Manual Bolus"))
(
(isSMB ?? false) ? " " + NSLocalizedString("Auto", comment: "Automatic delivered bolus (SMB)") : " " +
NSLocalizedString("Manual", comment: "Manual Bolus")
)
case .tempBasal:
return numberFormatter
.string(from: amount as NSNumber)! + NSLocalizedString(" U/hr", comment: "Unit insulin per hour")
Expand Down Expand Up @@ -167,7 +170,7 @@ enum DataTable {
case .carbs:
return .loopYellow
case .fpus:
return .red
return .loopRed
case .bolus:
return .insulin
case .tempBasal:
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Services/Network/NightscoutAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension NightscoutAPI {
func checkConnection() -> AnyPublisher<Void, Swift.Error> {
struct Check: Codable, Equatable {
var eventType = "Note"
var enteredBy = "freeaps-x"
var enteredBy = "iAPS"
var notes = "iAPS connected"
}
let check = Check()
Expand Down

0 comments on commit 24c5abb

Please sign in to comment.