Skip to content

Commit

Permalink
Profile sync bugfix and extra validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoglom committed Jan 17, 2023
1 parent 85303bc commit d0af9c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tconnectsync/parser/nightscout.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def activity(created_at, duration, reason="", event_type=ACTIVITY_EVENTTYPE):
@staticmethod
def profile_store(profile: Profile, device_settings: DeviceSettings) -> dict:
return {
# insulin duration in hours
"dia": (profile.insulin_duration_min / 60),
# insulin duration in hours; Nightscout JS bug requires all top-level fields to be strings
"dia": "%s" % (profile.insulin_duration_min / 60),
"carbratio": [
{
"time": tandem_to_ns_time(segment.time),
Expand Down
4 changes: 4 additions & 0 deletions tconnectsync/sync/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def compare_profiles(device_profiles: List[Profile], device_settings: DeviceSett
if profile.active:
current_pump_profile = profile.title

if not current_pump_profile:
logger.error('No current pump profile, so skipping profile update: device: %s', device_profiles)
return False, current_ns_profile

current_ns_profile = ns_profile_obj.get('defaultProfile')
if current_pump_profile != current_ns_profile:
logger.info("Current profile changed: pump: %s nightscout: %s", current_pump_profile, current_ns_profile)
Expand Down

0 comments on commit d0af9c5

Please sign in to comment.