Skip to content

Commit

Permalink
fix: fix failure to update all cars with update
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Apr 5, 2020
1 parent 92907ae commit 76df2f1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions teslajsonpy/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def valid_result(result):
result,
args,
kwargs,
instance._id_to_vin(car_id)[-5:],
instance._id_to_vin(car_id)[-5:] if car_id else None,
instance.car_online,
)
instance.car_online[instance._id_to_vin(car_id)] = False
Expand Down Expand Up @@ -628,6 +628,7 @@ def _calculate_next_interval(vin: int) -> int:
)
)
): # Only update cars with update flag on
_LOGGER.debug("Updating %s with state %s", vin[-5:], car_state)
try:
data = await self.get(
self.__vin_id_map[vin],
Expand Down Expand Up @@ -660,8 +661,13 @@ def _calculate_next_interval(vin: int) -> int:
update_succeeded = True
if (
self.enable_websocket
and self.get_drive_params(car_id).get("shift_state")
and self.get_drive_params(car_id).get("shift_state") != "P"
and self.get_drive_params(self.__vin_id_map[vin]).get(
"shift_state"
)
and self.get_drive_params(self.__vin_id_map[vin]).get(
"shift_state"
)
!= "P"
):
asyncio.create_task(
self.__connection.websocket_connect(
Expand All @@ -671,7 +677,11 @@ def _calculate_next_interval(vin: int) -> int:
on_disconnect=self._process_websocket_disconnect,
)
)
return update_succeeded
else:
_LOGGER.debug(
"Skipping update of %s with state %s", vin[-5:], car_state
)
return update_succeeded

def get_climate_params(self, car_id):
"""Return cached copy of climate_params for car_id."""
Expand Down

0 comments on commit 76df2f1

Please sign in to comment.