Skip to content

Commit 726fedb

Browse files
authored
feat: add state_raw property (#214)
* feat: add `state_raw` property * formatting * update tests * version bump
1 parent d35ab4d commit 726fedb

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

openevsehttp/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,12 @@ def state(self) -> str:
688688
assert self._status is not None
689689
return states[int(self._status["state"])]
690690

691+
@property
692+
def state_raw(self) -> int:
693+
"""Return charger's state int form."""
694+
assert self._status is not None
695+
return self._status["state"]
696+
691697
@property
692698
def charge_time_elapsed(self) -> int:
693699
"""Return elapsed charging time."""

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.47"
8+
VERSION = "0.1.48"
99

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

tests/test_main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,3 +1402,15 @@ async def test_websocket_functions(test_charger, mock_aioclient, caplog):
14021402
await test_charger.update()
14031403
test_charger.ws_start()
14041404
await test_charger.ws_disconnect()
1405+
1406+
1407+
@pytest.mark.parametrize(
1408+
"fixture, expected",
1409+
[("test_charger", 254), ("test_charger_v2", 1)],
1410+
)
1411+
async def test_get_state_raw(fixture, expected, request):
1412+
"""Test v4 Status reply."""
1413+
charger = request.getfixturevalue(fixture)
1414+
await charger.update()
1415+
status = charger.state_raw
1416+
assert status == expected

0 commit comments

Comments
 (0)