TeslaKit Unity/C# Wrapper package gives you the ability to easily use the Tesla API from your Unity applications. You can make state or command requests to your vehicle and add more endpoints for future supported features of each Tesla model.
Massive thanks to https://github.com/timdorr for creating documentation around the Tesla API. Check out the Unoffical Tesla API https://tesla-api.timdorr.com/ for more documentation on the exact endpoints and auth services that are being used in this plugin.
- Tesla API Wrapper for Unity (OAuth2.0, List Vehicles, State / Command Requests, etc.)
- Nextmind Brain-Computer Interface Support for Mind-Control of Tesla Vehicle; Neuralink Support TDB
- 3D Vehicle of Tesla Model 3
- Ability to Add Vehicle Endpoint Methods for Future Vehicle Endpoint Updates.
- Real-time Tesla Debug Console UI in Examples
- Universal Render Pipeline Supported
- Async/await Pattern for Http Vehicle Requests
This package uses the semantic versioning strategy as required for all Unity packages. More info at https://docs.unity3d.com/Manual/upm-semver.html
using Tesla.API.Core;
using UnityEngine;
public class Example : MonoBehaviour {
private async void Start() {
TeslaClient Client = new TeslaClient();
await Client.AuthenticateAsync("your@email.com", "••••••••••••");
Client.User.GetVehicle<Model3>(async (M3) => {
var state = await M3.GetDriveStateAsync();
Debug.Log($"Vehicle Heading: {state.Response.heading}");
var command = await M3.SetChargeLimitAsync(80);
Debug.Log($"Charge Limit Set Result: {command.Response.result}");
});
}
}
using Tesla.API.Core;
using System.Threading.Tasks;
public static class VehicleExtensions
{
public static async Task<Command> OpenChargePortAsync(this Vehicle vehicle) {
return await vehicle.RequestAsync<Command>($"/api/1/vehicles/{vehicle.Id}/command/charge_port_door_open");
}
}
If you create a endpoint extension method for a new type of vehicle state you will have to create a serializable type that matches exactly the structure of the incoming JSON from the API for the serializer to work. After you've created the seriablizable type pass it into the generic RequestAsync() method as a type paramater.
Follow the official Unity guide linked below to install this package using the package manager inside of Unity. https://docs.unity3d.com/Manual/upm-ui-giturl.html
- Add the rest of API endpoints
- Add refresh token method
- Add support for raw json response ex.Task<Response> Response.Raw
- Handle sign in failed if possible either for incorrect password or don't have an account etc.
- Add better and more robust exception handing
- Implement an awaitable handle for all requests for users to create loading bars or loading wheels.
- Break up auth request method into smaller pieces
- Fix Wake command response object not parsing from newtonsoft
- Add Neuralink support 🤷♂️