From d6b0410514ccd5ebbc414e53750caa16c7bdcd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bj=C3=B6rkert?= Date: Thu, 25 Jun 2026 22:00:01 +0200 Subject: [PATCH] Upload isCharging in uploader device status Populate the new UploaderStatus.isCharging flag from the device battery state so the Nightscout device status reflects whether the uploading device is on power. A full battery counts as charging, matching iOS battery state semantics where a plugged-in device at 100% reports .full rather than .charging. --- NightscoutServiceKit/Extensions/StoredDosingDecision.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NightscoutServiceKit/Extensions/StoredDosingDecision.swift b/NightscoutServiceKit/Extensions/StoredDosingDecision.swift index aba4104..4e1d49e 100644 --- a/NightscoutServiceKit/Extensions/StoredDosingDecision.swift +++ b/NightscoutServiceKit/Extensions/StoredDosingDecision.swift @@ -139,7 +139,10 @@ extension StoredDosingDecision { var uploaderStatus: UploaderStatus { let uploaderDevice = UIDevice.current let battery = uploaderDevice.isBatteryMonitoringEnabled ? Int(uploaderDevice.batteryLevel * 100) : 0 - return UploaderStatus(name: uploaderDevice.name, timestamp: date, battery: battery) + let isCharging: Bool? = uploaderDevice.isBatteryMonitoringEnabled + ? (uploaderDevice.batteryState == .charging || uploaderDevice.batteryState == .full) + : nil + return UploaderStatus(name: uploaderDevice.name, timestamp: date, battery: battery, isCharging: isCharging) } func deviceStatus(automaticDoseDecision: StoredDosingDecision?) -> DeviceStatus {