mirror of
https://github.com/Dielee/volvo2mqtt.git
synced 2026-08-13 03:09:52 +02:00
Fix wrong return values for not working endpoints
This commit is contained in:
+4
-4
@@ -183,17 +183,17 @@ def api_call(url, method, vin, sensor_id=None, force_update=False):
|
|||||||
response = session.get(url.format(vin), timeout=15)
|
response = session.get(url.format(vin), timeout=15)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print("Error getting data: " + str(e))
|
print("Error getting data: " + str(e))
|
||||||
return ""
|
return None
|
||||||
elif method == "POST":
|
elif method == "POST":
|
||||||
print("Starting " + method + " call against " + url)
|
print("Starting " + method + " call against " + url)
|
||||||
try:
|
try:
|
||||||
response = session.post(url.format(vin), timeout=20)
|
response = session.post(url.format(vin), timeout=20)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print("Error getting data: " + str(e))
|
print("Error getting data: " + str(e))
|
||||||
return ""
|
return None
|
||||||
else:
|
else:
|
||||||
print("Unkown method posted: " + method + ". Returning nothing")
|
print("Unkown method posted: " + method + ". Returning nothing")
|
||||||
return ""
|
return None
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -207,7 +207,7 @@ def api_call(url, method, vin, sensor_id=None, force_update=False):
|
|||||||
mqtt.update_car_data()
|
mqtt.update_car_data()
|
||||||
else:
|
else:
|
||||||
print("API Call failed. Status Code: " + str(response.status_code) + ". Error: " + response.text)
|
print("API Call failed. Status Code: " + str(response.status_code) + ". Error: " + response.text)
|
||||||
return ""
|
return None
|
||||||
return parse_api_data(data, sensor_id)
|
return parse_api_data(data, sensor_id)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user