From 9436684214be96aeedc276e859ee70e57d8e560e Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 3 Apr 2021 00:26:04 -0700 Subject: [PATCH] fix: catch keyerror for missing seatwarmers #186 --- teslajsonpy/controller.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/teslajsonpy/controller.py b/teslajsonpy/controller.py index 42bd296e..77efcfbb 100644 --- a/teslajsonpy/controller.py +++ b/teslajsonpy/controller.py @@ -546,11 +546,11 @@ def _add_components(self, car): self.__components.append(TrunkLock(car, self)) self.__components.append(FrunkLock(car, self)) self.__components.append(UpdateSensor(car, self)) - self.__components.append(HeatedSeatSwitch(car, self, 'left')) - self.__components.append(HeatedSeatSwitch(car, self, 'right')) - self.__components.append(HeatedSeatSwitch(car, self, 'rear_left')) - self.__components.append(HeatedSeatSwitch(car, self, 'rear_center')) - self.__components.append(HeatedSeatSwitch(car, self, 'rear_right')) + for seat in ['left', 'right', 'rear_left', 'rear_center', 'rear_right']: + try: + self.__components.append(HeatedSeatSwitch(car, self, seat)) + except KeyError: + _LOGGER.debug("Seat warmer %s not detected", seat) async def _wake_up(self, car_id): car_vin = self._id_to_vin(car_id)