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

MercedesEQ SoC #1084

Merged
merged 35 commits into from
Aug 9, 2023
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5eaa56a
First try Mercedes Soc
DetMoerk Dec 29, 2022
02b477c
Update .gitignore
DetMoerk Dec 29, 2022
e465d66
Delete soc_eq_acc_ev8
DetMoerk Dec 29, 2022
72f1325
Update auth.py
DetMoerk Jan 2, 2023
c2acea9
SocEQ Remove loginURL
DetMoerk Feb 15, 2023
d407754
SocMercedesEQ Cleanup Code
DetMoerk Feb 15, 2023
0d7b163
Cleanup1
DetMoerk Feb 15, 2023
f91382d
Cleanup2
DetMoerk Feb 15, 2023
eba3c85
cleanup3
DetMoerk Feb 15, 2023
dfa439d
Delete callback_lp.php
DetMoerk Feb 15, 2023
4079ac9
cleanup4
DetMoerk Feb 15, 2023
6a8440f
cleanup5
DetMoerk Feb 15, 2023
a9566a4
cleanup5
DetMoerk Feb 15, 2023
ca6abb3
cleanup6
DetMoerk Feb 15, 2023
f006fbc
cleanup7
DetMoerk Feb 15, 2023
e0c83bd
cleanup8
DetMoerk Feb 15, 2023
e024a72
reworked comments
DetMoerk Feb 16, 2023
e18d62d
remove mercedeseq directory from gitignore
DetMoerk Feb 16, 2023
20c2712
cleanup flake8
DetMoerk Feb 16, 2023
b67e3b3
rework comments in auth.py
DetMoerk Feb 16, 2023
5263b55
flake8 rework
DetMoerk Feb 16, 2023
6a5830d
fix to use modules.common.req in auth.py
DetMoerk Feb 17, 2023
c768215
cleanup
DetMoerk Feb 17, 2023
8529920
fix auth.py
DetMoerk Feb 17, 2023
348c43d
Disable Flake8 check for special case
DetMoerk Feb 24, 2023
a37cd26
callback_ev.php sec fix
DetMoerk Mar 1, 2023
a08c953
Cleanup from reviews
DetMoerk Mar 2, 2023
9642e2c
cleanup
benderl Mar 3, 2023
530cc0d
fix import path
benderl Mar 3, 2023
5564be9
clean token default configuration
benderl Mar 7, 2023
8c6aaa7
Bugfixing None Type
DetMoerk Mar 15, 2023
bdf31b9
fix module import
benderl Apr 4, 2023
f6d5cf4
Cleanup MercedesEQ Soc
DetMoerk Aug 7, 2023
e2f91af
Merge branch 'openWB:master' into mercedesEQ-Soc
DetMoerk Aug 7, 2023
54bd958
Merge branch 'feature-mercedeseq' into mercedesEQ-Soc
DetMoerk Aug 8, 2023
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
38 changes: 12 additions & 26 deletions packages/modules/vehicles/mercedeseq/soc.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
from typing import Union
import logging
from dataclass_utils import dataclass_from_dict
from modules.common import store
from modules.common.abstract_device import DeviceDescriptor
from modules.common.abstract_soc import AbstractSoc
from modules.common.component_context import SingleComponentUpdateContext
from modules.common.abstract_soc import SocUpdateData
from modules.common.configurable_vehicle import ConfigurableVehicle
from modules.common.component_state import CarState
from modules.common.fault_state import ComponentInfo

from modules.vehicles.mercedeseq.config import MercedesEQSoc
import modules.vehicles.mercedeseq.api as api


log = logging.getLogger("soc."+__name__)


class Soc(AbstractSoc):
def __init__(self, device_config: Union[dict, MercedesEQSoc], vehicle: int):
self.config = dataclass_from_dict(MercedesEQSoc, device_config)
self.vehicle = vehicle
self.store = store.get_car_value_store(self.vehicle)
self.component_info = ComponentInfo(self.vehicle, self.config.name, "vehicle")

def update(self, charge_state: bool = False) -> None:
# # if self.config.configuration.code == None and self.config.configuration.token.access_token == None:
# if self.config.configuration.token.access_token == None:
# # error: "Bitte Link in der Konfiguration anklicken" triggert Aufruf der Callback-URL
# pass
# # elif self.config.configuration.code != None and self.config.configuration.token.access_token == None:
# # auth.py um Token abzuholen

# else:
with SingleComponentUpdateContext(self.component_info):
soc, range = api.fetch_soc(self.config, self.vehicle)
# log.info("eq: vehicle="+str(self.vehicle) + ", return: soc=" + str(soc)+", range=" + str(range))
self.store.set(CarState(soc, range))
def fetch(vehicle_config: MercedesEQSoc, soc_update_data: SocUpdateData, vehicle) -> CarState:
soc, range = api.fetch_soc(vehicle_config, vehicle)
return CarState(soc, range)


def create_vehicle(vehicle_config: MercedesEQSoc, vehicle: int):
def updater(soc_update_data: SocUpdateData) -> CarState:
return fetch(vehicle_config, soc_update_data, vehicle)
return ConfigurableVehicle(vehicle_config=vehicle_config, component_updater=updater, vehicle=vehicle)


device_descriptor = DeviceDescriptor(configuration_factory=MercedesEQSoc)