diff --git a/tconnectsync/parser/nightscout.py b/tconnectsync/parser/nightscout.py index 1427e1b..94aefd7 100644 --- a/tconnectsync/parser/nightscout.py +++ b/tconnectsync/parser/nightscout.py @@ -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), diff --git a/tconnectsync/sync/profile.py b/tconnectsync/sync/profile.py index a4a9fbb..c187b16 100644 --- a/tconnectsync/sync/profile.py +++ b/tconnectsync/sync/profile.py @@ -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)