Skip to content
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

Dynamic endpoints and token to use official Tesla API (self-hosted or from third party provider) #3903

Merged
merged 33 commits into from
May 27, 2024

Conversation

jlestel
Copy link
Contributor

@jlestel jlestel commented May 21, 2024

I introduced dynamic endpoints and a token to maxime compatibility for future Tesla API/streaming change:

dynamic endpoints based on ENV vars allows us to connect self-hosted Tesla Fleet API or homemade streaming/testing API
an optional token param to use official Tesla API and Telemetry via by a third party:
It is because the access_token and refresh_token are refreshed by these third parties that this token parameter is mandatory. Thus TeslaMate does not lose access and the API keys are managed on the third party's site.
Here are the 2 actors who operate according to this principle: MyTeslamate (free) and Teslemetry (24$/year)
When a token is provided, no inputs are needed when the user sign up
A compatible streaming server is also provided by a third party, the stream only sends events with the minimum interval of 1 minute. The streaming interval is the main regression in this operation with official Tesla Telemetry.

However, the new API also contains new data that can make it possible to create interesting new features.

Initially merged and reverted in PR 3866.

Copy link

netlify bot commented May 21, 2024

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit 62ae2b9
🔍 Latest deploy log https://app.netlify.com/sites/teslamate/deploys/665441edc93684000884b3ec
😎 Deploy Preview https://deploy-preview-3903--teslamate.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JakobLichterfeld JakobLichterfeld added enhancement New feature or request area:tesla api Related to the Tesla API area:teslamate Related to TeslaMate core labels May 21, 2024
@jlestel
Copy link
Contributor Author

jlestel commented May 21, 2024

@JakobLichterfeld I fix the error no match of right hand side value: "https://auth.tesla.com/oauth2/v3" on file lib/tesla_api/auth/refresh.ex:12.

It was linked to my lack of knowledge about Elixir. I corrected the assignment of the issuer_url variable

@jlestel
Copy link
Contributor Author

jlestel commented May 22, 2024

I tried the ghcr.io/teslamate-org/teslamate:pr-3903, seems fine to me. If we have testers, they can try it. I think that was the only typo.

@JakobLichterfeld
Copy link
Collaborator

@JakobLichterfeld I fix the error no match of right hand side value: "https://auth.tesla.com/oauth2/v3" on file lib/tesla_api/auth/refresh.ex:12.

It was linked to my lack of knowledge about Elixir. I corrected the assignment of the issuer_url variable

No worries, neither me nor Brian found it in our review. And I did not test it on my own before merging.

Copy link
Collaborator

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@JakobLichterfeld
Copy link
Collaborator

Successful tested backwards compatibility with ghcr.io/teslamate-org/teslamate:pr-3903

@JakobLichterfeld
Copy link
Collaborator

@jlestel please update with latest translations from main branch to make merging easier

@JakobLichterfeld JakobLichterfeld merged commit 4313409 into teslamate-org:master May 27, 2024
12 checks passed
@adampetrovic
Copy link

adampetrovic commented Jun 19, 2024

Is there any documentation associated with this change?

EDIT: nevermind, I see config variables showing up on here :) https://docs.teslamate.org/docs/configuration/environment_variables

@JakobLichterfeld
Copy link
Collaborator

Is there any documentation associated with this change?

#3959

@pkuehnel
Copy link

pkuehnel commented Jul 7, 2024

Is there any documentation on how the Fleet API Provider needs serve the Data? Also what is the protocol and how do the interfaces look so TeslaMate can consume Fleet Telemetry data?

@JakobLichterfeld
Copy link
Collaborator

Is there any documentation on how the Fleet API Provider needs serve the Data? Also what is the protocol and how do the interfaces look so TeslaMate can consume Fleet Telemetry data?

https://docs.teslamate.org/docs/guides/api

@pkuehnel
Copy link

What is the long-term goal for this? Will additional fields that are available with Fleet Telemetry be integrated in the future? Will it forever be with the 'faked' streaming API, or will there be another solution in the future? I am asking because, with TeslaSolarCharger I have highly Tesla Mate-connected software. Currently, I am hosting a fleet command proxy for all TSC users. I want to host a fleet telemetry server as well. As all the TSC users also use Tesla Mate, it would be cool if I could create a solution that works for Tesla Mate as well. But imitating the unofficial streaming API seems not to be the cleanest way to handle that issue in the long term.

@pkuehnel
Copy link

Is there anywhere a documentation how the old Streaming API transfers the data? Does TeslaMate work with getting Fleet Telemetry data only? Which data is required for TeslaMate to work?

@JakobLichterfeld
Copy link
Collaborator

Is there any documentation on how the Fleet API Provider needs serve the Data? Also what is the protocol and how do the interfaces look so TeslaMate can consume Fleet Telemetry data?

https://docs.teslamate.org/docs/guides/api

@pkuehnel
Copy link

@JakobLichterfeld Thanks, I already read that, my question is not answered there: How needs streaming Data to Look like so TeslaMate can consume it. I already have a Server getting data from fleet Telemetry but I do not know how the Websocket stream to TeslaMate needs to look like, to fake the old streaming API.

@jlestel
Copy link
Contributor Author

jlestel commented Oct 17, 2024

I didn't find any doc, I reengineered to do this: https://github.com/MyTeslaMate/websocket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tesla api Related to the Tesla API area:teslamate Related to TeslaMate core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants