Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Jan 2, 2025
1 parent e825a43 commit d2a8301
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def __str__(self) -> str:

class Service(Enum):
MY_SKODA = 'MySkoda'
MY_SKODA2 = 'MySkoda2'

def __str__(self) -> str:
return self.value
Expand Down
12 changes: 7 additions & 5 deletions src/carconnectivity_connectors/skoda/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def fetch_vehicles(self) -> None:
garage: Garage = self.car_connectivity.garage
url = 'https://mysmob.api.connect.skoda-auto.cz/api/v2/garage'
data: Dict[str, Any] | None = self._fetch_data(url, session=self._session)
print(data)
seen_vehicle_vins: set[str] = set()
if data is not None:
if 'vehicles' in data and data['vehicles'] is not None:
Expand Down Expand Up @@ -231,7 +230,6 @@ def fetch_vehicle_status(self, vehicle: SkodaVehicle) -> None:
url = f'https://mysmob.api.connect.skoda-auto.cz/api/v2/garage/vehicles/{vin}?' \
'connectivityGenerations=MOD1&connectivityGenerations=MOD2&connectivityGenerations=MOD3&connectivityGenerations=MOD4'
vehicle_data: Dict[str, Any] | None = self._fetch_data(url, self._session)
print(vehicle_data)
if vehicle_data:
if 'softwareVersion' in vehicle_data and vehicle_data['softwareVersion'] is not None:
vehicle.software.version._set_value(vehicle_data['softwareVersion']) # pylint: disable=protected-access
Expand Down Expand Up @@ -270,7 +268,6 @@ def fetch_vehicle_status(self, vehicle: SkodaVehicle) -> None:

url = f'https://mysmob.api.connect.skoda-auto.cz/api/v2/vehicle-status/{vin}/driving-range'
range_data: Dict[str, Any] | None = self._fetch_data(url, self._session)
print(range_data)
if range_data:
captured_at: datetime = robust_time_parse(range_data['carCapturedTimestamp'])
# Check vehicle type and if it does not match the current vehicle type, create a new vehicle object using copy constructor
Expand Down Expand Up @@ -334,6 +331,10 @@ def fetch_vehicle_status(self, vehicle: SkodaVehicle) -> None:
and range_data[f'{drive_id}EngineRange']['currentSoCInPercent'] is not None:
# pylint: disable-next=protected-access
drive.level._set_value(value=range_data[f'{drive_id}EngineRange']['currentSoCInPercent'], measured=captured_at)
elif 'currentFuelLevelInPercent' in range_data[f'{drive_id}EngineRange'] \
and range_data[f'{drive_id}EngineRange']['currentFuelLevelInPercent'] is not None:
# pylint: disable-next=protected-access
drive.level._set_value(value=range_data[f'{drive_id}EngineRange']['currentFuelLevelInPercent'], measured=captured_at)
else:
drive.level._set_value(None, measured=captured_at) # pylint: disable=protected-access
if 'remainingRangeInKm' in range_data[f'{drive_id}EngineRange'] and range_data[f'{drive_id}EngineRange']['remainingRangeInKm'] is not None:
Expand All @@ -342,7 +343,9 @@ def fetch_vehicle_status(self, vehicle: SkodaVehicle) -> None:
else:
drive.range._set_value(None, measured=captured_at, unit=Length.KM) # pylint: disable=protected-access

log_extra_keys(LOG_API, f'{drive_id}EngineRange', range_data, {'engineType', 'currentSoCInPercent', 'remainingRangeInKm'})
log_extra_keys(LOG_API, f'{drive_id}EngineRange', range_data[f'{drive_id}EngineRange'], {'engineType',
'currentSoCInPercent',
'remainingRangeInKm'})
log_extra_keys(LOG_API, '/api/v2/vehicle-status/{vin}/driving-range', range_data, {'carCapturedTimestamp',
'carType',
'totalRangeInKm',
Expand All @@ -351,7 +354,6 @@ def fetch_vehicle_status(self, vehicle: SkodaVehicle) -> None:

url = f'https://api.connect.skoda-auto.cz/api/v2/vehicle-status/{vin}'
vehicle_status_data: Dict[str, Any] | None = self._fetch_data(url, self._session)
print(vehicle_status_data)
if vehicle_status_data:
if 'remote' in vehicle_status_data and vehicle_status_data['remote'] is not None:
vehicle_status_data = vehicle_status_data['remote']
Expand Down

0 comments on commit d2a8301

Please sign in to comment.