Skip to content

Commit 72ee45b

Browse files
authored
Fix DevideByZeroError (#10)
1 parent 019f428 commit 72ee45b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

toonapi/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ def current_covered_by_solar(self) -> int | None:
268268
"""Calculate current solar covering current usage."""
269269
if self.current_solar is None or self.current is None:
270270
return None
271+
if self.current == 0:
272+
return 0
271273
return min(100, round((self.current_solar / self.current) * 100))
272274

273275
def update_from_dict(self, data: dict[str, Any]) -> None:

0 commit comments

Comments
 (0)