From ad335dc8d24776069214f5e3f203aa5888e26847 Mon Sep 17 00:00:00 2001 From: tropxy Date: Wed, 31 Jan 2024 09:45:57 +0000 Subject: [PATCH 1/2] added fix to evse_max_voltage --- iso15118/secc/controller/interface.py | 5 ++++- poetry.lock | 10 ++++----- tests/shared/messages/test_interface.py | 27 +++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/iso15118/secc/controller/interface.py b/iso15118/secc/controller/interface.py index 548764ad..08ab6498 100644 --- a/iso15118/secc/controller/interface.py +++ b/iso15118/secc/controller/interface.py @@ -786,7 +786,10 @@ async def get_evse_max_voltage_limit(self) -> PVEVSEMaxVoltageLimit: - ISO 15118-2 """ session_limits = self.evse_data_context.session_limits - voltage_limit = session_limits.dc_limits.max_voltage + if self.evse_data_context.current_type == CurrentType.AC: + voltage_limit = self.evse_data_context.nominal_voltage + else: + voltage_limit = session_limits.dc_limits.max_voltage exponent, value = PhysicalValue.get_exponent_value_repr(voltage_limit) return PVEVSEMaxVoltageLimit( multiplier=exponent, diff --git a/poetry.lock b/poetry.lock index bbc19a5d..bfb6fe59 100644 --- a/poetry.lock +++ b/poetry.lock @@ -502,18 +502,18 @@ files = [ [[package]] name = "platformdirs" -version = "4.1.0" +version = "4.2.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." optional = false python-versions = ">=3.8" files = [ - {file = "platformdirs-4.1.0-py3-none-any.whl", hash = "sha256:11c8f37bcca40db96d8144522d925583bdb7a31f7b0e37e3ed4318400a8e2380"}, - {file = "platformdirs-4.1.0.tar.gz", hash = "sha256:906d548203468492d432bcb294d4bc2fff751bf84971fbb2c10918cc206ee420"}, + {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, + {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, ] [package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] +docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] [[package]] name = "pluggy" diff --git a/tests/shared/messages/test_interface.py b/tests/shared/messages/test_interface.py index e64ed2da..1ee175de 100644 --- a/tests/shared/messages/test_interface.py +++ b/tests/shared/messages/test_interface.py @@ -11,6 +11,7 @@ from iso15118.shared.messages.datatypes import ( PVEVSEMaxCurrent, PVEVSEMaxCurrentLimit, + PVEVSEMaxVoltageLimit, UnitSymbol, ) @@ -207,3 +208,29 @@ async def test_get_evse_present_and_nominal_voltage_are_0( limit = await evse_controller_interface.get_evse_max_current_limit() assert isinstance(limit, PVEVSEMaxCurrent) assert limit == expected_limit + + async def test_get_evse_max_voltage_limit_ac(self, evse_controller_interface): + evse_controller_interface.evse_data_context.current_type = CurrentType.AC + evse_controller_interface.evse_data_context.nominal_voltage = 230 + expected_limit = PVEVSEMaxVoltageLimit( + multiplier=0, + value=230, + unit=UnitSymbol.VOLTAGE, + ) + limit = await evse_controller_interface.get_evse_max_voltage_limit() + assert isinstance(limit, PVEVSEMaxVoltageLimit) + assert limit == expected_limit + + async def test_get_evse_max_voltage_limit_dc(self, evse_controller_interface): + evse_controller_interface.evse_data_context.current_type = CurrentType.DC + evse_controller_interface.evse_data_context.session_limits.dc_limits.max_voltage = ( + 1000 + ) + expected_limit = PVEVSEMaxVoltageLimit( + multiplier=0, + value=1000, + unit=UnitSymbol.VOLTAGE, + ) + limit = await evse_controller_interface.get_evse_max_voltage_limit() + assert isinstance(limit, PVEVSEMaxVoltageLimit) + assert limit == expected_limit From ee210c21b65b3e2bb5866bd50d3281a315313795 Mon Sep 17 00:00:00 2001 From: tropxy Date: Wed, 31 Jan 2024 09:50:16 +0000 Subject: [PATCH 2/2] fix line too long --- tests/shared/messages/test_interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shared/messages/test_interface.py b/tests/shared/messages/test_interface.py index 1ee175de..5607f4b0 100644 --- a/tests/shared/messages/test_interface.py +++ b/tests/shared/messages/test_interface.py @@ -223,7 +223,7 @@ async def test_get_evse_max_voltage_limit_ac(self, evse_controller_interface): async def test_get_evse_max_voltage_limit_dc(self, evse_controller_interface): evse_controller_interface.evse_data_context.current_type = CurrentType.DC - evse_controller_interface.evse_data_context.session_limits.dc_limits.max_voltage = ( + evse_controller_interface.evse_data_context.session_limits.dc_limits.max_voltage = ( # noqa: E501 1000 ) expected_limit = PVEVSEMaxVoltageLimit(