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

Ability to use custom API endpoint #307

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

jlestel
Copy link

@jlestel jlestel commented Sep 30, 2024

As already discussed #255 #292 the official Tesla API will be the only way to send commands.

Using third-party Tesla API providers (or a self-hosted commands proxy) would allow command endpoints to be preserved.

I added an environment variable to allow users to choose their API provider.

@tobiasehlert tobiasehlert added enhancement New feature or request good first issue Good for newcomers go Pull requests that update Go code labels Oct 15, 2024
@tobiasehlert tobiasehlert self-requested a review October 15, 2024 20:03
Copy link

sonarcloud bot commented Oct 15, 2024

@tobiasehlert
Copy link
Owner

hi @jlestel,

Thanks for your pull request!

Just of curiosity, is this to be able to send the requests through MyTeslamate towards the Fleet API endpoint or what is the goal?
I'm considering either removing the commands section from TeslaMateAPI or yeah.. try to change it so that it can be used with the Fleet API directly (even though I don't use the commands endpoints anymore).

Kind regards,
Tobias

Copy link
Owner

@tobiasehlert tobiasehlert left a comment

Choose a reason for hiding this comment

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

Two things regarding this pull request, what do you think?

  1. I prefer use the same environment variable names as used in the TeslaMate project for reusability within the setup (pushed in 5b32d3e).
  2. Would be good to have some info-message at startup that says that the TESLA_API_HOST environment variable is set and therefore is overriding the API command calls.

Other than that it looks good to me :)

@@ -122,6 +122,7 @@ Basically the same environment variables for the database, mqqt and timezone nee
| **MQTT_PASSWORD** | string | |
| **MQTT_NAMESPACE** | string | |
| **MQTT_CLIENTID** | string | _4 char random string_ |
| **TESLA_API_URL** | string | _uses Owner API by default_ |
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
| **TESLA_API_URL** | string | _uses Owner API by default_ |
| **TESLA_API_HOST** | string | _uses Owner API by default_ |

@@ -112,9 +112,9 @@ func TeslaMateAPICarsCommandV1(c *gin.Context) {

switch getCarRegionAPI(TeslaAccessToken) {
case ChinaAPI:
TeslaEndpointUrl = "https://owner-api.vn.cloud.tesla.cn"
TeslaEndpointUrl = getEnv("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
TeslaEndpointUrl = getEnv("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn")
TeslaEndpointUrl = getEnv("TESLA_API_HOST", "https://owner-api.vn.cloud.tesla.cn")

default:
TeslaEndpointUrl = "https://owner-api.teslamotors.com"
TeslaEndpointUrl = getEnv("TESLA_API_URL", "https://owner-api.teslamotors.com")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
TeslaEndpointUrl = getEnv("TESLA_API_URL", "https://owner-api.teslamotors.com")
TeslaEndpointUrl = getEnv("TESLA_API_HOST", "https://owner-api.teslamotors.com")

@jlestel
Copy link
Author

jlestel commented Oct 17, 2024

Two things regarding this pull request, what do you think?

  1. I prefer use the same environment variable names as used in the TeslaMate project for reusability within the setup (pushed in 5b32d3e).
  2. Would be good to have some info-message at startup that says that the TESLA_API_HOST environment variable is set and therefore is overriding the API command calls.

Other than that it looks good to me :)

Agree on both bullets.

@jlestel
Copy link
Author

jlestel commented Oct 17, 2024

hi @jlestel,

Thanks for your pull request!

Just of curiosity, is this to be able to send the requests through MyTeslamate towards the Fleet API endpoint or what is the goal? I'm considering either removing the commands section from TeslaMateAPI or yeah.. try to change it so that it can be used with the Fleet API directly (even though I don't use the commands endpoints anymore).

Kind regards, Tobias

no I already send commands via myteslamate. the goal is rather to propose an oss mobile application for teslamate via teslamateapi.

so if it allows users who have their api command to use it to send commands with teslamateapi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants