diff --git a/openevsehttp/__init__.py b/openevsehttp/__init__.py index 8d3f2f3..4afd20e 100644 --- a/openevsehttp/__init__.py +++ b/openevsehttp/__init__.py @@ -446,7 +446,10 @@ async def set_current(self, amps: int = 6) -> None: """Set the soft current limit.""" url = f"{self.url}config" - if amps < self._config["min_current_hard"] or amps > self._config["max_current_hard"]: + if ( + amps < self._config["min_current_hard"] + or amps > self._config["max_current_hard"] + ): _LOGGER.error("Invalid value for max_current_soft: %s", amps) raise ValueError @@ -458,8 +461,7 @@ async def set_current(self, amps: int = 6) -> None: ) # noqa: E501 if response["msg"] != "done": _LOGGER.error("Problem issuing command: %s", response["msg"]) - raise UnknownError - + raise UnknownError @property def hostname(self) -> str: @@ -746,7 +748,7 @@ def divert_active(self) -> bool: return self._status["divert_active"] @property - def wifi_serial(self) -> str: + def wifi_serial(self) -> str | None: """Return wifi serial.""" if self._config is not None and "wifi_serial" in self._config: return self._config["wifi_serial"] diff --git a/tests/test_init.py b/tests/test_init.py index 7fd380c..ac06cb9 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -612,6 +612,7 @@ async def test_toggle_override_v2(test_charger_v2, mock_aioclient, caplog): await test_charger_v2.toggle_override() assert "Toggling manual override via RAPI" in caplog.text + @pytest.mark.parametrize( "fixture, expected", [("test_charger", "1234567890AB"), ("test_charger_v2", None)] ) @@ -622,6 +623,7 @@ async def test_wifi_serial(fixture, expected, request): status = charger.wifi_serial assert status == expected + async def test_set_current(test_charger, mock_aioclient, caplog): """Test v4 Status reply""" await test_charger.update() @@ -633,7 +635,8 @@ async def test_set_current(test_charger, mock_aioclient, caplog): ) with caplog.at_level(logging.DEBUG): await test_charger.set_current(12) - assert "Setting max_current_soft to 12" in caplog.text + assert "Setting max_current_soft to 12" in caplog.text + async def test_set_current_error(test_charger, mock_aioclient, caplog): """Test v4 Status reply""" @@ -646,4 +649,4 @@ async def test_set_current_error(test_charger, mock_aioclient, caplog): 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 \ No newline at end of file + assert "Invalid value for max_current_soft: 60" in caplog.text