Class TeslaLiveApi

java.lang.Object
de.chiflux.tesla.TeslaLiveApi
All Implemented Interfaces:
TeslaApi

public class TeslaLiveApi extends Object implements TeslaApi
A thin wrapper around the Tesla API functionality supporting charging. It makes use of these APIs: /api/1/vehicles, /ID/vehicle_data, /ID/wake_up, /ID/command/set_charge_limit, /ID/command/charge_*
  • Constructor Details

    • TeslaLiveApi

      public TeslaLiveApi(String teslaRefreshToken)
      Explicit constructor that takes the TESLA_REFRESH_TOKEN as parameter.
      Parameters:
      teslaRefreshToken - The TESLA_REFRESH_TOKEN as parameter - must not be null
    • TeslaLiveApi

      public TeslaLiveApi()
      Default constructor which reads TESLA_REFRESH_TOKEN from Java Properties or ENV Variable. A Java Property has precedence over an ENV variable.
  • Method Details

    • startCharge

      public Boolean startCharge(String id_s)
      Description copied from interface: TeslaApi
      Start charging
      Specified by:
      startCharge in interface TeslaApi
      Parameters:
      id_s - id of the vehicle
      Returns:
      true if successful
    • stopCharge

      public Boolean stopCharge(String id_s)
      Description copied from interface: TeslaApi
      Stop charging
      Specified by:
      stopCharge in interface TeslaApi
      Parameters:
      id_s - id of the vehicle
      Returns:
      true if successful
    • setChargeLimit

      public Boolean setChargeLimit(String id_s, int chargeLimit)
      Description copied from interface: TeslaApi
      Set the charge limit
      Specified by:
      setChargeLimit in interface TeslaApi
      Parameters:
      id_s - id of the vehicle
      chargeLimit - charge limit in percent
      Returns:
      true if successful
    • wakeUp

      public Boolean wakeUp(String id_s)
      Description copied from interface: TeslaApi
      Wake up the vehicle
      Specified by:
      wakeUp in interface TeslaApi
      Parameters:
      id_s - id of the vehicle
      Returns:
      true if successful
    • getFullVehicleData

      public FullVehicleData getFullVehicleData(String id_s)
      Description copied from interface: TeslaApi
      Full vehicle data consists of charge state, drive state, vehicle config vehicle state and general information. Should implement a grace period if the vehicle is parked and locked to give the vehicle a change to sleep.
      Specified by:
      getFullVehicleData in interface TeslaApi
      Parameters:
      id_s - id of the vehicle
      Returns:
      Full vehicle data or null
    • getVehicles

      public VehiclesResponse getVehicles()
      Description copied from interface: TeslaApi
      All vehicles associated with the account
      Specified by:
      getVehicles in interface TeslaApi
      Returns:
      All vehicles associated with the account or null
    • refreshToken

      public void refreshToken()
      Description copied from interface: TeslaApi
      Refresh the access token.
      Specified by:
      refreshToken in interface TeslaApi