@@ -83,7 +83,8 @@ def update(self, vehicle_update_data: VehicleUpdateData):
8383 self .calculated_soc_state .soc_start = car_state .soc
8484 Pub ().pub (f"openWB/set/vehicle/{ self .vehicle } /soc_module/calculated_soc_state" ,
8585 asdict (self .calculated_soc_state ))
86- if vehicle_update_data .soc_timestamp is None or vehicle_update_data .soc_timestamp < car_state .soc_timestamp :
86+ if (vehicle_update_data .soc_timestamp is None or
87+ vehicle_update_data .soc_timestamp <= car_state .soc_timestamp ):
8788 # Nur wenn der SoC neuer ist als der bisherige, diesen setzen.
8889 self .store .set (car_state )
8990 elif vehicle_update_data .soc_timestamp > 1e10 :
@@ -99,7 +100,7 @@ def _get_carstate_source(self, vehicle_update_data: VehicleUpdateData) -> SocSou
99100 self .calculated_soc_state .manual_soc ):
100101 if isinstance (self .vehicle_config , ManualSoc ):
101102 # Wenn ein manueller SoC gesetzt wurde, diesen als neuen Start merken.
102- if self .calculated_soc_state .manual_soc or self .calculated_soc_state .imported_start is None :
103+ if self .calculated_soc_state .manual_soc is not None or self .calculated_soc_state .imported_start is None :
103104 return SocSource .MANUAL
104105 else :
105106 if vehicle_update_data .plug_state :
@@ -134,7 +135,10 @@ def _get_carstate_by_source(self, vehicle_update_data: VehicleUpdateData, source
134135 return CarState (soc = vehicle_update_data .soc_from_cp ,
135136 soc_timestamp = vehicle_update_data .timestamp_soc_from_cp )
136137 elif source == SocSource .MANUAL :
137- soc = self .calculated_soc_state .manual_soc or self .calculated_soc_state .soc_start
138+ if self .calculated_soc_state .manual_soc is not None :
139+ soc = self .calculated_soc_state .manual_soc
140+ else :
141+ self .calculated_soc_state .soc_start
138142 self .calculated_soc_state .manual_soc = None
139143 return CarState (soc )
140144
0 commit comments