Skip to content

Commit 2601fe8

Browse files
authored
feat: add max_current property (#380)
* feat: add `max_current` property * linting * add test
1 parent 5bbbc3f commit 2601fe8

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

openevsehttp/__main__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,11 +895,18 @@ def openevse_firmware(self) -> str:
895895

896896
@property
897897
def max_current_soft(self) -> int | None:
898-
"""Return the firmware version."""
898+
"""Return the max current soft."""
899899
if self._config is not None and "max_current_soft" in self._config:
900900
return self._config["max_current_soft"]
901901
return self._status["pilot"]
902902

903+
@property
904+
def max_current(self) -> int | None:
905+
"""Return the max current."""
906+
if self._status is not None and "max_current" in self._status:
907+
return self._status["max_current"]
908+
return None
909+
903910
@property
904911
def wifi_firmware(self) -> str:
905912
"""Return the ESP firmware version."""

pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ disable=
2626
too-many-instance-attributes,
2727
too-many-branches,
2828
too-many-statements,
29-
too-many-lines
29+
too-many-lines,
30+
too-many-positional-arguments
3031

3132
[REPORTS]
3233
score=no

tests/fixtures/v4_json/status-new.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
"total_week": 12345,
5656
"total_month": 123456,
5757
"total_year": 1234567,
58-
"total_energy": 12345678
58+
"total_energy": 12345678,
59+
"max_current": 48
5960
}

tests/test_main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,3 +1752,14 @@ async def test_make_claim(test_charger, test_charger_v2, mock_aioclient, caplog)
17521752
with caplog.at_level(logging.DEBUG):
17531753
await test_charger_v2.make_claim()
17541754
assert "Feature not supported for older firmware." in caplog.text
1755+
1756+
1757+
@pytest.mark.parametrize(
1758+
"fixture, expected", [("test_charger_new", 48), ("test_charger_v2", None)]
1759+
)
1760+
async def test_max_current(fixture, expected, request):
1761+
"""Test max_current reply."""
1762+
charger = request.getfixturevalue(fixture)
1763+
await charger.update()
1764+
status = charger.max_current
1765+
assert status == expected

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ python =
88
3.11: py311
99
3.12: py312, lint, mypy
1010

11+
[pytest]
12+
asyncio_default_fixture_loop_scope=function
13+
1114
[testenv]
1215
commands =
1316
pytest --timeout=30 --cov=openevsehttp --cov-report=xml {posargs}

0 commit comments

Comments
 (0)