Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions openevsehttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,16 @@ def wifi_serial(self) -> str | None:
return self._config["wifi_serial"]
return None

@property
def charging_power(self) -> float:
"""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

# There is currently no min/max amps JSON data
# available via HTTP API methods
@property
Expand Down
2 changes: 1 addition & 1 deletion requirements_lint.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements.txt
black==22.1.0
black==22.3.0
flake8==4.0.1
mypy==0.941
pydocstyle==6.1.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

PROJECT_DIR = Path(__file__).parent.resolve()
README_FILE = PROJECT_DIR / "README.md"
VERSION = "0.1.21"
VERSION = "0.1.22"

setup(
name="python-openevse-http",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/v4_json/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"comm_success": 332432,
"rapi_connected": 1,
"evse_connected": 1,
"amp": 0,
"amp": 32.2,
"voltage": 240,
"pilot": 48,
"wh": 64582,
Expand Down
13 changes: 12 additions & 1 deletion tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async def test_get_wifi_signal(fixture, expected, request):


@pytest.mark.parametrize(
"fixture, expected", [("test_charger", 0), ("test_charger_v2", 0)]
"fixture, expected", [("test_charger", 32.2), ("test_charger_v2", 0)]
)
async def test_get_charging_current(fixture, expected, request):
"""Test v4 Status reply"""
Expand Down Expand Up @@ -664,3 +664,14 @@ async def test_set_current_v2(test_charger_v2, mock_aioclient, caplog):
with caplog.at_level(logging.DEBUG):
await test_charger_v2.set_current(12)
assert "Setting current via RAPI" in caplog.text


@pytest.mark.parametrize(
"fixture, expected", [("test_charger", 7728), ("test_charger_v2", 0)]
)
async def test_get_charging_power(fixture, expected, request):
"""Test v4 Status reply"""
charger = request.getfixturevalue(fixture)
await charger.update()
status = charger.charging_power
assert status == expected