mirror of
https://github.com/bckelley/tconnectsync.git
synced 2026-08-28 05:34:10 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a2a4ca771 | ||
|
|
54ba2ed7df | ||
|
|
2892eb8ace |
@@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = tconnectsync
|
||||
version = 2.1.5
|
||||
version = 2.1.6
|
||||
author = James Woglom
|
||||
author_email = j@wogloms.net
|
||||
description = Syncs Tandem Source (formerly t:connect) insulin pump data to Nightscout for the t:slim X2
|
||||
|
||||
@@ -25,6 +25,9 @@ class PumpProfile:
|
||||
carbEntry: int # 1 / 0
|
||||
maxBolus: int # milliunits
|
||||
|
||||
def __post_init__(self):
|
||||
self.tDependentSegs = [i for i in self.tDependentSegs if not i.skip]
|
||||
|
||||
@dataclass_json
|
||||
@dataclass
|
||||
class PumpProfiles:
|
||||
|
||||
@@ -251,30 +251,33 @@ class NightscoutEntry:
|
||||
return {
|
||||
# insulin duration in hours; Nightscout JS bug requires all top-level fields to be strings
|
||||
"dia": "%s" % (profile.insulinDuration / 60),
|
||||
"carbratio": [
|
||||
"carbratio": list(sorted([
|
||||
{
|
||||
"time": minutes_to_ns_time(segment.startTime),
|
||||
"timeAsSeconds": segment.startTime * 60,
|
||||
"value": segment.carbRatio / 1000 # milliunits->units
|
||||
} for segment in profile.tDependentSegs
|
||||
],
|
||||
} for segment in profile.tDependentSegs if not segment.skip
|
||||
], key=lambda x: x["timeAsSeconds"])),
|
||||
|
||||
"carbs_hr": NIGHTSCOUT_PROFILE_CARBS_HR_VALUE,
|
||||
"delay": NIGHTSCOUT_PROFILE_DELAY_VALUE,
|
||||
"sens": [ # Correction factor / isf
|
||||
|
||||
"sens": list(sorted([ # Correction factor / isf
|
||||
{
|
||||
"time": minutes_to_ns_time(segment.startTime),
|
||||
"timeAsSeconds": segment.startTime * 60,
|
||||
"value": segment.isf
|
||||
} for segment in profile.tDependentSegs
|
||||
],
|
||||
"basal": [
|
||||
} for segment in profile.tDependentSegs if not segment.skip
|
||||
], key=lambda x: x["timeAsSeconds"])),
|
||||
|
||||
"basal": list(sorted([
|
||||
{
|
||||
"time": minutes_to_ns_time(segment.startTime),
|
||||
"timeAsSeconds": segment.startTime * 60,
|
||||
"value": segment.basalRate / 1000 # milliunits->units
|
||||
} for segment in profile.tDependentSegs
|
||||
],
|
||||
], key=lambda x: x["timeAsSeconds"])),
|
||||
|
||||
"target_low": [
|
||||
{
|
||||
"time": "00:00",
|
||||
|
||||
@@ -8,7 +8,7 @@ from ...features import DEFAULT_FEATURES
|
||||
from ... import features
|
||||
from ...domain.tandemsource.pump_settings import PumpSettings
|
||||
from ...parser.nightscout import (
|
||||
NightscoutEntry
|
||||
NightscoutEntry, ENTERED_BY
|
||||
)
|
||||
from ...secret import NIGHTSCOUT_PROFILE_UPLOAD_MODE
|
||||
|
||||
@@ -53,6 +53,8 @@ class UpdateProfiles:
|
||||
if ns_profile_obj is None:
|
||||
ns_profile_obj = {}
|
||||
|
||||
logger.info("Current Nightscout profile was authored by: %s" % (ns_profile_obj.get('enteredBy')))
|
||||
|
||||
diff, ns_profile_new = self.compare_profiles(pump_settings, ns_profile_obj)
|
||||
if not diff:
|
||||
logger.info("Pump and Nightscout profiles up to date")
|
||||
@@ -145,6 +147,7 @@ class UpdateProfiles:
|
||||
return False, ns_profile_obj
|
||||
|
||||
logger.info("New Nightscout profile object: %s", new_ns_profile)
|
||||
new_ns_profile['enteredBy'] = ENTERED_BY
|
||||
return True, new_ns_profile
|
||||
|
||||
def nightscout_profiles_identical(self, configured: dict, translated: dict) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user