diff --git a/tconnectsync/parser/nightscout.py b/tconnectsync/parser/nightscout.py index 8b533ff..00c6022 100644 --- a/tconnectsync/parser/nightscout.py +++ b/tconnectsync/parser/nightscout.py @@ -195,14 +195,15 @@ def activity(created_at, duration, reason="", event_type=ACTIVITY_EVENTTYPE, pum } @staticmethod - def devicestatus(created_at, batteryVoltage, batteryString, pump_event_id=""): + def devicestatus(created_at, batteryVoltage, batteryPercent, pump_event_id=""): return { "device": ENTERED_BY, "created_at": created_at, "pump": { "battery": { "voltage": float(batteryVoltage), - "string": batteryString + "percent": int(batteryPercent) if batteryPercent else None, + "status": "%.0f%s" % (batteryPercent, '%') }, }, "pump_event_id": pump_event_id diff --git a/tconnectsync/sync/tandemsource/process_device_status.py b/tconnectsync/sync/tandemsource/process_device_status.py index 0461e25..545916c 100644 --- a/tconnectsync/sync/tandemsource/process_device_status.py +++ b/tconnectsync/sync/tandemsource/process_device_status.py @@ -59,7 +59,7 @@ def daily_basal_to_nsentry(self, event): return NightscoutEntry.devicestatus( created_at=event.eventTimestamp.format(), batteryVoltage=(float(event.batterylipomillivolts or 0)/1000), - batteryString="%.0f%s" % (100*event.batteryChargePercent, '%'), + batteryPercent=int(100*event.batteryChargePercent), pump_event_id = "%s" % event.seqNum ) diff --git a/tests/sync/tandemsource/test_process_device_status.py b/tests/sync/tandemsource/test_process_device_status.py index 1ae6cc7..7d4e89f 100644 --- a/tests/sync/tandemsource/test_process_device_status.py +++ b/tests/sync/tandemsource/test_process_device_status.py @@ -38,7 +38,8 @@ def test_single_event_no_last_uploaded(self): 'device': 'Pump (tconnectsync)', 'pump': { 'battery': { - 'string': '48%', + 'status': '48%', + 'percent': 48, 'voltage': 14.08 } }, @@ -90,7 +91,8 @@ def test_multiple_event_with_last_uploaded(self): 'device': 'Pump (tconnectsync)', 'pump': { 'battery': { - 'string': '47%', + 'status': '47%', + 'percent': 47, 'voltage': 13.824 } }, @@ -132,7 +134,8 @@ def test_multiple_event_only_latest_applied(self): 'device': 'Pump (tconnectsync)', 'pump': { 'battery': { - 'string': '46%', + 'status': '46%', + 'percent': 46, 'voltage': 13.568 } },