* Catch Volvo API not returning a valid json string #104

* Update changelog
This commit is contained in:
Linus Dietz
2023-09-21 14:31:21 +02:00
committed by GitHub
parent 6b419cfe3a
commit 781e1da8e8
4 changed files with 18 additions and 7 deletions
+6 -1
View File
@@ -8,6 +8,7 @@ from threading import currentThread
from datetime import datetime, timedelta
from config import settings
from babel.dates import format_datetime
from json import JSONDecodeError
from const import charging_system_states, charging_connection_states, door_states, window_states, \
OAUTH_URL, VEHICLES_URL, VEHICLE_DETAILS_URL, RECHARGE_STATE_URL, CLIMATE_START_URL, \
WINDOWS_STATE_URL, LOCK_STATE_URL, TYRE_STATE_URL, supported_entities, BATTERY_CHARGE_STATE_URL, \
@@ -347,7 +348,11 @@ def api_call(url, method, vin, sensor_id=None, force_update=False, key_change=Fa
return None
logging.debug("Response status code: " + str(response.status_code))
data = response.json()
try:
data = response.json()
except JSONDecodeError as e:
logging.error("Fetched json decode error, Volvo API seems to return garbage. Skipping update. Error: " + str(e))
return None
if response.status_code == 200:
logging.debug(response.text)