Skip to content

Commit

Permalink
Added rounding to distance, prevented end_time from NoneType as Times…
Browse files Browse the repository at this point in the history
…tamps need to be actual timestamps
  • Loading branch information
edwork committed Jan 6, 2023
1 parent 13d99e2 commit 6508a1d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/peloton/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ def compile_quant_data(
"End Time",
datetime.fromtimestamp(workout_stats_summary["end_time"], user_timezone)
if "end_time" in workout_stats_summary
and workout_stats_summary["end_time"] is not None
else None,
and workout_stats_summary["end_time"] is not None or not 'null'
else datetime.fromtimestamp(workout_stats_summary["start_time"], user_timezone),
None,
SensorDeviceClass.TIMESTAMP,
SensorStateClass.MEASUREMENT,
"mdi:timer-sand-complete",
),
PelotonStat(
"Duration",
duration_sec / 60
round((duration_sec / 60), 2)
if (
(duration_sec := workout_stats_summary.get("ride", {}).get("duration"))
and duration_sec is not None
Expand Down

0 comments on commit 6508a1d

Please sign in to comment.