teslajsonpy

Python Package for controlling Tesla API.

For more details about this api, please refer to the documentation at https://github.com/zabuldon/teslajsonpy

Classes

  • Connection: Connection to Tesla Motors API.

  • Controller: Controller for connections to Tesla Motors API.

  • TeslaProxy: Class to handle proxy login connections to Alexa.

  • Battery: Home-Assistant battery class for a Tesla VehicleDevice.

  • Range: Home-Assistant class of the battery range for a Tesla VehicleDevice.

  • ChargerConnectionSensor: Home-assistant charger connection class for Tesla vehicles.

  • ChargingSensor: Home-Assistant charging sensor class for a Tesla VehicleDevice.

  • OnlineSensor: Home-Assistant Online sensor class for a Tesla VehicleDevice.

  • ParkingSensor: Home-assistant parking brake class for Tesla vehicles.

  • UpdateSensor: Home-Assistant update sensor class for a Tesla VehicleDevice.

  • ChargerSwitch: Home-Assistant class for the charger of a Tesla VehicleDevice.

  • RangeSwitch: Home-Assistant class for setting range limit for charger.

  • Climate: Home-assistant class of HVAC for Tesla vehicles.

  • TempSensor: Home-assistant class of temperature sensors for Tesla vehicles.

  • GPS: Home-assistant class for GPS of Tesla vehicles.

  • Odometer: Home-assistant class for odometer of Tesla vehicles.

  • Lock: Home-assistant lock class for Tesla vehicles.

  • SentryModeSwitch: Home-Assistant class for sentry mode of Tesla vehicles.

  • TrunkLock: Home-Assistant rear trunk lock for a Tesla VehicleDevice.

  • FrunkLock: Home-Assistant front trunk (frunk) lock for a Tesla VehicleDevice.

class teslajsonpy.Connection(websession: aiohttp.client.ClientSession, email: Optional[str] = None, password: Optional[str] = None, access_token: Optional[str] = None, refresh_token: Optional[str] = None, authorization_token: Optional[str] = None, expiration: int = 0)

Connection to Tesla Motors API.

Inheritance

digraph inheritance087f428942 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Connection" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Connection to Tesla Motors API."]; }
async get(command)

Get data from API.

async get_authorization_code(email: str, password: str, mfa_code: str = '', mfa_device: int = 0, retry_limit: int = 3)str

Get authorization code from the oauth3 login method.

Get authorization code url for the oauth3 login method.

async get_bearer_token(access_token)

Get bearer token. This is used by the owners API.

async get_sso_auth_token(code)

Get sso auth token.

async post(command, method='post', data=None)

Post data to API.

async refresh_access_token(refresh_token)

Refresh access token from sso.

async websocket_connect(vin: int, vehicle_id: int, **kwargs)

Connect to Tesla streaming websocket.

Parameters
  • vin (int) – vin of vehicle

  • vehicle_id (int) – vehicle_id from Tesla api

  • on_message (function) – function to call on a valid message. It must process a json delivered in data

  • on_disconnect (function) – function to call on a disconnect message. It must process a json delivered in data

class teslajsonpy.Controller(websession, email: Optional[str] = None, password: Optional[str] = None, access_token: Optional[str] = None, refresh_token: Optional[str] = None, expiration: int = 0, update_interval: int = 300, enable_websocket: bool = False)

Controller for connections to Tesla Motors API.

Inheritance

digraph inheritancef1ba0f48d0 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Controller" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Controller for connections to Tesla Motors API."]; }
async command(car_id, name, data=None, wake_if_asleep=True)

Post name command to the car_id.

Parameters
Returns

Tesla json object.

Return type

dict

async connect(test_login: bool = False, wake_if_asleep: bool = False, filtered_vins: Optional[List[str]] = None, mfa_code: str = '')Dict[str, str]

Connect controller to Tesla.

Args

test_login (bool, optional): Whether to test credentials only. Defaults to False. wake_if_asleep (bool, optional): Whether to wake up any sleeping cars to update state. Defaults to False. filtered_vins (list, optional): If not empty, filters the cars by the provided VINs. mfa_code (Text, optional): MFA code to use for connection

Returns

Dict[Text, Text]: Returns the refresh_token, access_token, and expires_in time

async data_request(car_id, name, wake_if_asleep=False)

Get requested data from car_id.

Parameters
Returns

Tesla json object.

Return type

dict

async get(car_id, command, wake_if_asleep=False)

Send get command to the car_id.

This is a wrapped function by wake_up.

Parameters
Returns

Tesla json object.

Return type

dict

get_charging_params(car_id)

Return cached copy of charging_params for car_id.

get_climate_params(car_id)

Return cached copy of climate_params for car_id.

get_config_params(car_id)

Return cached copy of state_params for car_id.

get_drive_params(car_id)

Return cached copy of drive_params for car_id.

get_expiration()int

Return expiration for oauth.

Returns

int: Returns timestamp when oauth expires

get_gui_params(car_id)

Return cached copy of gui_params for car_id.

get_homeassistant_components()

Return list of Tesla components for Home Assistant setup.

Use get_vehicles() for general API use.

get_last_update_time(car_id: Optional[str] = None)

Get last_update time dictionary.

Parameters

car_id (string) – Identifier for the car on the owner-api endpoint. It is the id field for identifying the car across the owner-api endpoint. https://tesla-api.timdorr.com/api-basics/vehicles#vehicle_id-vs-id If no car_id, returns the complete dictionary.

Returns

If car_id exists, a int (time.time()) indicating when updates last processed. Othewise, the entire updates dictionary.

Return type

int or dict of ints

get_oauth_url()yarl.URL

Return oauth url.

get_state_params(car_id)

Return cached copy of state_params for car_id.

get_tokens()Dict[str, str]

Return oauth data including refresh and access tokens, and expires time.

This will set the the self.__connection token_refreshed to False.

Returns

Dict[Text, Text]: Returns the refresh_token, access_token, and expires time

get_updates(car_id: Optional[str] = None)

Get updates dictionary.

Parameters

car_id (string) – Identifier for the car on the owner-api endpoint. It is the id field for identifying the car across the owner-api endpoint. https://tesla-api.timdorr.com/api-basics/vehicles#vehicle_id-vs-id If no car_id, returns the complete dictionary.

Returns

If car_id exists, a bool indicating whether updates should be processed. Othewise, the entire updates dictionary.

Return type

bool or dict of booleans

async get_vehicles()

Get vehicles json from TeslaAPI.

is_token_refreshed()bool

Return whether token has been changed and not retrieved.

Returns

bool: Whether token has been changed since the last return

async post(car_id, command, data=None, wake_if_asleep=True)

Send post command to the car_id.

This is a wrapped function by wake_up.

Parameters
Returns

Tesla json object.

Return type

dict

register_websocket_callback(callback)int

Register callback for websocket messages.

Args

callback (function): function to call with json data

Returns

int: Return index of entry

set_authorization_code(code: str)None

Set authorization code in Connection.

set_authorization_domain(domain: str)None

Set authorization domain in Connection.

set_updates(car_id: str, value: bool)None

Set updates dictionary.

Parameters
Returns

Return type

None

async update(car_id: Optional[str] = None, wake_if_asleep: bool = False, force: bool = False)bool

Update all vehicle attributes in the cache.

This command will connect to the Tesla API and first update the list of online vehicles assuming no attempt for at least the [update_interval]. It will then update all the cached values for cars that are awake assuming no update has occurred for at least the [update_interval].

Args

car_id (Text, optional): The vehicle to update. If None, all cars are updated. Defaults to None. wake_if_asleep (bool, optional): force a vehicle awake. This is processed by the wake_up decorator. Defaults to False. force (bool, optional): force a vehicle update regardless of the update_interval. Defaults to False.

Returns

Whether update was successful.

Raises

RetryLimitError

property update_interval

Return update_interval.

Returns

int: The number of seconds between updates

class teslajsonpy.TeslaProxy(proxy_url: yarl.URL, host_url: yarl.URL)

Class to handle proxy login connections to Alexa.

Inheritance

digraph inheritance8fc76f5186 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "AuthCaptureProxy" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class to handle proxy login connections."]; "TeslaProxy" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class to handle proxy login connections to Alexa."]; "AuthCaptureProxy" -> "TeslaProxy" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
async modify_headers(site: yarl.URL, request: aiohttp.web_request.Request)multidict._multidict.MultiDict

Modify headers.

Parameters
  • site (URL) – URL of the next host request.

  • request (web.Request) – Proxy directed request. This will need to be changed for the actual host request.

Returns

multidict.MultiDict: Headers after modifications

async prepend_i18n_path(base_url: yarl.URL, html: str)str

Prepend path for i18n loadPath so it’ll reach the proxy.

This is intended to be used for to place the proxy_url path in front of relative urls for loadPath in i18next.

Parameters
  • base_url (URL) – Base URL to prepend

  • html (Text) – Text to replace

Returns

Text: Replaced text

async prepend_relative_urls(base_url: yarl.URL, html: str)str

Prepend relative urls with url host.

This is intended to be used for to place the proxy_url in front of relative urls in src=”/

Parameters
  • base_url (URL) – Base URL to prepend

  • html (Text) – Text to replace

Returns

Text: Replaced text

async reset_data()None

Reset all stored data.

A proxy may need to service multiple login requests if the route is not torn down. This function will reset all data between logins.

async test_url(resp: aiohttp.client_reqrep.ClientResponse, data: Dict[str, Any], query: Dict[str, Any])

Test for a successful Tesla URL.

https://tesla-api.timdorr.com/api-basics/authentication#step-2-obtain-an-authorization-code

Parameters
  • resp (ClientResponse) – The aiohttp response.

  • data (Dict[Text, Any]) – Dictionary of all post data captured through proxy with overwrites for duplicate keys.

  • query (Dict[Text, Any]) – Dictionary of all query data with overwrites for duplicate keys.

Returns

Optional[Union[URL, Text]]: URL for a http 302 redirect or Text to display on success. None indicates test did not pass.

class teslajsonpy.Battery(data: Dict, controller)

Home-Assistant battery class for a Tesla VehicleDevice.

Inheritance

digraph inheritance5da92de2cf { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Battery" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant battery class for a Tesla VehicleDevice."]; "VehicleDevice" -> "Battery" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the battery state.

battery_charging()bool

Return the battery level.

battery_level()int

Return the battery level.

property device_class

Return the HA device class.

get_value()int

Return the battery level.

static has_battery()bool

Return whether the device has a battery.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.Range(data: Dict, controller)

Home-Assistant class of the battery range for a Tesla VehicleDevice.

Inheritance

digraph inheritance3b6ce52305 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Range" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant class of the battery range for a Tesla VehicleDevice."]; "VehicleDevice" -> "Range" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the battery range state.

property device_class

Return the HA device class.

get_value()

Return the battery range.

This function will return either the rated range or the ideal range based on the gui_settings.

static has_battery()

Return whether the device has a battery.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.ChargerConnectionSensor(data, controller)

Home-assistant charger connection class for Tesla vehicles.

This is intended to be partially inherited by a Home-Assitant entity.

Inheritance

digraph inheritancedc9e0604ed { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "BinarySensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant binary sensor class for Tesla vehicles."]; "VehicleDevice" -> "BinarySensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ChargerConnectionSensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant charger connection class for Tesla vehicles."]; "BinarySensor" -> "ChargerConnectionSensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the charger connection sensor.

get_value()Optional[bool]

Return whether the charger cable is connected.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.ChargingSensor(data: Dict, controller)

Home-Assistant charging sensor class for a Tesla VehicleDevice.

Inheritance

digraph inheritance6a3dfb1ac4 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ChargingSensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant charging sensor class for a Tesla VehicleDevice."]; "VehicleDevice" -> "ChargingSensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
property added_range

Return the added range.

async async_update(wake_if_asleep=False, force=False)None

Update the battery state.

property charge_current_request

Return the requested current.

property charge_energy_added

Return the energy added.

property charge_limit_soc

Return the state of charge limit.

property charger_actual_current

Return the actual current.

property charger_voltage

Return the voltage.

property charging_rate

Return the charging rate.

property device_class

Return the HA device class.

static has_battery()bool

Return whether the device has a battery.

refresh()None

Refresh data.

This assumes the controller has already been updated

property time_left

Return the time left to full in hours.

class teslajsonpy.OnlineSensor(data: Dict, controller)

Home-Assistant Online sensor class for a Tesla VehicleDevice.

Inheritance

digraph inheritance163c0cebb3 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "BinarySensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant binary sensor class for Tesla vehicles."]; "VehicleDevice" -> "BinarySensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "OnlineSensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant Online sensor class for a Tesla VehicleDevice."]; "BinarySensor" -> "OnlineSensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the battery state.

get_value()Optional[bool]

Return the car is online.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.ParkingSensor(data: Dict, controller)

Home-assistant parking brake class for Tesla vehicles.

This is intended to be partially inherited by a Home-Assitant entity.

Inheritance

digraph inheritanceb808b41618 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "BinarySensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant binary sensor class for Tesla vehicles."]; "VehicleDevice" -> "BinarySensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ParkingSensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant parking brake class for Tesla vehicles."]; "BinarySensor" -> "ParkingSensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the parking brake sensor.

get_value()Optional[bool]

Return whether parking brake engaged.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.UpdateSensor(data: Dict, controller)

Home-Assistant update sensor class for a Tesla VehicleDevice.

Inheritance

digraph inheritancec8d3478604 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "BinarySensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant binary sensor class for Tesla vehicles."]; "VehicleDevice" -> "BinarySensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "UpdateSensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant update sensor class for a Tesla VehicleDevice."]; "BinarySensor" -> "UpdateSensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the battery state.

property device_state_attributes

Return the optional state attributes.

get_value()Optional[bool]

Return the car is online.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.ChargerSwitch(data, controller)

Home-Assistant class for the charger of a Tesla VehicleDevice.

Inheritance

digraph inheritanceca9a0e4ac7 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ChargerSwitch" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant class for the charger of a Tesla VehicleDevice."]; "VehicleDevice" -> "ChargerSwitch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the charging state of the Tesla Vehicle.

static has_battery()

Return whether the Tesla charger has a battery.

is_charging()

Return whether the Tesla Vehicle is charging.

refresh()None

Refresh data.

This assumes the controller has already been updated

async start_charge()

Start charging the Tesla Vehicle.

async stop_charge()

Stop charging the Tesla Vehicle.

class teslajsonpy.RangeSwitch(data, controller)

Home-Assistant class for setting range limit for charger.

Inheritance

digraph inheritance2f47351d84 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "RangeSwitch" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant class for setting range limit for charger."]; "VehicleDevice" -> "RangeSwitch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the status of the range setting.

static has_battery()

Return whether the device has a battery.

is_maxrange()

Return whether max range setting is set.

refresh()None

Refresh data.

This assumes the controller has already been updated

async set_max()

Set the charger to max range for trips.

async set_standard()

Set the charger to standard range for daily commute.

class teslajsonpy.Climate(data, controller)

Home-assistant class of HVAC for Tesla vehicles.

This is intended to be partially inherited by a Home-Assitant entity.

Inheritance

digraph inheritance5cb5c12563 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Climate" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of HVAC for Tesla vehicles."]; "VehicleDevice" -> "Climate" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the HVAC state.

get_current_temp()

Return vehicle inside temperature.

get_fan_status()

Return fan status.

get_goal_temp()

Return driver set temperature.

static has_battery()

Return whether the device has a battery.

is_hvac_enabled()

Return whether HVAC is running.

property preset_mode

Return the current preset mode, e.g., home, away, temp.

Requires SUPPORT_PRESET_MODE.

property preset_modes

Return a list of available preset modes.

Requires SUPPORT_PRESET_MODE.

refresh()None

Refresh data.

This assumes the controller has already been updated

async set_preset_mode(preset_mode: str)None

Set new preset mode.

async set_status(enabled)

Enable or disable the HVAC.

async set_temperature(temp)

Set both the driver and passenger temperature to temp.

class teslajsonpy.TempSensor(data, controller)

Home-assistant class of temperature sensors for Tesla vehicles.

This is intended to be partially inherited by a Home-Assitant entity.

Inheritance

digraph inheritance1182b8abef { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "TempSensor" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of temperature sensors for Tesla vehicles."]; "VehicleDevice" -> "TempSensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the temperature.

property device_class

Return the HA device class.

get_inside_temp()

Get inside temperature.

get_outside_temp()

Get outside temperature.

static has_battery()

Return whether the device has a battery.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.GPS(data, controller)

Home-assistant class for GPS of Tesla vehicles.

Inheritance

digraph inheritance8afb2b6446 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GPS" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class for GPS of Tesla vehicles."]; "VehicleDevice" -> "GPS" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the current GPS location.

get_location()

Return the current location.

static has_battery()

Return whether the device has a battery.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.Odometer(data, controller)

Home-assistant class for odometer of Tesla vehicles.

Inheritance

digraph inheritancea98c743a5d { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Odometer" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class for odometer of Tesla vehicles."]; "VehicleDevice" -> "Odometer" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the odometer and the unit of measurement based on GUI.

property device_class

Return the HA device class.

get_value()

Return the odometer reading.

static has_battery()

Return whether the device has a battery.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.Lock(data, controller)

Home-assistant lock class for Tesla vehicles.

This is intended to be partially inherited by a Home-Assitant entity.

Inheritance

digraph inheritance832c3edb9e { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Lock" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant lock class for Tesla vehicles."]; "VehicleDevice" -> "Lock" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the lock state.

static has_battery()

Return whether the device has a battery.

is_locked()

Return whether doors are locked.

async lock()

Lock the doors.

refresh()None

Refresh data.

This assumes the controller has already been updated

async unlock()

Unlock the doors and extend handles where applicable.

class teslajsonpy.SentryModeSwitch(data, controller)

Home-Assistant class for sentry mode of Tesla vehicles.

Inheritance

digraph inheritance02c463f274 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "SentryModeSwitch" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant class for sentry mode of Tesla vehicles."]; "VehicleDevice" -> "SentryModeSwitch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)

Update the sentry mode of the vehicle.

available()bool

Return whether the sentry mode is available.

async disable_sentry_mode()None

Disable the sentry mode.

async enable_sentry_mode()None

Enable the sentry mode.

static has_battery()bool

Return whether the device has a battery.

is_on()Optional[bool]

Return whether the sentry mode is enabled, or None if sentry mode is not available.

refresh()None

Refresh data.

This assumes the controller has already been updated

class teslajsonpy.TrunkLock(data, controller)

Home-Assistant rear trunk lock for a Tesla VehicleDevice.

Inheritance

digraph inheritanceb343d48f3f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "TrunkLock" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant rear trunk lock for a Tesla VehicleDevice."]; "VehicleDevice" -> "TrunkLock" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the rear trunk state.

static has_battery()

Return whether the device has a battery.

is_locked()

Return whether the rear trunk is closed.

async lock()

Close the rear trunk.

refresh()None

Refresh data.

This assumes the controller has already been updated

async unlock()

Open the rear trunk.

class teslajsonpy.FrunkLock(data, controller)

Home-Assistant front trunk (frunk) lock for a Tesla VehicleDevice.

Inheritance

digraph inheritancea7a0fc7c8a { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "FrunkLock" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-Assistant front trunk (frunk) lock for a Tesla VehicleDevice."]; "VehicleDevice" -> "FrunkLock" [arrowsize=0.5,style="setlinewidth(0.5)"]; "VehicleDevice" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Home-assistant class of Tesla vehicles."]; }
async async_update(wake_if_asleep=False, force=False)None

Update the front trunk (frunk) state.

static has_battery()

Return whether the device has a battery.

is_locked()

Return whether the front trunk (frunk) is closed.

async lock()

Close the front trunk (frunk).

refresh()None

Refresh data.

This assumes the controller has already been updated

async unlock()

Open the front trunk (frunk).

Exceptions

exception teslajsonpy.TeslaException(code: str, *args, **kwargs)

Class of Tesla API exceptions.

Inheritance

digraph inheritancea58a391388 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "TeslaException" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class of Tesla API exceptions."]; }
exception teslajsonpy.UnknownPresetMode(code: str, *args, **kwargs)

Class of exceptions for Unknown Preset.

Inheritance

digraph inheritancec2ed502f44 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "TeslaException" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class of Tesla API exceptions."]; "UnknownPresetMode" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class of exceptions for Unknown Preset."]; "TeslaException" -> "UnknownPresetMode" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
exception teslajsonpy.RetryLimitError(code: str, *args, **kwargs)

Class of exceptions for hitting retry limits.

Inheritance

digraph inheritancefae8dcd8d6 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "RetryLimitError" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class of exceptions for hitting retry limits."]; "TeslaException" -> "RetryLimitError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TeslaException" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class of Tesla API exceptions."]; }
exception teslajsonpy.IncompleteCredentials(code: str, *args, devices: Optional[Dict[Any, Any]] = None, **kwargs)

Class of exceptions for incomplete credentials.

Inheritance

digraph inheritance49d735891d { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "IncompleteCredentials" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class of exceptions for incomplete credentials."]; "TeslaException" -> "IncompleteCredentials" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TeslaException" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Class of Tesla API exceptions."]; }

Variables

teslajsonpy.__version__

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

'0.15.0'