diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index 738fe363e6..a4791b4962 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -57,7 +57,7 @@ class UpdateConfig: - DATASTORE_VERSION = 105 + DATASTORE_VERSION = 106 valid_topic = [ "^openWB/bat/config/bat_control_permitted$", @@ -2679,3 +2679,13 @@ def upgrade(topic: str, payload) -> None: return {topic: config} self._loop_all_received_topics(upgrade) self._append_datastore_version(105) + + def upgrade_datastore_106(self) -> None: + def upgrade(topic: str, payload) -> None: + if re.search("openWB/vehicle/[0-9]+/soc_module/config", topic) is not None: + config = decode_payload(payload) + if config.get("type") == "http" or config.get("type") == "mqtt": + config["configuration"]["calculate_soc"] = False + return {topic: config} + self._loop_all_received_topics(upgrade) + self._append_datastore_version(106) diff --git a/packages/modules/vehicles/http/config.py b/packages/modules/vehicles/http/config.py index 8a78c77450..b176de91e4 100644 --- a/packages/modules/vehicles/http/config.py +++ b/packages/modules/vehicles/http/config.py @@ -3,9 +3,12 @@ @auto_str class HttpSocConfiguration: - def __init__(self, soc_url=None, range_url=None): + def __init__(self, soc_url=None, + range_url=None, + calculate_soc: bool = False): self.soc_url = soc_url self.range_url = range_url + self.calculate_soc = calculate_soc @auto_str diff --git a/packages/modules/vehicles/http/soc.py b/packages/modules/vehicles/http/soc.py index cbfea28ca2..a2788aaaba 100644 --- a/packages/modules/vehicles/http/soc.py +++ b/packages/modules/vehicles/http/soc.py @@ -35,7 +35,10 @@ def fetch_soc(config: HttpSocSetup) -> CarState: def create_vehicle(vehicle_config: HttpSocSetup, vehicle: int): def updater(vehicle_update_data: VehicleUpdateData) -> CarState: return fetch_soc(vehicle_config) - return ConfigurableVehicle(vehicle_config=vehicle_config, component_updater=updater, vehicle=vehicle) + return ConfigurableVehicle(vehicle_config=vehicle_config, + component_updater=updater, + vehicle=vehicle, + calc_while_charging=vehicle_config.configuration.calculate_soc) def http_update(soc_url: str, range_url: str, charge_point: int): diff --git a/packages/modules/vehicles/mqtt/config.py b/packages/modules/vehicles/mqtt/config.py index 8e9da39351..aa4d4bc1aa 100644 --- a/packages/modules/vehicles/mqtt/config.py +++ b/packages/modules/vehicles/mqtt/config.py @@ -1,6 +1,6 @@ class MqttSocConfiguration: - def __init__(self): - pass + def __init__(self, calculate_soc: bool = False): + self.calculate_soc = calculate_soc class MqttSocSetup: diff --git a/packages/modules/vehicles/mqtt/soc.py b/packages/modules/vehicles/mqtt/soc.py index 23be6ee2ba..b5b49524e6 100644 --- a/packages/modules/vehicles/mqtt/soc.py +++ b/packages/modules/vehicles/mqtt/soc.py @@ -37,7 +37,9 @@ def on_message(client, userdata, message): "Einstellungen beachten.") return None configurable_vehicle = ConfigurableVehicle(vehicle_config=vehicle_config, - component_updater=updater, vehicle=vehicle) + component_updater=updater, + vehicle=vehicle, + calc_while_charging=vehicle_config.configuration.calculate_soc) return configurable_vehicle