devicestatus: set pump.battery.percent

This commit is contained in:
James Woglom
2024-12-12 22:20:13 -05:00
parent fb9588ff2c
commit d1341e09c0
3 changed files with 10 additions and 6 deletions
+3 -2
View File
@@ -195,14 +195,15 @@ class NightscoutEntry:
} }
@staticmethod @staticmethod
def devicestatus(created_at, batteryVoltage, batteryString, pump_event_id=""): def devicestatus(created_at, batteryVoltage, batteryPercent, pump_event_id=""):
return { return {
"device": ENTERED_BY, "device": ENTERED_BY,
"created_at": created_at, "created_at": created_at,
"pump": { "pump": {
"battery": { "battery": {
"voltage": float(batteryVoltage), "voltage": float(batteryVoltage),
"string": batteryString "percent": int(batteryPercent) if batteryPercent else None,
"status": "%.0f%s" % (batteryPercent, '%')
}, },
}, },
"pump_event_id": pump_event_id "pump_event_id": pump_event_id
@@ -59,7 +59,7 @@ class ProcessDeviceStatus:
return NightscoutEntry.devicestatus( return NightscoutEntry.devicestatus(
created_at=event.eventTimestamp.format(), created_at=event.eventTimestamp.format(),
batteryVoltage=(float(event.batterylipomillivolts or 0)/1000), batteryVoltage=(float(event.batterylipomillivolts or 0)/1000),
batteryString="%.0f%s" % (100*event.batteryChargePercent, '%'), batteryPercent=int(100*event.batteryChargePercent),
pump_event_id = "%s" % event.seqNum pump_event_id = "%s" % event.seqNum
) )
@@ -38,7 +38,8 @@ class TestProcessDeviceStatus(unittest.TestCase):
'device': 'Pump (tconnectsync)', 'device': 'Pump (tconnectsync)',
'pump': { 'pump': {
'battery': { 'battery': {
'string': '48%', 'status': '48%',
'percent': 48,
'voltage': 14.08 'voltage': 14.08
} }
}, },
@@ -90,7 +91,8 @@ class TestProcessDeviceStatus(unittest.TestCase):
'device': 'Pump (tconnectsync)', 'device': 'Pump (tconnectsync)',
'pump': { 'pump': {
'battery': { 'battery': {
'string': '47%', 'status': '47%',
'percent': 47,
'voltage': 13.824 'voltage': 13.824
} }
}, },
@@ -132,7 +134,8 @@ class TestProcessDeviceStatus(unittest.TestCase):
'device': 'Pump (tconnectsync)', 'device': 'Pump (tconnectsync)',
'pump': { 'pump': {
'battery': { 'battery': {
'string': '46%', 'status': '46%',
'percent': 46,
'voltage': 13.568 'voltage': 13.568
} }
}, },