Skip to content

Commit 7dc54a3

Browse files
authored
fix: adjust power calculation function (#93)
* fix: adjust power calculation function * adjust pylint config
1 parent 3bf5c47 commit 7dc54a3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

openevsehttp/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -816,14 +816,16 @@ def wifi_serial(self) -> str | None:
816816
return None
817817

818818
@property
819-
def charging_power(self) -> float:
819+
def charging_power(self) -> float | None:
820820
"""Return the charge power.
821821
822822
Calculate Watts base on V*I
823823
"""
824-
assert self._status is not None
825-
value = round(self._status["voltage"] * self._status["amp"], 2)
826-
return value
824+
if self._status is not None and any(
825+
key in self._status for key in ["voltage", "amp"]
826+
):
827+
return round(self._status["voltage"] * self._status["amp"], 2)
828+
return None
827829

828830
# There is currently no min/max amps JSON data
829831
# available via HTTP API methods

pylintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ max-attributes=15
1616
# too-few-* - same as too-many-*
1717
# import-outside-toplevel - TODO
1818
disable=
19-
bad-continuation,
2019
duplicate-code,
2120
fixme,
2221
import-outside-toplevel,
@@ -26,7 +25,6 @@ disable=
2625
too-many-public-methods,
2726
too-many-instance-attributes,
2827
too-many-branches,
29-
no-self-use,
3028
too-many-statements
3129

3230
[REPORTS]

0 commit comments

Comments
 (0)