Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calc soc: fix missing value #1602

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/modules/common/configurable_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def update(self, vehicle_update_data: VehicleUpdateData):
car_state = self._get_carstate_by_source(vehicle_update_data, source)
log.debug(f"Requested start soc from {source.value}: {car_state.soc}%")

if source != SocSource.CALCULATION:
if (source != SocSource.CALCULATION or
(vehicle_update_data.imported and self.calculated_soc_state.imported_start is None)):
# Wenn nicht berechnet wurde, SoC als Start merken.
self.calculated_soc_state.imported_start = vehicle_update_data.imported
self.calculated_soc_state.soc_start = car_state.soc
Expand Down Expand Up @@ -108,11 +109,12 @@ def _get_carstate_by_source(self, vehicle_update_data, source):
if source == SocSource.API:
return self.__component_updater(vehicle_update_data)
elif source == SocSource.CALCULATION:
return CarState(soc=calc_soc.calc_soc(vehicle_update_data,
vehicle_update_data.efficiency,
self.calculated_soc_state.imported_start,
self.calculated_soc_state.soc_start,
vehicle_update_data.battery_capacity))
return CarState(soc=calc_soc.calc_soc(
vehicle_update_data,
vehicle_update_data.efficiency,
self.calculated_soc_state.imported_start or vehicle_update_data.imported,
self.calculated_soc_state.soc_start,
vehicle_update_data.battery_capacity))
elif source == SocSource.CP:
return CarState(vehicle_update_data.soc_from_cp)
elif source == SocSource.MANUAL:
Expand Down