Poctech: fix unit conversion

This commit is contained in:
Milos Kozak 2021-12-03 19:29:45 +01:00
parent 67edb7a2fd
commit 4a899365db

View file

@ -70,8 +70,8 @@ class PoctechPlugin @Inject constructor(
val json = jsonArray.getJSONObject(i) val json = jsonArray.getJSONObject(i)
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += CgmSourceTransaction.TransactionGlucoseValue(
timestamp = json.getLong("date"), timestamp = json.getLong("date"),
value = if (safeGetString(json, "units", Constants.MGDL) == "mmol/L") json.getDouble("current") value = if (safeGetString(json, "units", Constants.MGDL) == "mmol/L") json.getDouble("current") * Constants.MMOLL_TO_MGDL
else json.getDouble("current") * Constants.MMOLL_TO_MGDL, else json.getDouble("current"),
raw = json.getDouble("raw"), raw = json.getDouble("raw"),
noise = null, noise = null,
trendArrow = GlucoseValue.TrendArrow.fromString(json.getString("direction")), trendArrow = GlucoseValue.TrendArrow.fromString(json.getString("direction")),