Skip to content

Commit

Permalink
ScheduleExchangeRes parsing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Garry Blair committed Mar 26, 2024
1 parent 317071c commit 16012af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
10 changes: 5 additions & 5 deletions iso15118/evcc/states/iso15118_20_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ async def process_message(
service_discovery_res.service_renegotiation_supported
)

req_energy_services: List[
ServiceV20
] = await self.comm_session.ev_controller.get_supported_energy_services()
req_energy_services: List[ServiceV20] = (
await self.comm_session.ev_controller.get_supported_energy_services()
)

for energy_service in service_discovery_res.energy_service_list.services:
for requested_energy_service in req_energy_services:
Expand Down Expand Up @@ -854,8 +854,8 @@ async def process_message(
else:
bpt_channel_selection = ChannelSelection.CHARGE

await self.comm_session.ev_controller.enable_charging(True)
if self.comm_session.selected_charging_type_is_ac:
await self.comm_session.ev_controller.enable_charging(True)
power_delivery_req = PowerDeliveryReq(
header=MessageHeader(
session_id=self.comm_session.session_id,
Expand Down Expand Up @@ -1576,7 +1576,7 @@ async def build_power_delivery_req(self):
bpt_channel_selection = ChannelSelection.DISCHARGE
else:
bpt_channel_selection = ChannelSelection.CHARGE
await self.comm_session.ev_controller.enable_charging(True)

power_delivery_req = PowerDeliveryReq(
header=MessageHeader(
session_id=self.comm_session.session_id,
Expand Down
2 changes: 2 additions & 0 deletions iso15118/shared/comm_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ async def stop(self, reason: str):
evse_controller = self.comm_session.evse_controller
await evse_controller.update_data_link(terminate_or_pause)
await evse_controller.session_ended(str(self.current_state), reason)
elif hasattr(self.comm_session, "ev_controller"):
await self.comm_session.ev_controller.enable_charging(False)
logger.info(f"{terminate_or_pause}d the data link")
await asyncio.sleep(3)
try:
Expand Down
25 changes: 1 addition & 24 deletions iso15118/shared/messages/iso15118_20/common_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
(or class) that matches the definitions in the XSD schema, including the XSD
element names by using the 'alias' attribute.
"""

from dataclasses import dataclass
from enum import Enum
from typing import List, Tuple
Expand Down Expand Up @@ -821,30 +822,6 @@ def min_soc_less_than_or_equal_to_target_soc(cls, values):

return values

@root_validator(pre=True)
def either_price_levels_or_absolute_prices(cls, values):
"""
Either price_level_schedule or absolute_price_schedule must be set,
depending on abstract price levels or absolute prices are used to
indicate costs for the charging session.
Pydantic validators are "class methods",
see https://pydantic-docs.helpmanual.io/usage/validators/
"""
# pylint: disable=no-self-argument
# pylint: disable=no-self-use
if one_field_must_be_set(
[
"price_level_schedule",
"PriceLevelSchedule",
"absolute_price_schedule",
"AbsolutePriceSchedule",
],
values,
True,
):
return values


class ScheduleExchangeRes(V2GResponse):
"""See section 8.3.4.3.7.3 in ISO 15118-20"""
Expand Down

0 comments on commit 16012af

Please sign in to comment.