Skip to content

Commit

Permalink
autoupdate: reset API connection when event index change is recorded …
Browse files Browse the repository at this point in the history
…but no data is found, potential fix for #11
  • Loading branch information
jwoglom committed Jan 4, 2022
1 parent 0d95651 commit e2b3068
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tconnectsync/autoupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
import logging
import sys

from .api import TConnectApi
from .process import process_time_range
from .features import DEFAULT_FEATURES
from .secret import (
TCONNECT_EMAIL,
TCONNECT_PASSWORD,
PUMP_SERIAL_NUMBER,
AUTOUPDATE_DEFAULT_SLEEP_SECONDS,
AUTOUPDATE_MAX_SLEEP_SECONDS,
Expand Down Expand Up @@ -42,6 +45,9 @@ def process_auto_update(tconnect, nightscout, time_start, time_end, pretend, fea
if last_event_index:
logger.error('An event index change was recorded, but no new data was found via the API. ' +
'If this error reoccurs, try restarting tconnectsync.')

logger.info('Resetting TConnectApi')
tconnect = TConnectApi(TCONNECT_EMAIL, TCONNECT_PASSWORD)
else:
last_process_time_range = now

Expand Down

0 comments on commit e2b3068

Please sign in to comment.