Class TeslaApiService

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

public class TeslaApiService extends Object implements TeslaApi
Service Monitoring of all assigned vehicles of a tesla account.
  • Field Details

    • STATE_CHANGE_INFO_QUEUE

      public final SynchronousQueue<StateChangeInfo> STATE_CHANGE_INFO_QUEUE
      Synchronous queue to safely exchange state change events over thread boundaries.
  • Method Details

    • getInstance

      public static TeslaApiService getInstance()
      Get the instance
      Returns:
      the instance
    • markVehicleInactive

      public void markVehicleInactive(String id)
      Will let a vehicle fall asleep
      Parameters:
      id - the vehicle id
    • unmuteVehicle

      public void unmuteVehicle(String id_s)
      Allow requesting the vehicle data API
      Parameters:
      id_s - id of the vehicle
    • isMute

      public boolean isMute(String id_s)
      Tests if a car is mute i.e., it will not query the vehicle data API to give the vehicle a chance to fall asleep.
      Parameters:
      id_s - id of the vehicle
      Returns:
      true if vehicle is mute
    • startService

      public void startService()
      Starts the monitoring service
    • pauseService

      public void pauseService()
      Pauses the monitoring service
    • endService

      public void endService()
      Ends the monitoring service (cannot be restarted afterward)
    • 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)
      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 - 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