Skip to content

Commit 9c131ac

Browse files
committed
add missing doors and windows to images when there is no access status
1 parent c345de7 commit 9c131ac

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

weconnect/elements/vehicle.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,15 @@ def updateStatusPicture(self) -> None: # noqa: C901
412412

413413
badges: Set[Vehicle.Badge] = set()
414414

415+
doorNameMap: Dict[str, str] = {'frontLeft': 'door_left_front',
416+
'frontRight': 'door_right_front',
417+
'rearLeft': 'door_left_back',
418+
'rearRight': 'door_right_back'}
419+
windowNameMap: Dict[str, str] = {'frontLeft': 'window_left_front',
420+
'frontRight': 'window_right_front',
421+
'rearLeft': 'window_left_back',
422+
'rearRight': 'window_right_back',
423+
'sunRoof': 'sunroof'}
415424
if 'access' in self.domains and 'accessStatus' in self.domains['access']:
416425
accessStatus: AccessStatus = cast(AccessStatus, self.domains['access']['accessStatus'])
417426

@@ -424,10 +433,6 @@ def updateStatusPicture(self) -> None: # noqa: C901
424433
badges.add(Vehicle.Badge.WARNING)
425434

426435
for name, door in accessStatus.doors.items():
427-
doorNameMap: Dict[str, str] = {'frontLeft': 'door_left_front',
428-
'frontRight': 'door_right_front',
429-
'rearLeft': 'door_left_back',
430-
'rearRight': 'door_right_back'}
431436
name = doorNameMap.get(name, name)
432437
doorImageName: Optional[str] = None
433438

@@ -444,11 +449,6 @@ def updateStatusPicture(self) -> None: # noqa: C901
444449
img.paste(doorImage, (0, 0), doorImage)
445450

446451
for name, window in accessStatus.windows.items():
447-
windowNameMap: Dict[str, str] = {'frontLeft': 'window_left_front',
448-
'frontRight': 'window_right_front',
449-
'rearLeft': 'window_left_back',
450-
'rearRight': 'window_right_back',
451-
'sunRoof': 'sunroof'}
452452
name = windowNameMap.get(name, name)
453453
windowImageName: Optional[str] = None
454454

@@ -463,6 +463,15 @@ def updateStatusPicture(self) -> None: # noqa: C901
463463
if windowImageName is not None and windowImageName in self.__carImages:
464464
windowImage = self.__carImages[windowImageName].convert("RGBA")
465465
img.paste(windowImage, (0, 0), windowImage)
466+
else:
467+
for name in doorNameMap.values():
468+
if name in self.__carImages:
469+
doorImage = self.__carImages[name].convert("RGBA")
470+
img.paste(doorImage, (0, 0), doorImage)
471+
for name in windowNameMap.values():
472+
if name != 'sunroof' and name in self.__carImages:
473+
windowImage = self.__carImages[name].convert("RGBA")
474+
img.paste(windowImage, (0, 0), windowImage)
466475

467476
if 'vehicleLights' in self.domains and 'lightsStatus' in self.domains['vehicleLights']:
468477
lightsStatus: LightsStatus = cast(LightsStatus, self.domains['vehicleLights']['lightsStatus'])

0 commit comments

Comments
 (0)