From 8244d26a35f515903a5b9c63e7862ec4ba4960d7 Mon Sep 17 00:00:00 2001 From: flopp999 <21694965+flopp999@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:15:38 +0200 Subject: [PATCH 1/2] fix for issue #38 division by zero https://github.com/faanskit/pyCheckwatt/issues/38 --- pycheckwatt/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pycheckwatt/__init__.py b/pycheckwatt/__init__.py index 3c3047b..ffdb26f 100644 --- a/pycheckwatt/__init__.py +++ b/pycheckwatt/__init__.py @@ -390,7 +390,10 @@ async def get_fcrd_month_net_revenue(self): misseddays += 1 dayswithmoney = int(dayssofar) - int(misseddays) if response.status == 200: - self.dailyaverage = self.revenuemonth / int(dayswithmoney) + if dayswithmoney > 0: + self.dailyaverage = self.revenuemonth / int(dayswithmoney) + else: + self.dailyaverage = 0 self.monthestimate = ( self.dailyaverage * daysleft ) + self.revenuemonth From ad18fe762c5e5d0748c209e005e158618e0d5378 Mon Sep 17 00:00:00 2001 From: flopp999 <21694965+flopp999@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:22:26 +0200 Subject: [PATCH 2/2] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index eb822f7..e780139 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pycheckwatt" -version = "0.2.6" +version = "0.2.7" description = "Read data from CheckWatts EnergyInBalance WEB API" authors = ["Marcus Karlsson ", "Anders Yderborg ", "Daniel Nilsson "] license = "MIT License"