Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

class UpdateConfig:

DATASTORE_VERSION = 105
DATASTORE_VERSION = 106

valid_topic = [
"^openWB/bat/config/bat_control_permitted$",
Expand Down Expand Up @@ -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)
5 changes: 4 additions & 1 deletion packages/modules/vehicles/http/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion packages/modules/vehicles/http/soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/vehicles/mqtt/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class MqttSocConfiguration:
def __init__(self):
pass
def __init__(self, calculate_soc: bool = False):
self.calculate_soc = calculate_soc


class MqttSocSetup:
Expand Down
4 changes: 3 additions & 1 deletion packages/modules/vehicles/mqtt/soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down