From 23c45dc5938563ebd7761bebe7f8fa0e96903f6d Mon Sep 17 00:00:00 2001 From: "firstof9@gmail.com" Date: Sat, 16 May 2026 14:27:39 -0700 Subject: [PATCH 1/2] Bump version to 0.3.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 50d0843..3e598b5 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ PROJECT_DIR = Path(__file__).parent.resolve() README_FILE = PROJECT_DIR / "README.md" -VERSION = "0.3.2" +VERSION = "0.3.3" setup( name="python_openevse_http", From de6187ba031af46012ffa5ea084151e2a06a083d Mon Sep 17 00:00:00 2001 From: "firstof9@gmail.com" Date: Sat, 16 May 2026 14:32:46 -0700 Subject: [PATCH 2/2] fix: update shaper command API parameters and add status tracking --- openevsehttp/client.py | 2 +- openevsehttp/commands.py | 8 ++++++-- tests/test_shaper.py | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/openevsehttp/client.py b/openevsehttp/client.py index df95781..9901293 100644 --- a/openevsehttp/client.py +++ b/openevsehttp/client.py @@ -139,7 +139,7 @@ async def _process_request_with_session( try: message = json.loads(message) except ValueError: - _LOGGER.warning("Non JSON response: %s", message) + _LOGGER.debug("Non JSON response: %s", message) if resp.status == 400: if isinstance(message, dict) and "msg" in message: diff --git a/openevsehttp/commands.py b/openevsehttp/commands.py index 650fcd8..4ff0e65 100644 --- a/openevsehttp/commands.py +++ b/openevsehttp/commands.py @@ -492,6 +492,8 @@ async def set_divert_mode(self, mode: str = "fast") -> None: _LOGGER.error("Problem issuing command: %s", response) raise UnknownError + self._status["divertmode"] = new_mode + async def set_shaper(self, enable: bool = True) -> None: """Set shaper mode.""" if not self._version_check("4.0.0"): @@ -500,16 +502,18 @@ async def set_shaper(self, enable: bool = True) -> None: url = f"{self.url}shaper" mode = 1 if enable else 0 - data = {"mode": mode} + data = {"shaper": mode} _LOGGER.debug("Setting shaper to %s", mode) - response = await self.process_request(url=url, method="post", data=data) + response = await self.process_request(url=url, method="post", rapi=data) response = self._normalize_response(response) msg = response.get("msg") if isinstance(response, Mapping) else None if msg not in ["OK", "done", "no change", "Current Shaper state changed"]: _LOGGER.error("Problem issuing command: %s", response) raise UnknownError + self._status["shaper"] = mode + async def toggle_shaper(self) -> None: """Toggle shaper mode.""" shaper_active = self._status.get("shaper") diff --git a/tests/test_shaper.py b/tests/test_shaper.py index 5591777..9db469e 100644 --- a/tests/test_shaper.py +++ b/tests/test_shaper.py @@ -46,6 +46,33 @@ async def test_set_shaper_fail(test_charger, mock_aioclient, caplog): await test_charger.set_shaper(True) +async def test_set_shaper_non_json(test_charger, mock_aioclient, caplog): + """Test set_shaper with a non-JSON response.""" + await test_charger.update() + test_charger._status["shaper"] = 0 + + mock_aioclient.post( + TEST_URL_SHAPER, + status=200, + body="Current Shaper state changed", + ) + with caplog.at_level(logging.DEBUG): + await test_charger.set_shaper(True) + assert "Setting shaper to 1" in caplog.text + assert test_charger.shaper_active == 1 + + test_charger._status["shaper"] = 1 + mock_aioclient.post( + TEST_URL_SHAPER, + status=200, + body="Current Shaper state changed", + ) + with caplog.at_level(logging.DEBUG): + await test_charger.set_shaper(False) + assert "Setting shaper to 0" in caplog.text + assert test_charger.shaper_active == 0 + + async def test_toggle_shaper(test_charger, mock_aioclient, caplog): """Test toggle_shaper command.""" await test_charger.update()