Skip to content

Commit 8df15fa

Browse files
authored
feat: add charge_mode property (#204)
* feat: add charge_mode property * formatting
1 parent dbe2a77 commit 8df15fa

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

openevsehttp/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,12 @@ def divertmode(self) -> str:
788788
return "normal"
789789
return "eco"
790790

791+
@property
792+
def charge_mode(self) -> str:
793+
"""Return the charge mode."""
794+
assert self._config is not None
795+
return self._config["charge_mode"]
796+
791797
@property
792798
def available_current(self) -> float:
793799
"""Return the computed available current for divert."""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
PROJECT_DIR = Path(__file__).parent.resolve()
77
README_FILE = PROJECT_DIR / "README.md"
8-
VERSION = "0.1.42"
8+
VERSION = "0.1.43"
99

1010
setup(
1111
name="python-openevse-http",

tests/test_main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,3 +1256,14 @@ async def test_set_charge_mode(test_charger, mock_aioclient, caplog):
12561256
)
12571257
with pytest.raises(ValueError):
12581258
await test_charger.set_charge_mode("test")
1259+
1260+
1261+
@pytest.mark.parametrize(
1262+
"fixture, expected", [("test_charger", "fast"), ("test_charger_v2", "fast")]
1263+
)
1264+
async def test_charge_mode(fixture, expected, request):
1265+
"""Test vehicle_range reply."""
1266+
charger = request.getfixturevalue(fixture)
1267+
await charger.update()
1268+
status = charger.charge_mode
1269+
assert status == expected

0 commit comments

Comments
 (0)