ShareToVehicleOptions: Add option to send GPS coordinates as destination
Some places on earth don't have regulate street address, especially charging stations along highway. So it would be great to share to vehicle geo coordinates (GPS) as a destination.
As far as I unterstand the ShareToVehicleOptions, this is not possible now, or is it?
While most applications apparently send a postal address to the car, the Google Maps application is sending precise geo coordinates. So the Tesla API seems to accept them.
This gives a hint how to do it, unfortunately no further explained:
API: https://owner-api.teslamotors.com/api/1/vehicles/{remote_id}/command/share
Post JSON:
{
"type": "share_ext_content_raw",
"value": {
"android.intent.extra.TEXT": "{There is no subject, only lng and lat}"
},
"locale": "zh-CN"
}
// Just put the latlon value and that's it. No prefix or tag is needed.
See https://github.com/timdorr/tesla-api/issues/188#issuecomment-624065809
Did you figure out the data needed?
@Krillle this seems easy to implement
is "{There is no subject, only lng and lat}" just "{1.2,3.4}" ?
so i added this to the master branch, give it a try as im not able to right now. If it is buggy we can fix it
I added the feature my app Charge My Way and currently testing. I will let you know, when beta testers report it is working well.
Btw @jonasman if you like to have my app as a beta tester, let me now.
@jonasman thanks for catching up with my idea. I implemented sending coordinate with TeslaSwift version 11.1.2. Beta testers report, it is nicely working. I will be back at my own car on Thursday and can test it myself by then.
static func sendCoordinate (coordinate: CLLocationCoordinate2D) {
if let vehicle = Tesla.car.vehicle {
let shareToVehicleOptions = ShareToVehicleOptions(coordinate: coordinate)
Task {
do {
let _ = try await Tesla.api.sendCommandToVehicle(vehicle, command: VehicleCommand.shareToVehicle(options: shareToVehicleOptions))
print("TESLA API: Coordinate sent", coordinate)
} catch let error {
print("TESLA API: Sending coordinate failed:", error)
}
}
}
}
Log Output:
TESLA API: Coordinate sent CLLocationCoordinate2D(latitude: 51.888644, longitude: 13.836824)
I can confirm testing on my own car: It's working nicely.
@Krillle i would like to test