Skip to content

Add polling interval section to Tesla Fleet #38789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions source/_integrations/tesla_fleet.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ You must have:
- [AWS S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)
- [Cloudflare Pages](https://pages.cloudflare.com/)
- [Firebase Hosting](https://firebase.google.com/docs/hosting)


{% include integrations/config_flow.md %}

Expand Down Expand Up @@ -102,7 +102,7 @@ The following steps involve sensitive credentials. Never share your `Client Secr
1. Get your OAuth details by going to your [Developer dashboard](https://developer.tesla.com/en_US/dashboard). Under the app you set up for Home Assistant integration select **View Details**. Then, select the **Credentials & APIs** tab. Note the `Client ID` and `Client Secret` strings.

2. Run this CURL request, replacing the variable values as specified in the notes below:

```shell
CLIENT_ID=REPLACE_THIS_WITH_YOUR_CLIENT_ID
CLIENT_SECRET=REPLACE_THIS_WITH_YOUR_CLIENT_SECRET
Expand All @@ -116,20 +116,20 @@ The following steps involve sensitive credentials. Never share your `Client Secr
--data-urlencode "audience=$AUDIENCE" \
'https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3/token'
```

Notes about the variable values:
- For the `CLIENT_SECRET` value, depending on your terminal environment, you may need to escape any `!` and `$` characters in the string, or the curl request will fail.
- Replace the `AUDIENCE` value with your region-specific URL. The URL in the example is for users in North America and Asia-Pacific (excluding China). Refer to the [Base URLs documentation](https://developer.tesla.com/docs/fleet-api/getting-started/base-urls) for the URLs for other regions.
- For the `scope=...` line, replace the values with a space-delimited list of [the official scope keywords](https://developer.tesla.com/docs/fleet-api/authentication/overview#scopes), as you defined them earlier in your app.
3. The CURL request should return a response that looks something like:

```json
{"access_token":"ACCESS_TOKEN","expires_in":28800,"token_type":"Bearer"}
```

This is your access token. Copy everything between the double-quotes to be used next.
4. Run this CURL request, replacing the variable values as specified in the notes below:

```shell
curl --location 'https://fleet-api.prd.na.vn.cloud.tesla.com/api/1/partner_accounts' \
--header 'Content-Type: application/json' \
Expand All @@ -138,7 +138,7 @@ The following steps involve sensitive credentials. Never share your `Client Secr
"domain": "my.domain.com"
}'
```

- If you had to change the `AUDIENCE` URL for your region in step 2, update the main domain of the `--location` arg.
- Replace `ACCESS_TOKEN` with the access token that you copied in the previous step.
- In the `domain:` line, enter your domain without the leading `https://` and the trailing `/`.
Expand All @@ -158,6 +158,14 @@ The following steps involve sensitive credentials. Never share your `Client Secr

{% enddetails %}

## Vehicle data polling interval

The integration is configured to {% term polling poll %} each vehicle every 10 minutes while it's awake.
This is long enough that a single vehicle can be polled 24/7 without exceeding the USD$10 credit Tesla provides.
It is expected that most vehicles are asleep over 50% of the day, so the defaults should also suit users with multiple vehicles or that want to run automated commands.

If the default polling interval does not suit your needs, you can [define a custom polling interval](https://www.home-assistant.io/common-tasks/general/#defining-a-custom-polling-interval).

## Scopes

When connecting your Tesla account to Home Assistant, you **must** select at least one of the `Vehicle Information` or `Energy Product Information` scopes. It is recommended you select all scopes for full functionality. The `Vehicle Location` scope was added in Home Assistant 2024.1, so any authorizations performed on previous releases that want this scope will need to be [modified](https://accounts.tesla.com/en_au/account-settings/security?tab=tpty-apps).
Expand Down