From dc9032aa2feaf60f7cb07859df3337bfb7eb57e7 Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Fri, 11 Jul 2025 14:16:57 +0200 Subject: [PATCH 1/2] fix manual soc: manual_soc=0% --- packages/modules/common/configurable_vehicle.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/modules/common/configurable_vehicle.py b/packages/modules/common/configurable_vehicle.py index 297d4832e5..6794961f9d 100644 --- a/packages/modules/common/configurable_vehicle.py +++ b/packages/modules/common/configurable_vehicle.py @@ -83,7 +83,7 @@ def update(self, vehicle_update_data: VehicleUpdateData): self.calculated_soc_state.soc_start = car_state.soc Pub().pub(f"openWB/set/vehicle/{self.vehicle}/soc_module/calculated_soc_state", asdict(self.calculated_soc_state)) - if vehicle_update_data.soc_timestamp is None or vehicle_update_data.soc_timestamp < car_state.soc_timestamp: + if vehicle_update_data.soc_timestamp is None or vehicle_update_data.soc_timestamp <= car_state.soc_timestamp: # Nur wenn der SoC neuer ist als der bisherige, diesen setzen. self.store.set(car_state) elif vehicle_update_data.soc_timestamp > 1e10: @@ -99,7 +99,7 @@ def _get_carstate_source(self, vehicle_update_data: VehicleUpdateData) -> SocSou self.calculated_soc_state.manual_soc): if isinstance(self.vehicle_config, ManualSoc): # Wenn ein manueller SoC gesetzt wurde, diesen als neuen Start merken. - if self.calculated_soc_state.manual_soc or self.calculated_soc_state.imported_start is None: + if self.calculated_soc_state.manual_soc is not None or self.calculated_soc_state.imported_start is None: return SocSource.MANUAL else: if vehicle_update_data.plug_state: @@ -134,7 +134,10 @@ def _get_carstate_by_source(self, vehicle_update_data: VehicleUpdateData, source return CarState(soc=vehicle_update_data.soc_from_cp, soc_timestamp=vehicle_update_data.timestamp_soc_from_cp) elif source == SocSource.MANUAL: - soc = self.calculated_soc_state.manual_soc or self.calculated_soc_state.soc_start + if self.calculated_soc_state.manual_soc is not None: + soc = self.calculated_soc_state.manual_soc + else: + self.calculated_soc_state.soc_start self.calculated_soc_state.manual_soc = None return CarState(soc) From 88be508b6d28f938d9cd1c91087bf7c83ab43361 Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Fri, 11 Jul 2025 14:20:32 +0200 Subject: [PATCH 2/2] flake8 --- packages/modules/common/configurable_vehicle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/modules/common/configurable_vehicle.py b/packages/modules/common/configurable_vehicle.py index 6794961f9d..53ee878cd9 100644 --- a/packages/modules/common/configurable_vehicle.py +++ b/packages/modules/common/configurable_vehicle.py @@ -83,7 +83,8 @@ def update(self, vehicle_update_data: VehicleUpdateData): self.calculated_soc_state.soc_start = car_state.soc Pub().pub(f"openWB/set/vehicle/{self.vehicle}/soc_module/calculated_soc_state", asdict(self.calculated_soc_state)) - if vehicle_update_data.soc_timestamp is None or vehicle_update_data.soc_timestamp <= car_state.soc_timestamp: + if (vehicle_update_data.soc_timestamp is None or + vehicle_update_data.soc_timestamp <= car_state.soc_timestamp): # Nur wenn der SoC neuer ist als der bisherige, diesen setzen. self.store.set(car_state) elif vehicle_update_data.soc_timestamp > 1e10: