Skip to content

Commit

Permalink
fix: Fixed average cost on target rate sensors to handle when no rate…
Browse files Browse the repository at this point in the history
…s are available
  • Loading branch information
BottlecapDave committed Apr 10, 2023
1 parent 9cc7694 commit b67989e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_target_rate_info(current_date: datetime, applicable_rates, offset: str =

return {
"is_active": is_active,
"overall_average_cost": round(overall_total_cost / total_applicable_rates, 5),
"overall_average_cost": round(overall_total_cost / total_applicable_rates, 5) if total_applicable_rates > 0 else 0,
"overall_min_cost": overall_min_cost,
"overall_max_cost": overall_max_cost,
"current_duration_in_hours": current_duration_in_hours,
Expand Down

0 comments on commit b67989e

Please sign in to comment.