diff --git a/openevsehttp/__main__.py b/openevsehttp/__main__.py index c030735..7839ada 100644 --- a/openevsehttp/__main__.py +++ b/openevsehttp/__main__.py @@ -388,21 +388,15 @@ async def set_current(self, amps: int = 6) -> None: amps = int(amps) if self._version_check("4.1.2"): - url = f"{self.url}config" - if ( amps < self._config["min_current_hard"] or amps > self._config["max_current_hard"] ): - _LOGGER.error("Invalid value for max_current_soft: %s", amps) + _LOGGER.error("Invalid value for current limit: %s", amps) raise ValueError - data = {"max_current_soft": amps} - - _LOGGER.debug("Setting max_current_soft to %s", amps) - response = await self.process_request( - url=url, method="post", data=data - ) # noqa: E501 + _LOGGER.debug("Setting current limit to %s", amps) + response = await self.set_override(charge_current=amps) _LOGGER.debug("Set current response: %s", response) else: diff --git a/setup.py b/setup.py index 773078c..226cda3 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ PROJECT_DIR = Path(__file__).parent.resolve() README_FILE = PROJECT_DIR / "README.md" -VERSION = "0.1.36" +VERSION = "0.1.37" setup( name="python-openevse-http", diff --git a/tests/test_main.py b/tests/test_main.py index 28a6048..7eb43db 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -699,29 +699,28 @@ async def test_wifi_serial(fixture, expected, request): async def test_set_current(test_charger, mock_aioclient, caplog): """Test v4 Status reply.""" await test_charger.update() - value = {"msg": "done"} mock_aioclient.post( - TEST_URL_CONFIG, + TEST_URL_OVERRIDE, status=200, - body=json.dumps(value), + body='{"msg": "OK"}', ) with caplog.at_level(logging.DEBUG): await test_charger.set_current(12) - assert "Setting max_current_soft to 12" in caplog.text + assert "Setting current limit to 12" in caplog.text async def test_set_current_error(test_charger, mock_aioclient, caplog): """Test v4 Status reply.""" await test_charger.update() mock_aioclient.post( - TEST_URL_CONFIG, + TEST_URL_OVERRIDE, status=200, - body="OK", + body='{"msg": "OK"}', ) with caplog.at_level(logging.DEBUG): with pytest.raises(ValueError): await test_charger.set_current(60) - assert "Invalid value for max_current_soft: 60" in caplog.text + assert "Invalid value for current limit: 60" in caplog.text async def test_set_current_v2( @@ -742,9 +741,9 @@ async def test_set_current_v2( await test_charger_dev.update() value = {"msg": "OK"} mock_aioclient.post( - TEST_URL_CONFIG, + TEST_URL_OVERRIDE, status=200, - body=json.dumps(value), + body='{"msg": "OK"}', ) with caplog.at_level(logging.DEBUG): await test_charger_dev.set_current(12)