-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
From time to time Tesla-API servers return text/html instead of application/json.
Which results in a rather nasty Exception (Some information is obfuscated):
File "/home/....../tesla_api/__init__.py", line 154, in get
response_json = await resp.json()
File "/home/....../lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1026, in json
raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://owner-api.teslamotors.com/api/1/vehicles/21212121212121/data_request/charge_state')
raise ContentTypeError(
Handling this is the app seems too complicated, as this error could occur at any point the app code (and api call) and just generate a lot of copy & paste code for exception handling. Or a 2nd api layer around the lib just to handle those rare hick-ups.
The lib could retry to send the command for a defined number of times or raise a CommunicationError Exception of some sort.
Metadata
Metadata
Assignees
Labels
No labels