Skip to content

Commit

Permalink
Change time interval rounding to 5s which matches iotawatts data log …
Browse files Browse the repository at this point in the history
  • Loading branch information
amosyuen committed Mar 20, 2023
1 parent c758405 commit 2f508a3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions iotawattpy/iotawatt.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@ async def _refreshSensors(self, timespan, lastUpdate):
# incorrect result. As a workaround, we use UTC.
now = datetime.now(tz=timezone.utc)

# The iotawatt only supports rounded seconds. We also ound to the nearest 30s
# The iotawatt only supports rounded seconds. We also round to the nearest 5s,
# iotawatt's measurement interval.
seconds = now.second
diff = seconds - 30 if seconds >= 30 else seconds
diff = seconds % 5
now -= timedelta(seconds=diff, microseconds=now.microsecond)

if lastUpdate is None:
Expand Down

0 comments on commit 2f508a3

Please sign in to comment.