diff options
author | Ben <b-schaefer@posteo.de> | 2019-04-16 10:40:04 +0200 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.com> | 2019-09-02 19:55:45 +0200 |
commit | c13b8d7bc6c4d362c7da37482dd3a9dfe207424c (patch) | |
tree | 4e7369871d447fd38c546567ca5dd499af81ec3c /glucometerutils | |
parent | Add type: ignore comments when using lifescan_binary_protocol.Timestamp. (diff) | |
download | glucometerutils-c13b8d7bc6c4d362c7da37482dd3a9dfe207424c.tar glucometerutils-c13b8d7bc6c4d362c7da37482dd3a9dfe207424c.tar.gz glucometerutils-c13b8d7bc6c4d362c7da37482dd3a9dfe207424c.tar.bz2 glucometerutils-c13b8d7bc6c4d362c7da37482dd3a9dfe207424c.tar.lz glucometerutils-c13b8d7bc6c4d362c7da37482dd3a9dfe207424c.tar.xz glucometerutils-c13b8d7bc6c4d362c7da37482dd3a9dfe207424c.tar.zst glucometerutils-c13b8d7bc6c4d362c7da37482dd3a9dfe207424c.zip |
Diffstat (limited to 'glucometerutils')
-rw-r--r-- | glucometerutils/common.py | 3 | ||||
-rw-r--r-- | glucometerutils/drivers/fslibre.py | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/glucometerutils/common.py b/glucometerutils/common.py index 4af2001..4c7694c 100644 --- a/glucometerutils/common.py +++ b/glucometerutils/common.py @@ -66,6 +66,7 @@ class GlucoseReading: default=MeasurementMethod.BLOOD_SAMPLE, validator=attr.validators.in_( MeasurementMethod)) # type: MeasurementMethod + device_id = attr.ib(default=None) # type: int def get_value_as(self, to_unit): # type: (Unit) -> float @@ -89,6 +90,7 @@ class KetoneReading: timestamp = attr.ib() # type: datetime.datetime value = attr.ib() # type: float comment = attr.ib(default='') # type: Text + device_id = attr.ib(default=None) # type: int def as_csv(self, unit): """Returns the reading as a formatted comma-separated value string.""" @@ -106,6 +108,7 @@ class TimeAdjustment: default=MeasurementMethod.TIME, validator=attr.validators.in_( MeasurementMethod)) # type: MeasurementMethod + device_id = attr.ib(default=None) # type: int def as_csv(self, unit): del unit diff --git a/glucometerutils/drivers/fslibre.py b/glucometerutils/drivers/fslibre.py index 2823a2b..0e62aa6 100644 --- a/glucometerutils/drivers/fslibre.py +++ b/glucometerutils/drivers/fslibre.py @@ -26,6 +26,7 @@ from glucometerutils.support import freestyle # Fields of the records returned by both $history and $arresult? # Tuple of pairs of idx and field name _BASE_ENTRY_MAP = ( + (0, 'device_id'), (1, 'type'), (2, 'month'), (3, 'day'), @@ -116,7 +117,8 @@ def _parse_arresult(record): parsed_record.update(_parse_record(record, _ARRESULT_TIME_ADJUSTMENT_ENTRY_MAP)) return common.TimeAdjustment( _extract_timestamp(parsed_record), - _extract_timestamp(parsed_record, 'old_')) + _extract_timestamp(parsed_record, 'old_'), + device_id=parsed_record['device_id']) else: return None @@ -195,7 +197,8 @@ def _parse_arresult(record): _extract_timestamp(parsed_record), value, comment='; '.join(comment_parts), - measure_method=measure_method) + measure_method=measure_method, + device_id=parsed_record['device_id']) class Device(freestyle.FreeStyleHidDevice): """Glucometer driver for FreeStyle Libre devices.""" @@ -237,7 +240,9 @@ class Device(freestyle.FreeStyleHidDevice): _extract_timestamp(parsed_record), parsed_record['value'], comment='(Sensor)', - measure_method=common.MeasurementMethod.CGM) + measure_method=common.MeasurementMethod.CGM, + device_id=parsed_record['device_id'] + ) # Then get the results of explicit scans and blood tests (and other # events). |