Skip to content
/ tesla Public

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.

License

Notifications You must be signed in to change notification settings

alandtse/tesla

Repository files navigation

Tesla Custom Integration

GitHub Release GitHub all releases GitHub release (latest by SemVer) GitHub Activity

License

hacs Project Maintenance BuyMeCoffee

Discord Community Forum

A fork of the previous official Tesla integration in Home Assistant which has been removed due to Tesla login issues. Do not report issues to Home Assistant.

To use the component, you will need an application to generate a Tesla refresh token:

Installation

  1. Use HACS, in HACS > Integrations > Explore & Add Repositories search for "Tesla". After adding this https://github.com/alandtse/tesla as a custom repository. Skip to 7.
  2. If you do not have HACS, use the tool of choice to open the directory (folder) for your HA configuration (where you find configuration.yaml).
  3. If you do not have a custom_components directory (folder) there, you need to create it.
  4. In the custom_components directory (folder) create a new folder called tesla_custom.
  5. Download all the files from the custom_components/tesla_custom/ directory (folder) in this repository.
  6. Place the files you downloaded in the new directory (folder) you created.
  7. Restart Home Assistant.
  8. Add the integration: Add Integration or in the HA UI go to "Settings" -> "Devices & Services" then click "+" and search for "Tesla Custom Integration".
  9. For most vehicles, you will need to the Tesla Fleet API Proxy (see below).

Note: This integration will wake up your vehicle(s) during installation.

Tesla Fleet API Proxy

Tesla has deprecated the Owner API for most vehicles in favor of a new Fleet API with end-to-end encryption. You'll know you're affected if you see teslajsonpy.exceptions.TeslaException errors in the log when attempting to send commands (sensors will work regardless).

If your vehicle is affected by this (most likely), you'll need to install the Tesla HTTP Proxy add-on and configure this component to use it. This requires a complex setup; see here for step-by-step instructions.

Usage

The Tesla integration offers integration with the Tesla cloud service and provides presence detection as well as sensors such as charger state and temperature.

This integration provides the following entities for vehicles:

  • Binary sensors - charger connection, charging status, car online, parking brake, car asleep, and door status.
  • Buttons - horn, flash lights, wake up1, force data update1, trigger HomeLink, and remote start. Note: The HomeLink button is disabled by default as some vehicles don't have this option. Enable via configuration/entities if desired.
  • Climate - turn HVAC on/off, set target temperature, set preset modes (defrost, keep on, dog mode and camp mode).
  • Device tracker - car location1, and active route destination.
  • Cover - Charger door, frunk, trunk, and windows.
  • Locks - door lock, and charge port latch lock. Note: Set state to heat_cool or off to enable/disable your Tesla's climate system via a scene.
  • Selects - seat heaters and cabin overheat protection2. Note: Turning on a heated seat will cause the climate to turn on.
  • Sensors - battery level, charge rate, energy added, charger power, inside/outside temperature, odometer, estimated range, time charge complete, TPMS pressure, active route arrival time and distance to arrival.
  • Switches - heated steering wheel, charger, sentry mode, polling, and valet mode.1.
  • Update - software update2

1 Diagnostics entities.
2 Configuration entities.

This integration provides the following entities for energy sites:

  • Binary sensors - Powerwall charging and grid status.
  • Selects - grid charging, export rule and operation mode.
  • Sensors - solar power, grid power, load power, battery level, battery Wh remaining and backup reserve.

Options

Tesla options are set via Configuration -> Integrations -> Tesla -> Options.

  • Seconds between polling - referred to below as the polling_interval.
  • Wake cars on start - Whether to wake sleeping cars on Home Assistant startup. This allows a user to choose whether cars should continue to sleep (and not update information) or to wake up the cars potentially interrupting long term hibernation and increasing vampire drain.
  • Polling policy - When do we actively poll the car to get updates, and when do we try to allow the car to sleep. See the Wiki for more information.
  • Sync Data from TeslaMate via MQTT - Enable syncing of Data from an TeslaMate instance via MQTT, essentially enabling the Streaming API for updates. This requires MQTT to be configured in Home Assistant.

Potential Battery impacts

Here are some things to consider and understand when implementing the Tesla component and its potential effect on your car's battery.

  • The polling_interval determines when to check if the car is awake and new information is available, but the Tesla integration will not wake up a sleeping car during this polling. By default, the polling will occur every 660 seconds. Polling a car too frequently can keep the car awake and drain the battery. Different firmware versions and measurements of Tesla cars can take from 11 to 15 minutes for sleep mode to occur. There is no official information on sleep mode timings so your mileage may vary and you should experiment with different polling times for an optimal experience.
  • The car will, however, be woken up when a command is actively sent to the car, such as door unlock or turning on the HVAC. It will then also fetch updated information while the car is awake based on the polling_interval.
  • The car can intentionally be woken up to fetch recent information by sending a harmless command, for example, a lock command. This can be used in an automation to, for example, ensure that updated information is available every morning. (Note that the command must be valid for that specific car model. So locking the frunk of a Model 3 will not wake up that car).
  • You can also toggle the polling switch on/off to disable polling of the vehicle completely via automations or the Lovelace UI.

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines

Component built with integration_blueprint.