diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.com> | 2023-08-03 11:12:46 +0200 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-08-03 11:20:21 +0200 |
commit | 50c8b19f42c58931af69f2f68f2bbb6ed076cd2a (patch) | |
tree | fe7578b489db3e691ad376b0d61cacbb79a7b27e | |
parent | Initial import of FreeStyle Libre 2 driver. (diff) | |
download | glucometerutils-50c8b19f42c58931af69f2f68f2bbb6ed076cd2a.tar glucometerutils-50c8b19f42c58931af69f2f68f2bbb6ed076cd2a.tar.gz glucometerutils-50c8b19f42c58931af69f2f68f2bbb6ed076cd2a.tar.bz2 glucometerutils-50c8b19f42c58931af69f2f68f2bbb6ed076cd2a.tar.lz glucometerutils-50c8b19f42c58931af69f2f68f2bbb6ed076cd2a.tar.xz glucometerutils-50c8b19f42c58931af69f2f68f2bbb6ed076cd2a.tar.zst glucometerutils-50c8b19f42c58931af69f2f68f2bbb6ed076cd2a.zip |
-rw-r--r-- | glucometerutils/support/freestyle_libre.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/glucometerutils/support/freestyle_libre.py b/glucometerutils/support/freestyle_libre.py index e5c9efe..46ecf15 100644 --- a/glucometerutils/support/freestyle_libre.py +++ b/glucometerutils/support/freestyle_libre.py @@ -14,7 +14,7 @@ import datetime import logging from typing import Dict, Generator, Mapping, Optional, Sequence, Tuple, Type -from glucometerutils import common +from glucometerutils import common, exceptions from glucometerutils.support import freestyle # Fields of the records returned by both $history and $arresult? @@ -218,9 +218,13 @@ class LibreDevice(freestyle.FreeStyleHidDevice): def get_glucose_unit(self) -> common.Unit: # pylint: disable=no-self-use """Returns the glucose unit of the device.""" - # TODO(Flameeyes): figure out how to identify the actual unit on the - # device. - return common.Unit.MG_DL + uom = self._session.send_text_command(b"$uom?").rstrip("\r\n") + if uom == "0": + return common.Unit.MMOL_L + if uom == "1": + return common.Unit.MG_DL + + raise exceptions.InvalidGlucoseUnit(uom) def get_readings(self) -> Generator[common.AnyReading, None, None]: # First of all get the usually longer list of sensor readings, and |