mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-22 09:26:16 +00:00
Merge pull request #25 from farom57/master
fix Value Error for position/ handle altitude
This commit is contained in:
+10
-3
@@ -77,9 +77,16 @@ def preconditioning(vin, activate):
|
||||
@app.route('/position/<string:vin>')
|
||||
def get_position(vin):
|
||||
res = myp.get_vehicle_info(vin)
|
||||
longitude, latitude = res.last_position.geometry.coordinates
|
||||
return jsonify(
|
||||
{"longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"})
|
||||
coordinates=res.last_position.geometry.coordinates
|
||||
if len(coordinates)==3: # altitude is not always availlable
|
||||
longitude, latitude, altitude = coordinates
|
||||
return jsonify(
|
||||
{"longitude": longitude, "latitude": latitude, "altitude": altitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"})
|
||||
else:
|
||||
longitude, latitude = coordinates
|
||||
return jsonify(
|
||||
{"longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"})
|
||||
|
||||
|
||||
|
||||
# Set a battery threshold and schedule an hour to stop the charge
|
||||
|
||||
Reference in New Issue
Block a user