Skip to content

Commit 73baabc

Browse files
committed
Added workaround for #11
1 parent f5fdf08 commit 73baabc

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ The `Vehicle` class extends `dict` and stores vehicle data returned by the API.
3333
| `get_vehicle_data()` | gets a rollup of all the data request endpoints plus vehicle config |
3434
| `get_nearby_charging_sites()` | lists nearby Tesla-operated charging stations |
3535
| `mobile_enabled()` | checks if mobile access is enabled in the vehicle |
36-
| `compose_image()` | composes a vehicle image based on vehicle option codes |
36+
| `compose_image()` <sup>2</sup> | composes a vehicle image based on vehicle option codes |
3737
| `dist_units()` | converts distance or speed units to GUI setting of the vehicle |
3838
| `temp_units()` | converts temperature units to GUI setting of the vehicle |
3939
| `decode_vin()` | decodes the vehicle identification number to a dict |
4040
| `remote_start_drive()` | enables keyless drive (requires password to be set) |
4141
| `command()` | wrapper around `api()` for vehicle command response error handling |
4242

4343
<sup>1</sup> Option codes appear to be deprecated. Vehicles return a generic set of codes related to a Model 3.
44+
<sup>2</sup> Pass vehicle option codes to this method or the image may not be accurate.
4445

4546
Only `get_vehicle_summary()`, `option_code_list()`, `compose_image()` and `decode_vin()` are available when the vehicle is asleep or offline. These methods will not prevent your vehicle from sleeping. Other methods and API calls require the vehicle to be brought online by using `sync_wake_up()` and can prevent your vehicle from sleeping if called with too short a period.
4647

teslapy/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,16 @@ def mobile_enabled(self):
435435
uri = 'api/1/vehicles/%s/mobile_enabled' % self['id_s']
436436
return self.tesla.get(uri)['response']
437437

438-
def compose_image(self, view='STUD_3QTR', size=640):
438+
def compose_image(self, view='STUD_3QTR', size=640, options=None):
439439
""" Returns a PNG formatted composed vehicle image. Valid views are:
440440
STUD_3QTR, STUD_SEAT, STUD_SIDE, STUD_REAR and STUD_WHEEL """
441-
# Derive model from VIN and other properties from option codes
442-
params = {'model': 'm' + self['vin'][3].lower(), 'bkba_opt': 1,
443-
'view': view, 'size': size, 'options': self['option_codes']}
441+
if options is None:
442+
msg = 'compose_image requires options for the image to be accurate'
443+
logger.warning(msg)
444+
# Derive model from VIN and other properties from (given) option codes
445+
params = {'model': 'm' + self['vin'][3].lower(),
446+
'bkba_opt': 1, 'view': view, 'size': size,
447+
'options': options or self['option_codes']}
444448
# Retrieve image from compositor
445449
url = 'https://static-assets.tesla.com/v1/compositor/'
446450
response = requests.get(url, params=params, verify=self.tesla.verify,

0 commit comments

Comments
 (0)