From 74b1f2990f4979bea01e1719c8d37ec18b2645f4 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 11 Sep 2022 09:47:10 -0700 Subject: [PATCH 1/2] fix: adjust power calculation function --- openevsehttp/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openevsehttp/__init__.py b/openevsehttp/__init__.py index 1af82d4..b8e0c2b 100644 --- a/openevsehttp/__init__.py +++ b/openevsehttp/__init__.py @@ -816,14 +816,16 @@ def wifi_serial(self) -> str | None: return None @property - def charging_power(self) -> float: + def charging_power(self) -> float | None: """Return the charge power. Calculate Watts base on V*I """ - assert self._status is not None - value = round(self._status["voltage"] * self._status["amp"], 2) - return value + if self._status is not None and any( + key in self._status for key in ["voltage", "amp"] + ): + return round(self._status["voltage"] * self._status["amp"], 2) + return None # There is currently no min/max amps JSON data # available via HTTP API methods From d503ce0f01f4e05b016abf26d23933948a61ecf1 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 11 Sep 2022 09:50:03 -0700 Subject: [PATCH 2/2] adjust pylint config --- pylintrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/pylintrc b/pylintrc index 87f96a1..aa7931e 100644 --- a/pylintrc +++ b/pylintrc @@ -16,7 +16,6 @@ max-attributes=15 # too-few-* - same as too-many-* # import-outside-toplevel - TODO disable= - bad-continuation, duplicate-code, fixme, import-outside-toplevel, @@ -26,7 +25,6 @@ disable= too-many-public-methods, too-many-instance-attributes, too-many-branches, - no-self-use, too-many-statements [REPORTS]