Skip to content

Commit

Permalink
Don't break if vehicle has no status (#187)
Browse files Browse the repository at this point in the history
* Don't exit if vehicle has no status

* Update state.py

Co-authored-by: rikroe <rikroe@users.noreply.github.com>
  • Loading branch information
rikroe and rikroe committed Jun 21, 2020
1 parent 5ca622c commit cdfbce9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bimmer_connected/state.py
Expand Up @@ -125,12 +125,17 @@ def update_data(self) -> None:
'dlat': self._vehicle.observer_latitude,
'dlon': self._vehicle.observer_longitude,
}
response = self._account.send_request(
VEHICLE_STATUS_URL.format(server=self._account.server_url, vin=self._vehicle.vin), logfilename='status',
params=params)
attributes = response.json()['vehicleStatus']
# Pre-NBT vehicles don't seem to have a status that can be reported
try:
response = self._account.send_request(
VEHICLE_STATUS_URL.format(server=self._account.server_url, vin=self._vehicle.vin), logfilename='status',
params=params)
attributes = response.json()['vehicleStatus']
_LOGGER.debug('received new data from connected drive')
except OSError:
attributes = {}
_LOGGER.debug('Unable to retrieve vehicle status from connected drive (car too old)')
self._attributes = attributes
_LOGGER.debug('received new data from connected drive')

@property
@backend_parameter
Expand Down

0 comments on commit cdfbce9

Please sign in to comment.