Skip to content

bloto/tesla.kt

Repository files navigation

Tesla for Kotlin

Build Status Maven Central

A multi-platform Tesla API Client Library for Kotlin and Java.

dependencies {
  implementation("org.teslatoolkit:tesla-core:0.1.0")
}

Features

  • Authentication
    • Email/Password
    • OAuth2 Token
  • Read Access
    • Vehicles on Account
    • Climate State
    • Drive State
    • Media State
    • Charge State
    • Vehicle Configuration
    • GUI Settings

Examples

Kotlin

suspend fun main() {
  val client = TeslaHttpClient.create(
    AccountAuthentication(
      email = "[email protected]",
      password = "MySecurePassword"
    )
  )

  client.listVehicles().forEach { vehicle ->
    println("Vehicle ${vehicle.vehicleId}:")
    println("  State: ${vehicle.state}")
  }

  client.close()
}

Java

class ExampleMain {
  public static void main(String[] args){
    AuthenticationMethod auth = new AccountAuthentication(args[0], args[1]);
    try (TeslaClientSync client = TeslaClientSync.create(auth)) {
      for (Vehicle vehicle : client.listVehicles()) {
        System.out.println("Vehicle " + vehicle.getVehicleId());
        System.out.println("  State: " + vehicle.getState());
      }
    }
  }
}

About

Tesla Client Library for Kotlin

Resources

License

Stars

Watchers

Forks

Packages

No packages published