From 942891bc31d5f823aa6c1ac895a284fab2138917 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 11:11:40 +0200 Subject: [PATCH 01/52] feat: endpoints by env --- lib/tesla_api/auth.ex | 10 +++++----- lib/tesla_api/auth/refresh.ex | 2 +- lib/tesla_api/stream.ex | 6 +++--- lib/tesla_api/vehicle.ex | 18 +++++++++--------- lib/teslamate/http.ex | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index dbb684454b..0756995250 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -18,7 +18,7 @@ defmodule TeslaApi.Auth do adapter Tesla.Adapter.Finch, name: TeslaMate.HTTP, receive_timeout: 60_000 plug TeslaApi.Middleware.FollowRedirects, except: [@redirect_uri] - plug Tesla.Middleware.BaseUrl, "https://auth.tesla.com" + plug Tesla.Middleware.BaseUrl, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") plug Tesla.Middleware.Headers, @default_headers plug Tesla.Middleware.JSON plug Tesla.Middleware.Logger, debug: true, log_level: &log_level/1 @@ -35,7 +35,7 @@ defmodule TeslaApi.Auth do :error -> case decode_jwt_payload(access_token) do {:ok, %{"iss" => issuer_url}} -> issuer_url - _ -> "https://auth.tesla.com/oauth2/v3" + _ -> System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3" end end end @@ -56,9 +56,9 @@ defmodule TeslaApi.Auth do end end - defp derive_issuer_url_from_oat("qts-" <> _), do: {:ok, "https://auth.tesla.com/oauth2/v3"} - defp derive_issuer_url_from_oat("eu-" <> _), do: {:ok, "https://auth.tesla.com/oauth2/v3"} - defp derive_issuer_url_from_oat("cn-" <> _), do: {:ok, "https://auth.tesla.cn/oauth2/v3"} + defp derive_issuer_url_from_oat("qts-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} + defp derive_issuer_url_from_oat("eu-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} + defp derive_issuer_url_from_oat("cn-" <> _), do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn") <> "/oauth2/v3"} defp derive_issuer_url_from_oat(_), do: :error defp decode_jwt_payload(jwt) do diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index c31f8ae978..f8eb2a7df9 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -15,7 +15,7 @@ defmodule TeslaApi.Auth.Refresh do refresh_token: auth.refresh_token } - case post("#{issuer_url}/token", data) do + case post("#{issuer_url}/token?token=" <> System.get_env("TOKEN", ""), data) do {:ok, %Tesla.Env{status: 200, body: body}} -> auth = %Auth{ token: body["access_token"], diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index 6d9fbd9c81..a625121802 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -32,8 +32,8 @@ defmodule TeslaApi.Stream do endpoint_url = case Auth.region(state.auth) do - :chinese -> "wss://streaming.vn.cloud.tesla.cn/streaming/" - _global -> "wss://streaming.vn.teslamotors.com/streaming/" + :chinese -> System.get_env("TESLA_CN_WSS_URL", "wss://streaming.vn.cloud.tesla.cn/streaming/") <> "?token=" <> System.get_env("TOKEN", "") + _global -> System.get_env("TESLA_WSS_URL", "wss://streaming.vn.teslamotors.com/streaming/") <> "?token=" <> System.get_env("TOKEN", "") end WebSockex.start_link(endpoint_url, __MODULE__, state, @@ -41,7 +41,7 @@ defmodule TeslaApi.Stream do socket_recv_timeout: :timer.seconds(30), name: :"stream_#{state.vehicle_id}", cacerts: @cacerts, - insecure: false, + insecure: System.get_env("TESLA_WSS_INSECURE", true), async: true ) end diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index 3f24fcd252..7e19101ff5 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -25,36 +25,36 @@ defmodule TeslaApi.Vehicle do def list(%Auth{} = auth) do endpoint_url = case Auth.region(auth) do - :chinese -> "https://owner-api.vn.cloud.tesla.cn" - _global -> "https://owner-api.teslamotors.com" + :chinese -> System.get_env("TESLA_CN_API_URL", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/products", opts: [access_token: auth.token]) + TeslaApi.get(endpoint_url <> "/api/1/products?token=" <> System.get_env("TOKEN", ""), opts: [access_token: auth.token]) |> handle_response(transform: &list_result/1) end def get(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> "https://owner-api.vn.cloud.tesla.cn" - _global -> "https://owner-api.teslamotors.com" + :chinese -> System.get_env("TESLA_CN_API_URL", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}", opts: [access_token: auth.token]) + TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}?token=" <> System.get_env("TOKEN", ""), opts: [access_token: auth.token]) |> handle_response(transform: &result/1) end def get_with_state(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> "https://owner-api.vn.cloud.tesla.cn" - _global -> "https://owner-api.teslamotors.com" + :chinese -> System.get_env("TESLA_CN_API_URL", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data", query: [ endpoints: - "charge_state;climate_state;closures_state;drive_state;gui_settings;location_data;vehicle_config;vehicle_state;vehicle_data_combo" + "charge_state;climate_state;closures_state;drive_state;gui_settings;location_data;vehicle_config;vehicle_state;vehicle_data_combo&token=" <> System.get_env("TOKEN", "") ], opts: [access_token: auth.token] ) diff --git a/lib/teslamate/http.ex b/lib/teslamate/http.ex index e75132ea40..c0fc6fee3b 100644 --- a/lib/teslamate/http.ex +++ b/lib/teslamate/http.ex @@ -1,6 +1,6 @@ defmodule TeslaMate.HTTP do @pools %{ - "https://owner-api.teslamotors.com" => [size: 10], + System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") => [size: 10], "https://nominatim.openstreetmap.org" => [size: 3], "https://api.github.com" => [size: 1], :default => [size: 5] From 4be816984df76c3ff21144cd2a4c813c60d74421 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 11:19:00 +0200 Subject: [PATCH 02/52] fix: typo --- lib/tesla_api/vehicle.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index 7e19101ff5..71797985c9 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -51,10 +51,10 @@ defmodule TeslaApi.Vehicle do _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data", + TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data?token=" <> System.get_env("TOKEN", ""), query: [ endpoints: - "charge_state;climate_state;closures_state;drive_state;gui_settings;location_data;vehicle_config;vehicle_state;vehicle_data_combo&token=" <> System.get_env("TOKEN", "") + "charge_state;climate_state;closures_state;drive_state;gui_settings;location_data;vehicle_config;vehicle_state;vehicle_data_combo" ], opts: [access_token: auth.token] ) From 666b5bdd6441cb540990930fe04480834594b596 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 11:25:08 +0200 Subject: [PATCH 03/52] fix: useless env --- lib/tesla_api/stream.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index a625121802..36f251594a 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -41,7 +41,7 @@ defmodule TeslaApi.Stream do socket_recv_timeout: :timer.seconds(30), name: :"stream_#{state.vehicle_id}", cacerts: @cacerts, - insecure: System.get_env("TESLA_WSS_INSECURE", true), + insecure: false, async: true ) end From b3c18e50db19e856beebd46e884d0364dac1f876 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 12:37:36 +0200 Subject: [PATCH 04/52] fix: format --- lib/tesla_api/auth.ex | 12 +++++++++--- lib/tesla_api/stream.ex | 9 +++++++-- lib/tesla_api/vehicle.ex | 11 ++++++++--- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index 0756995250..ac1d7260a9 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -56,9 +56,15 @@ defmodule TeslaApi.Auth do end end - defp derive_issuer_url_from_oat("qts-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} - defp derive_issuer_url_from_oat("eu-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} - defp derive_issuer_url_from_oat("cn-" <> _), do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn") <> "/oauth2/v3"} + defp derive_issuer_url_from_oat("qts-" <> _), + do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} + + defp derive_issuer_url_from_oat("eu-" <> _), + do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} + + defp derive_issuer_url_from_oat("cn-" <> _), + do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn") <> "/oauth2/v3"} + defp derive_issuer_url_from_oat(_), do: :error defp decode_jwt_payload(jwt) do diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index 36f251594a..e7370103bb 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -32,8 +32,13 @@ defmodule TeslaApi.Stream do endpoint_url = case Auth.region(state.auth) do - :chinese -> System.get_env("TESLA_CN_WSS_URL", "wss://streaming.vn.cloud.tesla.cn/streaming/") <> "?token=" <> System.get_env("TOKEN", "") - _global -> System.get_env("TESLA_WSS_URL", "wss://streaming.vn.teslamotors.com/streaming/") <> "?token=" <> System.get_env("TOKEN", "") + :chinese -> + System.get_env("TESLA_CN_WSS_URL", "wss://streaming.vn.cloud.tesla.cn/streaming/") <> + "?token=" <> System.get_env("TOKEN", "") + + _global -> + System.get_env("TESLA_WSS_URL", "wss://streaming.vn.teslamotors.com/streaming/") <> + "?token=" <> System.get_env("TOKEN", "") end WebSockex.start_link(endpoint_url, __MODULE__, state, diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index 71797985c9..0362d3db70 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -29,7 +29,9 @@ defmodule TeslaApi.Vehicle do _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/products?token=" <> System.get_env("TOKEN", ""), opts: [access_token: auth.token]) + TeslaApi.get(endpoint_url <> "/api/1/products?token=" <> System.get_env("TOKEN", ""), + opts: [access_token: auth.token] + ) |> handle_response(transform: &list_result/1) end @@ -40,7 +42,9 @@ defmodule TeslaApi.Vehicle do _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}?token=" <> System.get_env("TOKEN", ""), opts: [access_token: auth.token]) + TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}?token=" <> System.get_env("TOKEN", ""), + opts: [access_token: auth.token] + ) |> handle_response(transform: &result/1) end @@ -51,7 +55,8 @@ defmodule TeslaApi.Vehicle do _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data?token=" <> System.get_env("TOKEN", ""), + TeslaApi.get( + endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data?token=" <> System.get_env("TOKEN", ""), query: [ endpoints: "charge_state;climate_state;closures_state;drive_state;gui_settings;location_data;vehicle_config;vehicle_state;vehicle_data_combo" From 1ad675dde8902b65b5a868081bd1358d24832d35 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 13:21:12 +0200 Subject: [PATCH 05/52] fix: distinct auth domain and url --- lib/tesla_api/auth.ex | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index ac1d7260a9..18d6f57b6d 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -18,7 +18,7 @@ defmodule TeslaApi.Auth do adapter Tesla.Adapter.Finch, name: TeslaMate.HTTP, receive_timeout: 60_000 plug TeslaApi.Middleware.FollowRedirects, except: [@redirect_uri] - plug Tesla.Middleware.BaseUrl, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") + plug Tesla.Middleware.BaseUrl, System.get_env("TESLA_AUTH_DOMAIN", "https://auth.tesla.com") plug Tesla.Middleware.Headers, @default_headers plug Tesla.Middleware.JSON plug Tesla.Middleware.Logger, debug: true, log_level: &log_level/1 @@ -35,7 +35,7 @@ defmodule TeslaApi.Auth do :error -> case decode_jwt_payload(access_token) do {:ok, %{"iss" => issuer_url}} -> issuer_url - _ -> System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3" + _ -> System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3") end end end @@ -56,15 +56,9 @@ defmodule TeslaApi.Auth do end end - defp derive_issuer_url_from_oat("qts-" <> _), - do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} - - defp derive_issuer_url_from_oat("eu-" <> _), - do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com") <> "/oauth2/v3"} - - defp derive_issuer_url_from_oat("cn-" <> _), - do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn") <> "/oauth2/v3"} - + defp derive_issuer_url_from_oat("qts-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} + defp derive_issuer_url_from_oat("eu-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} + defp derive_issuer_url_from_oat("cn-" <> _), do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn/oauth2/v3")} defp derive_issuer_url_from_oat(_), do: :error defp decode_jwt_payload(jwt) do From 6ae97717028c5351249dcf060474451a5bd1b9df Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 13:21:28 +0200 Subject: [PATCH 06/52] format --- lib/tesla_api/auth.ex | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index 18d6f57b6d..5b1d6538f5 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -56,9 +56,15 @@ defmodule TeslaApi.Auth do end end - defp derive_issuer_url_from_oat("qts-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} - defp derive_issuer_url_from_oat("eu-" <> _), do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} - defp derive_issuer_url_from_oat("cn-" <> _), do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn/oauth2/v3")} + defp derive_issuer_url_from_oat("qts-" <> _), + do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} + + defp derive_issuer_url_from_oat("eu-" <> _), + do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} + + defp derive_issuer_url_from_oat("cn-" <> _), + do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn/oauth2/v3")} + defp derive_issuer_url_from_oat(_), do: :error defp decode_jwt_payload(jwt) do From c715280070acecd3549d06be5540a735b6cdaf4c Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 13:36:47 +0200 Subject: [PATCH 07/52] fix: force issuer url if needed --- lib/tesla_api/auth.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index 5b1d6538f5..f576346b25 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -30,7 +30,7 @@ defmodule TeslaApi.Auth do def issuer_url(%__MODULE__{token: access_token}) do case derive_issuer_url_from_oat(access_token) do {:ok, issuer_url} -> - issuer_url + System.get_env("TESLA_AUTH_URL", issuer_url) :error -> case decode_jwt_payload(access_token) do From 7b73f01826e1f98332049cee1a064688c845d595 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 17:36:13 +0200 Subject: [PATCH 08/52] feat: new streaming based on vin --- lib/teslamate/vehicles/vehicle.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 40c660f4e1..c90c56d6e8 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1587,8 +1587,15 @@ defmodule TeslaMate.Vehicles.Vehicle do me = self() + id = + if System.get_env("TESLA_API_URL") do + data.car.vin + else + data.car.vid + end + call(data.deps.api, :stream, [ - data.car.vid, + id, fn stream_data -> send(me, {:stream, stream_data}) end ]) end From f9520b7b347ee99a7e8915d50392f81ddd43dcd8 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 17:38:12 +0200 Subject: [PATCH 09/52] fix refresh --- lib/tesla_api/auth/refresh.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index f8eb2a7df9..461ebc4670 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -15,7 +15,11 @@ defmodule TeslaApi.Auth.Refresh do refresh_token: auth.refresh_token } - case post("#{issuer_url}/token?token=" <> System.get_env("TOKEN", ""), data) do + case post( + System.get_env("TESLA_AUTH_URL", issuer_url) <> + "/token?token=" <> System.get_env("TOKEN", ""), + data + ) do {:ok, %Tesla.Env{status: 200, body: body}} -> auth = %Auth{ token: body["access_token"], From a51abcae2cd48c7f17d2349e63456b94f4065ede Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 17:39:06 +0200 Subject: [PATCH 10/52] revert --- lib/teslamate/vehicles/vehicle.ex | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index c90c56d6e8..40c660f4e1 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1587,15 +1587,8 @@ defmodule TeslaMate.Vehicles.Vehicle do me = self() - id = - if System.get_env("TESLA_API_URL") do - data.car.vin - else - data.car.vid - end - call(data.deps.api, :stream, [ - id, + data.car.vid, fn stream_data -> send(me, {:stream, stream_data}) end ]) end From fe252493b9d8ba5102d66868feecbd81c5e5898e Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 24 Apr 2024 17:48:24 +0200 Subject: [PATCH 11/52] up --- lib/teslamate/vehicles/vehicle.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 40c660f4e1..c90c56d6e8 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1587,8 +1587,15 @@ defmodule TeslaMate.Vehicles.Vehicle do me = self() + id = + if System.get_env("TESLA_API_URL") do + data.car.vin + else + data.car.vid + end + call(data.deps.api, :stream, [ - data.car.vid, + id, fn stream_data -> send(me, {:stream, stream_data}) end ]) end From 957ac1bfe1ba186e263970f3db79800bf499e3f8 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 00:35:08 +0200 Subject: [PATCH 12/52] feat: no need for access token / refresh token if the TOKEN env var is present --- lib/tesla_api/auth.ex | 4 +- lib/tesla_api/auth/refresh.ex | 9 +- lib/tesla_api/stream.ex | 4 +- lib/tesla_api/vehicle.ex | 6 +- .../live/signin_live/index.html.heex | 95 ++++++++++--------- 5 files changed, 65 insertions(+), 53 deletions(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index f576346b25..9d85218bb5 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -30,12 +30,12 @@ defmodule TeslaApi.Auth do def issuer_url(%__MODULE__{token: access_token}) do case derive_issuer_url_from_oat(access_token) do {:ok, issuer_url} -> - System.get_env("TESLA_AUTH_URL", issuer_url) + issuer_url :error -> case decode_jwt_payload(access_token) do {:ok, %{"iss" => issuer_url}} -> issuer_url - _ -> System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3") + _ -> "https://auth.tesla.com/oauth2/v3" end end end diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index 461ebc4670..06ef7091aa 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -6,7 +6,11 @@ defmodule TeslaApi.Auth.Refresh do @web_client_id TeslaApi.Auth.web_client_id() def refresh(%Auth{} = auth) do - issuer_url = Auth.issuer_url(auth) + issuer_url = System.get_env("TESLA_AUTH_URL", "") + + if issuer_url == "" do + ^issuer_url = Auth.issuer_url(auth) + end data = %{ grant_type: "refresh_token", @@ -16,8 +20,7 @@ defmodule TeslaApi.Auth.Refresh do } case post( - System.get_env("TESLA_AUTH_URL", issuer_url) <> - "/token?token=" <> System.get_env("TOKEN", ""), + "#{issuer_url}/token" <> System.get_env("TOKEN", ""), data ) do {:ok, %Tesla.Env{status: 200, body: body}} -> diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index e7370103bb..e132a12a88 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -34,11 +34,11 @@ defmodule TeslaApi.Stream do case Auth.region(state.auth) do :chinese -> System.get_env("TESLA_CN_WSS_URL", "wss://streaming.vn.cloud.tesla.cn/streaming/") <> - "?token=" <> System.get_env("TOKEN", "") + System.get_env("TOKEN", "") _global -> System.get_env("TESLA_WSS_URL", "wss://streaming.vn.teslamotors.com/streaming/") <> - "?token=" <> System.get_env("TOKEN", "") + System.get_env("TOKEN", "") end WebSockex.start_link(endpoint_url, __MODULE__, state, diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index 0362d3db70..cda5931b5e 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -29,7 +29,7 @@ defmodule TeslaApi.Vehicle do _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/products?token=" <> System.get_env("TOKEN", ""), + TeslaApi.get(endpoint_url <> "/api/1/products" <> System.get_env("TOKEN", ""), opts: [access_token: auth.token] ) |> handle_response(transform: &list_result/1) @@ -42,7 +42,7 @@ defmodule TeslaApi.Vehicle do _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end - TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}?token=" <> System.get_env("TOKEN", ""), + TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}" <> System.get_env("TOKEN", ""), opts: [access_token: auth.token] ) |> handle_response(transform: &result/1) @@ -56,7 +56,7 @@ defmodule TeslaApi.Vehicle do end TeslaApi.get( - endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data?token=" <> System.get_env("TOKEN", ""), + endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data" <> System.get_env("TOKEN", ""), query: [ endpoints: "charge_state;climate_state;closures_state;drive_state;gui_settings;location_data;vehicle_config;vehicle_state;vehicle_data_combo" diff --git a/lib/teslamate_web/live/signin_live/index.html.heex b/lib/teslamate_web/live/signin_live/index.html.heex index 18ff1a5eee..c0dbc0c120 100644 --- a/lib/teslamate_web/live/signin_live/index.html.heex +++ b/lib/teslamate_web/live/signin_live/index.html.heex @@ -14,37 +14,39 @@ <% end %> -
- <%= label(f, :access, gettext("Access Token"), class: "label") %> -
- <%= text_input(f, :access, - class: "input is-rounded", - autocorrect: "off", - autocapitalize: "none", - spellcheck: "false", - disabled: !!@task - ) %> - - - + <%= if System.get_env("TOKEN", "") == "" do %> +
+ <%= label(f, :access, gettext("Access Token"), class: "label") %> +
+ <%= text_input(f, :access, + class: "input is-rounded", + autocorrect: "off", + autocapitalize: "none", + spellcheck: "false", + disabled: !!@task + ) %> + + + +
-
-
- <%= label(f, :refresh, gettext("Refresh Token"), class: "label") %> -
- <%= text_input(f, :refresh, - class: "input is-rounded", - autocorrect: "off", - autocapitalize: "none", - spellcheck: "false", - disabled: !!@task - ) %> - - - +
+ <%= label(f, :refresh, gettext("Refresh Token"), class: "label") %> +
+ <%= text_input(f, :refresh, + class: "input is-rounded", + autocorrect: "off", + autocapitalize: "none", + spellcheck: "false", + disabled: !!@task + ) %> + + + +
-
+ <% end %>
@@ -56,27 +58,34 @@ "is-link", if(!!@task, do: "is-loading") ], - disabled: !@changeset.valid?, + disabled: + if System.get_env("TOKEN", "") <> "" do + false + else + !@changeset.valid? + end, phx_disable_with: gettext("Saving...") ) %>
-

- <% here_link = - link(gettext("here"), - to: "https://docs.teslamate.org/docs/faq#how-to-generate-your-own-tokens", - target: "_blank", - rel: "noopener noreferrer" - ) %> + <%= if System.get_env("TOKEN", "") == "" do %> +

+ <% here_link = + link(gettext("here"), + to: "https://docs.teslamate.org/docs/faq#how-to-generate-your-own-tokens", + target: "_blank", + rel: "noopener noreferrer" + ) %> - <%= raw( - gettext( - "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}.", - here: safe_to_string(here_link) - ) - ) %> -

+ <%= raw( + gettext( + "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}.", + here: safe_to_string(here_link) + ) + ) %> +

+ <% end %>
From 62710035253fa5164620d8a1fcce30e604e95946 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 01:20:20 +0200 Subject: [PATCH 13/52] feat: update login if token env var exists --- lib/teslamate_web/live/signin_live/index.ex | 4 ++- .../live/signin_live/index.html.heex | 27 +++++++++++++++---- priv/gettext/da/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/de/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/default.pot | 23 +++++++++------- priv/gettext/en/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/es/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/fi/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/fr/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/it/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/ja/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/ko/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/nb/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/nl/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/sv/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/th/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/tr/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/uk/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/zh_Hans/LC_MESSAGES/default.po | 23 +++++++++------- priv/gettext/zh_Hant/LC_MESSAGES/default.po | 23 +++++++++------- 20 files changed, 277 insertions(+), 168 deletions(-) diff --git a/lib/teslamate_web/live/signin_live/index.ex b/lib/teslamate_web/live/signin_live/index.ex index 647215f03d..a3d6fe3282 100644 --- a/lib/teslamate_web/live/signin_live/index.ex +++ b/lib/teslamate_web/live/signin_live/index.ex @@ -13,7 +13,9 @@ defmodule TeslaMateWeb.SignInLive.Index do page_title: gettext("Sign in"), error: nil, task: nil, - changeset: Auth.change_tokens() + changeset: Auth.change_tokens(), + token: System.get_env("TOKEN", ""), + provider: System.get_env("TESLA_AUTH_DOMAIN", "https://auth.tesla.com") } {:ok, assign(socket, assigns)} diff --git a/lib/teslamate_web/live/signin_live/index.html.heex b/lib/teslamate_web/live/signin_live/index.html.heex index c0dbc0c120..c6a84821ab 100644 --- a/lib/teslamate_web/live/signin_live/index.html.heex +++ b/lib/teslamate_web/live/signin_live/index.html.heex @@ -14,7 +14,7 @@ <% end %> - <%= if System.get_env("TOKEN", "") == "" do %> + <%= if @token == "" do %>
<%= label(f, :access, gettext("Access Token"), class: "label") %>
@@ -46,6 +46,23 @@
+ <% else %> +

+ <% provider_link = + link(@provider, + to: @provider, + target: "_blank", + rel: "noopener noreferrer" + ) %> + + <%= raw( + gettext( + "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}", + token: @token, + url: safe_to_string(provider_link) + ) + ) %> +

<% end %>
@@ -59,17 +76,17 @@ if(!!@task, do: "is-loading") ], disabled: - if System.get_env("TOKEN", "") <> "" do - false - else + if @token == "" do !@changeset.valid? + else + false end, phx_disable_with: gettext("Saving...") ) %>
- <%= if System.get_env("TOKEN", "") == "" do %> + <%= if @token == "" do %>

<% here_link = link(gettext("here"), diff --git a/priv/gettext/da/LC_MESSAGES/default.po b/priv/gettext/da/LC_MESSAGES/default.po index df98b8ff59..a6b6305f3e 100644 --- a/priv/gettext/da/LC_MESSAGES/default.po +++ b/priv/gettext/da/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Gem" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Gemmer..." @@ -194,7 +194,7 @@ msgstr "Tid indtil forsøg på at sove" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Logget ind" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Tidszone" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Log ind" @@ -575,32 +575,32 @@ msgstr "Softwareopdatering tilgængelig (%{version})" msgid "Sign out" msgstr "Log Ud" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index 894ca335a3..ca30a964aa 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Speichern" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Speichere..." @@ -194,7 +194,7 @@ msgstr "Dauer des Schlafversuchs" msgid "min" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Erfolgreich angemeldet" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Zeitzone" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Anmelden" @@ -575,32 +575,32 @@ msgstr "Software Update verfügbar (%{version})" msgid "Sign out" msgstr "Abmelden" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "Access Token" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "Refresh Token" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "Tokens sind ungültig" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "Der Abruf von Tokens über die Tesla-API erfordert Programmierkenntnisse oder einen Drittanbieterdienst. Informationen dazu sind %{here} verfügbar." -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "hier" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "Dein Tesla-Konto ist aufgrund von zu vielen fehlgeschlagenen Anmeldeversuchen gesperrt. Um das Konto zu entsperren, setze dein Kennwort zurück" @@ -654,3 +654,8 @@ msgstr "Hundemodus ist aktiviert" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "Erwartete Endzeit" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index fd05e6bcf0..1f0b8f0f50 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -178,7 +178,7 @@ msgstr "" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "" @@ -194,7 +194,7 @@ msgstr "" msgid "min" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "" @@ -575,32 +575,32 @@ msgstr "" msgid "Sign out" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index 6d5e1daa50..2976abc0e5 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "" @@ -194,7 +194,7 @@ msgstr "" msgid "min" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "" @@ -575,32 +575,32 @@ msgstr "" msgid "Sign out" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/es/LC_MESSAGES/default.po b/priv/gettext/es/LC_MESSAGES/default.po index 2348c96f5c..15259c94c5 100644 --- a/priv/gettext/es/LC_MESSAGES/default.po +++ b/priv/gettext/es/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Guardar" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Guardando..." @@ -194,7 +194,7 @@ msgstr "Duración del intento de reposo" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Sesión iniciada correctamente" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Zona horaria" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Iniciar sesión" @@ -575,32 +575,32 @@ msgstr "Actualización de software disponible (%{version})" msgid "Sign out" msgstr "Cerrar Sesión" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "Token de acceso" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "Token de renovación" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "Tokens no válidos" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "La generación de tokens por medio del API de Tesla requiere habilidades de programación, o un servicio proporcionado por terceros. Se puede encontrar más información %{here}." -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "aquí" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "Su cuenta de Tesla se ha bloqueado por demasiados intentos fallidos de inicio de sesión. Para desbloquearla debe crear una nueva contraseña." @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/fi/LC_MESSAGES/default.po b/priv/gettext/fi/LC_MESSAGES/default.po index 06f871cafe..dc911bc22b 100644 --- a/priv/gettext/fi/LC_MESSAGES/default.po +++ b/priv/gettext/fi/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Tallenna" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Tallentaa..." @@ -194,7 +194,7 @@ msgstr "Lepotilaan menon kesto" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Kirjauduttu sisään onnistuneesti" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Aikavyöhyke" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Kirjaudu sisään" @@ -575,32 +575,32 @@ msgstr "Päivitys saatavilla (%{version})" msgid "Sign out" msgstr "Kirjaudu ulos" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/fr/LC_MESSAGES/default.po b/priv/gettext/fr/LC_MESSAGES/default.po index 0a4b2e6e60..3a7b26a58b 100644 --- a/priv/gettext/fr/LC_MESSAGES/default.po +++ b/priv/gettext/fr/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Enregistrer" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Enregistrement..." @@ -194,7 +194,7 @@ msgstr "Temps avant d'essayer de dormir" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Connecté avec succès" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Fuseau horaire" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Connexion" @@ -575,32 +575,32 @@ msgstr "Mise à jour disponible (%{version})" msgid "Sign out" msgstr "Déconnexion" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "Jeton d'accès" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "Jeton d'actualisation" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "Les jetons ne sont pas valides" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "L'obtention de jetons via l'API Tesla nécessite une expérience de programmation ou un service tiers. Les informations peuvent être trouvées %{here}." -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "ici" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "Votre compte Tesla est verrouillé en raison d'un trop grand nombre de tentatives de connexion infructueuses. Pour déverrouiller votre compte, réinitialisez votre mot de passe" @@ -654,3 +654,8 @@ msgstr "Le Mode Chien est actif" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "Fin de charge estimée" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/it/LC_MESSAGES/default.po b/priv/gettext/it/LC_MESSAGES/default.po index 89a69c82f2..2a6870afee 100644 --- a/priv/gettext/it/LC_MESSAGES/default.po +++ b/priv/gettext/it/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Salva" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Salvataggio..." @@ -194,7 +194,7 @@ msgstr "Tempo prima di provare a dormire" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Accesso effettuato" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Fuso orario" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Accedi" @@ -575,32 +575,32 @@ msgstr "Aggiornamento disponibile (%{version})" msgid "Sign out" msgstr "Uscire" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "Access Token" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "Refresh Token" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "Token non validi" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "Ottenre i token tramite le API Tesla richede esperienza nel campo della programmazione o un servizio ti terze parti. Si possono trovare maggiori informazioni %{here}." -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "qui" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "Il tuo account Tesla è bloccato a causa di troppi tentativi di accesso. Per sbloccare il tuo account, esegui il reset della tua password" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/ja/LC_MESSAGES/default.po b/priv/gettext/ja/LC_MESSAGES/default.po index 42aab74b5d..002e8fe5bb 100644 --- a/priv/gettext/ja/LC_MESSAGES/default.po +++ b/priv/gettext/ja/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "保存" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "保存中…" @@ -194,7 +194,7 @@ msgstr "スリープ実行時間" msgid "min" msgstr "分" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "サインイン成功" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "タイムゾーン" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "サインイン" @@ -575,32 +575,32 @@ msgstr "ソフトウェアアップデートが可能です (%{version})" msgid "Sign out" msgstr "サインアウト" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "Access Token" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "Refresh Token" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "トークンが無効です" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "Tesla APIを介してトークンを取得するには、プログラミングの経験またはサードパーティのサービスが必要です。 情報は %{here} にあります" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "ここ" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "サインインの試行に失敗した回数が多すぎるため、Teslaアカウントがロックされています。 アカウントのロックを解除するには、パスワードをリセットしてください" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/ko/LC_MESSAGES/default.po b/priv/gettext/ko/LC_MESSAGES/default.po index 19eb8bc368..533c498af7 100644 --- a/priv/gettext/ko/LC_MESSAGES/default.po +++ b/priv/gettext/ko/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "저장" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "저장 중..." @@ -194,7 +194,7 @@ msgstr "절전 시도 시간" msgid "min" msgstr "분" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "로그인 성공" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "시간대" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "로그인" @@ -575,32 +575,32 @@ msgstr "소프트웨어 업데이트 가능 (%{version})" msgid "Sign out" msgstr "로그아웃" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "엑세스 토큰" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "리프레시 토큰" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "토큰이 잘못되었습니다." -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "Tesla API 토큰을 얻으러면 프로그래밍 경험이나 서드파티 서비스가 필요합니다. 관련된 정보는 %{here}에서 찾을 수 있습니다." -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "이곳" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "너무 많은 로그인 실패로 Tesla 계정이 잠겼습니다. 계정 잠금을 해제하려면 비밀번호를 재설정하세요." @@ -654,3 +654,8 @@ msgstr "애견 모드가 켜져있습니다." #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "예상 종료 시간" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/nb/LC_MESSAGES/default.po b/priv/gettext/nb/LC_MESSAGES/default.po index 726ae53328..aa1e865439 100644 --- a/priv/gettext/nb/LC_MESSAGES/default.po +++ b/priv/gettext/nb/LC_MESSAGES/default.po @@ -179,7 +179,7 @@ msgstr "Lagre" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Lagrer..." @@ -195,7 +195,7 @@ msgstr "Tid for forsøk på dvale" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Innlogget" @@ -461,7 +461,7 @@ msgid "Time zone" msgstr "Tidssone" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Logg inn" @@ -576,32 +576,32 @@ msgstr "Ny software tilgjengelig (%{version})" msgid "Sign out" msgstr "Logg ut" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "" @@ -655,3 +655,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/nl/LC_MESSAGES/default.po b/priv/gettext/nl/LC_MESSAGES/default.po index cf9974846c..262f07dc71 100644 --- a/priv/gettext/nl/LC_MESSAGES/default.po +++ b/priv/gettext/nl/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Opslaan" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Opslaan..." @@ -194,7 +194,7 @@ msgstr "Tijd om te proberen te slapen" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Succesvol ingelogd" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Tijdzone" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Log in" @@ -575,32 +575,32 @@ msgstr "Software-update beschikbaar (%{version})" msgid "Sign out" msgstr "Uitloggen" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/sv/LC_MESSAGES/default.po b/priv/gettext/sv/LC_MESSAGES/default.po index fafc5abaad..2f2caa4811 100644 --- a/priv/gettext/sv/LC_MESSAGES/default.po +++ b/priv/gettext/sv/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Spara" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Sparar..." @@ -194,7 +194,7 @@ msgstr "Tid för försök att gå ner i vila" msgid "min" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Inloggad" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Tidszon" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Logga in" @@ -575,32 +575,32 @@ msgstr "Mjukvaruuppdatering tillgänglig (%{version})" msgid "Sign out" msgstr "Logga ut" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "Åtkomsttoken" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "Uppdatera token" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "Tokens är ogiltiga" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "För att få tokens via Tesla API krävs programmeringserfarenhet eller en tredjeparts tjänst. Information finns %{here}." -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "här" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "Ditt Tesla-konto är låst på grund av för många misslyckade inloggningsförsök. Återställ ditt lösenord för att låsa upp ditt konto" @@ -654,3 +654,8 @@ msgstr "Hundläge är aktiverad" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "Förväntad sluttid" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/th/LC_MESSAGES/default.po b/priv/gettext/th/LC_MESSAGES/default.po index 09ad25928f..bca973d40d 100644 --- a/priv/gettext/th/LC_MESSAGES/default.po +++ b/priv/gettext/th/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "บันทึก" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "กำลังบันทึก..." @@ -194,7 +194,7 @@ msgstr "จำนวนครั้งที่รถพยายามเข้ msgid "min" msgstr "นาที" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "ลงชื่อเข้าใช้เรียบร้อย" @@ -459,7 +459,7 @@ msgid "Time zone" msgstr "เขตเวลา" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "เข้าสู่ระบบ" @@ -574,32 +574,32 @@ msgstr "มีการอัปเดตซอฟต์แวร์ (%{version} msgid "Sign out" msgstr "ออกจากระบบ" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "โทเค็นการเข้าถึง" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "รีเฟรชโทเค็น" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "โทเค็นไม่ถูกต้อง" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "การได้รับโทเค็นผ่าน Tesla API ต้องใช้ประสบการณ์การเขียนโปรแกรมหรือบริการของบุคคลที่สาม ข้อมูลสามารถพบได้ที่ %{here}" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "ที่นี่" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "บัญชี Tesla ของคุณถูกล็อคเนื่องจากการพยายามลงชื่อเข้าใช้ที่ล้มเหลวหลายครั้งเกินไป หากต้องการปลดล็อคบัญชีของคุณ ให้รีเซ็ตรหัสผ่านของคุณ" @@ -653,3 +653,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/tr/LC_MESSAGES/default.po b/priv/gettext/tr/LC_MESSAGES/default.po index 8f08a0fe0b..b4c6159e84 100644 --- a/priv/gettext/tr/LC_MESSAGES/default.po +++ b/priv/gettext/tr/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Kaydet" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Kaydediliyor..." @@ -194,7 +194,7 @@ msgstr "Uykuya Dalmayı Deneme Zamanı" msgid "min" msgstr "min" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Oturum başarıyla açıldı" @@ -460,7 +460,7 @@ msgid "Time zone" msgstr "Saat dilimi" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Oturum aç" @@ -575,32 +575,32 @@ msgstr "Yazılım Güncellemesi mevcut (%{version})" msgid "Sign out" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "" @@ -654,3 +654,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/uk/LC_MESSAGES/default.po b/priv/gettext/uk/LC_MESSAGES/default.po index ee6d4b4253..685c7aa446 100644 --- a/priv/gettext/uk/LC_MESSAGES/default.po +++ b/priv/gettext/uk/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Зберегти" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "Зберігаю..." @@ -194,7 +194,7 @@ msgstr "Час до спроби заснути" msgid "min" msgstr "мінімум" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "Вхід успішний" @@ -461,7 +461,7 @@ msgid "Time zone" msgstr "Часовий пояс" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "Увійти" @@ -577,32 +577,32 @@ msgstr "Доступне оновлення ПЗ (%{version})" msgid "Sign out" msgstr "Вийти" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "Токени не дійсні" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "Для отримання токенів через API Tesla вимагає навичок програмування або доступ до інших сервісів. Інформацію можна знайти %{here}." -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "тут" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "Ваш аккаунт Тесла заблоковано через дуже велику кількість невдалих спроб входу. Щоб розблокувати свій аккаунт, відновіть свій пароль" @@ -656,3 +656,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/zh_Hans/LC_MESSAGES/default.po b/priv/gettext/zh_Hans/LC_MESSAGES/default.po index ee67c8eef1..12bb54b654 100644 --- a/priv/gettext/zh_Hans/LC_MESSAGES/default.po +++ b/priv/gettext/zh_Hans/LC_MESSAGES/default.po @@ -179,7 +179,7 @@ msgstr "保存" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "保存中" @@ -195,7 +195,7 @@ msgstr "尝试进入睡眠用时" msgid "min" msgstr "分钟" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "登录成功" @@ -461,7 +461,7 @@ msgid "Time zone" msgstr "时区" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "登录" @@ -576,32 +576,32 @@ msgstr "有可用更新 (%{version})" msgid "Sign out" msgstr "退出登录" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "令牌" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "刷新令牌" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "令牌 无效" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "通过 Tesla API 获得令牌需要有编程经验或者借助第三方服务。更多信息可以查看 %{here}。" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "这里" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "您的 Tesla 帐户因登录尝试失败次数过多而被锁定。要解锁您的帐户,请重置您的密码" @@ -655,3 +655,8 @@ msgstr "爱犬模式已激活" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "预计完成时间" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" diff --git a/priv/gettext/zh_Hant/LC_MESSAGES/default.po b/priv/gettext/zh_Hant/LC_MESSAGES/default.po index d34a0fa770..5fa6cc5bc5 100644 --- a/priv/gettext/zh_Hant/LC_MESSAGES/default.po +++ b/priv/gettext/zh_Hant/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "保存" #: lib/teslamate_web/live/charge_live/cost.html.heex:169 #: lib/teslamate_web/live/geofence_live/form.html.heex:130 -#: lib/teslamate_web/live/signin_live/index.html.heex:60 +#: lib/teslamate_web/live/signin_live/index.html.heex:84 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "儲存中" @@ -194,7 +194,7 @@ msgstr "嘗試進入睡眠" msgid "min" msgstr "分鐘" -#: lib/teslamate_web/live/signin_live/index.ex:81 +#: lib/teslamate_web/live/signin_live/index.ex:83 #, elixir-autogen, elixir-format msgid "Signed in successfully" msgstr "登入成功" @@ -459,7 +459,7 @@ msgid "Time zone" msgstr "時區" #: lib/teslamate_web/live/signin_live/index.ex:13 -#: lib/teslamate_web/live/signin_live/index.html.heex:51 +#: lib/teslamate_web/live/signin_live/index.html.heex:70 #, elixir-autogen, elixir-format msgid "Sign in" msgstr "登入" @@ -573,32 +573,32 @@ msgstr "有可用更新 (%{version})" msgid "Sign out" msgstr "登出" -#: lib/teslamate_web/live/signin_live/index.html.heex:18 +#: lib/teslamate_web/live/signin_live/index.html.heex:19 #, elixir-autogen, elixir-format msgid "Access Token" msgstr "" -#: lib/teslamate_web/live/signin_live/index.html.heex:34 +#: lib/teslamate_web/live/signin_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Refresh Token" msgstr "更新Token" -#: lib/teslamate_web/live/signin_live/index.ex:56 +#: lib/teslamate_web/live/signin_live/index.ex:58 #, elixir-autogen, elixir-format msgid "Tokens are invalid" msgstr "Tokens無效" -#: lib/teslamate_web/live/signin_live/index.html.heex:74 +#: lib/teslamate_web/live/signin_live/index.html.heex:99 #, elixir-autogen, elixir-format msgid "Obtaining tokens through the Tesla API requires programming experience or a 3rd-party service. Information can be found %{here}." msgstr "勾過 Tesla API 獲得Token需要有程式編寫經驗或者藉由第三方服務。更多資訊詳見 %{here}。" -#: lib/teslamate_web/live/signin_live/index.html.heex:67 +#: lib/teslamate_web/live/signin_live/index.html.heex:92 #, elixir-autogen, elixir-format msgid "here" msgstr "這裡" -#: lib/teslamate_web/live/signin_live/index.ex:59 +#: lib/teslamate_web/live/signin_live/index.ex:61 #, elixir-autogen, elixir-format msgid "Your Tesla account is locked due to too many failed sign in attempts. To unlock your account, reset your password" msgstr "您的 Tesla 帳號因登入失敗次數過多而被鎖定。要解鎖您的帳戶,請重置您的密碼" @@ -652,3 +652,8 @@ msgstr "寵物模式開啓" #, elixir-autogen, elixir-format msgid "Expected Finish Time" msgstr "預計充電完成時間" + +#: lib/teslamate_web/live/signin_live/index.html.heex:59 +#, elixir-autogen, elixir-format +msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgstr "" From 45db029fff1cf13b8539d7b1aa5ec1c6605d512b Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 01:45:02 +0200 Subject: [PATCH 14/52] feat: add ENV var to allow insecure wss --- lib/tesla_api/stream.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index e132a12a88..a8d383fe40 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -33,7 +33,7 @@ defmodule TeslaApi.Stream do endpoint_url = case Auth.region(state.auth) do :chinese -> - System.get_env("TESLA_CN_WSS_URL", "wss://streaming.vn.cloud.tesla.cn/streaming/") <> + System.get_env("TESLA_WSS_URL", "wss://streaming.vn.cloud.tesla.cn/streaming/") <> System.get_env("TOKEN", "") _global -> @@ -46,7 +46,12 @@ defmodule TeslaApi.Stream do socket_recv_timeout: :timer.seconds(30), name: :"stream_#{state.vehicle_id}", cacerts: @cacerts, - insecure: false, + insecure: + if System.get_env("TESLA_WSS_INSECURE", "") == "" do + false + else + true + end, async: true ) end From f82fc8e82fa92d60272bf458398ed41ff74839ee Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 01:45:48 +0200 Subject: [PATCH 15/52] fix: remove TESLA_CN --- lib/tesla_api/auth.ex | 2 +- lib/tesla_api/vehicle.ex | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index 9d85218bb5..3347e4ec0b 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -63,7 +63,7 @@ defmodule TeslaApi.Auth do do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} defp derive_issuer_url_from_oat("cn-" <> _), - do: {:ok, System.get_env("TESLA_CN_AUTH_URL", "https://auth.tesla.cn/oauth2/v3")} + do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.cn/oauth2/v3")} defp derive_issuer_url_from_oat(_), do: :error diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index cda5931b5e..02a705c64c 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -25,7 +25,7 @@ defmodule TeslaApi.Vehicle do def list(%Auth{} = auth) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_CN_API_URL", "https://owner-api.vn.cloud.tesla.cn") + :chinese -> System.get_env("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn") _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end @@ -38,7 +38,7 @@ defmodule TeslaApi.Vehicle do def get(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_CN_API_URL", "https://owner-api.vn.cloud.tesla.cn") + :chinese -> System.get_env("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn") _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end @@ -51,7 +51,7 @@ defmodule TeslaApi.Vehicle do def get_with_state(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_CN_API_URL", "https://owner-api.vn.cloud.tesla.cn") + :chinese -> System.get_env("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn") _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") end From 21000c6999d337c82e1958d39d25838c5d03a1cf Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 02:08:00 +0200 Subject: [PATCH 16/52] fix(naming): TESLA_API_URL to TESLA_API_DOMAIN --- lib/tesla_api/vehicle.ex | 12 ++++++------ lib/teslamate/http.ex | 2 +- lib/teslamate/vehicles/vehicle.ex | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index 02a705c64c..06ffcecd6e 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -25,8 +25,8 @@ defmodule TeslaApi.Vehicle do def list(%Auth{} = auth) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn") - _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") + :chinese -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") end TeslaApi.get(endpoint_url <> "/api/1/products" <> System.get_env("TOKEN", ""), @@ -38,8 +38,8 @@ defmodule TeslaApi.Vehicle do def get(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn") - _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") + :chinese -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") end TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}" <> System.get_env("TOKEN", ""), @@ -51,8 +51,8 @@ defmodule TeslaApi.Vehicle do def get_with_state(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_API_URL", "https://owner-api.vn.cloud.tesla.cn") - _global -> System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") + :chinese -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") end TeslaApi.get( diff --git a/lib/teslamate/http.ex b/lib/teslamate/http.ex index c0fc6fee3b..650aa1d248 100644 --- a/lib/teslamate/http.ex +++ b/lib/teslamate/http.ex @@ -1,6 +1,6 @@ defmodule TeslaMate.HTTP do @pools %{ - System.get_env("TESLA_API_URL", "https://owner-api.teslamotors.com") => [size: 10], + System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") => [size: 10], "https://nominatim.openstreetmap.org" => [size: 3], "https://api.github.com" => [size: 1], :default => [size: 5] diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index c90c56d6e8..71215c881d 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1588,7 +1588,7 @@ defmodule TeslaMate.Vehicles.Vehicle do me = self() id = - if System.get_env("TESLA_API_URL") do + if System.get_env("TESLA_API_DOMAIN") do data.car.vin else data.car.vid From 99b4b2837dd61b8b59280f2d0948b396f6830002 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 02:11:53 +0200 Subject: [PATCH 17/52] feat: add an env var to allo invalid certs on WSS --- lib/tesla_api/stream.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index a8d383fe40..83fb4f4a5a 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -47,10 +47,10 @@ defmodule TeslaApi.Stream do name: :"stream_#{state.vehicle_id}", cacerts: @cacerts, insecure: - if System.get_env("TESLA_WSS_INSECURE", "") == "" do - false - else + if System.get_env("TESLA_WSS_TLS_ACCEPT_INVALID_CERTS", "") == "true" do true + else + false end, async: true ) From ec096a81b48b91dbede01e7bad3e02bcb3f5bfab Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 02:13:00 +0200 Subject: [PATCH 18/52] doc: add API domains env vars description --- .../configuration/environment_variables.md | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index d1504f6640..72361cc5a6 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -6,34 +6,39 @@ sidebar_label: Environment Variables TeslaMate accepts the following environment variables for runtime configuration: -| Variable Name | Description | Default Value | -| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | -| **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | | -| **DATABASE_USER** | Username (**required**) | | -| **DATABASE_PASS** | User password (**required**) | | -| **DATABASE_NAME** | The database to connect to (**required**) | | -| **DATABASE_HOST** | Hostname of the database server (**required**) | | -| **DATABASE_PORT** | Port of the database server | 5432 | -| **DATABASE_POOL_SIZE** | Size of the database connection pool | 10 | -| **DATABASE_TIMEOUT** | The time in milliseconds to wait for database query calls to finish | 60000 | -| **DATABASE_SSL** | Set to `true` if SSL should be enabled or `noverify` if certificate verification should not be performed. | false | -| **DATABASE_SSL_CA_CERT_FILE** | Path to a file containing PEM-encoded CA certificates (required if `DATABASE_SSL` is set to `true`) | | -| **DATABASE_SSL_SNI** | set SNI for host undel ssl mode | | -| **DATABASE_IPV6** | Set to `true` if IPv6 should be used | false | -| **VIRTUAL_HOST** | Host part used for generating URLs throughout the app | localhost | -| **URL_PATH** | Path used for generating URLs (can be used with a reverse proxy) | / | -| **CHECK_ORIGIN** | Configures whether to check the origin header or not. May be `true` (**recommended**), `false` (_default_) or a comma-separated list of hosts that are allowed (e.g. `https://example.com,//another.com:8080`). Hosts also support wildcards. If `true`, it will check against the host value in `VIRTUAL_HOST`. | false | -| **PORT** | Port where the web interface is exposed | 4000 | -| **HTTP_BINDING_ADDRESS** | IP address where the web interface is exposed, or blank (_default_) meaning all addresses. | | -| **DISABLE_MQTT** | Disables the MQTT feature if `true` | false | -| **MQTT_HOST** | Hostname of the broker (**required** unless DISABLE_MQTT is `true`) | | -| **MQTT_PORT** | Port of the broker | 1883 (8883 for MQTT over TLS) | -| **MQTT_USERNAME** | Username | | -| **MQTT_PASSWORD** | Password | | -| **MQTT_TLS** | Enables TLS if `true` | false | -| **MQTT_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates if `true` | false | -| **MQTT_IPV6** | Set to `true` if IPv6 should be used | false | -| **MQTT_NAMESPACE** | Inserts a custom namespace into the MQTT topic . For example, with `MQTT_NAMESPACE=account_0`: `teslamate/account_0/cars/$car_id/state`. | | -| **IMPORT_DIR** | The path of the directory for the import of data (e.g. TeslaFi) | ./import | -| **TZ** | Used to establish the local time zone, e.g. to use the local time in logs. See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | | -| **DEFAULT_GEOFENCE** | The default GEOFENCE to send via GEOFENCE if car not in geofence. Overrides the default of "" which will delete any retained value. | "" (no quotes) | +| Variable Name | Description | Default Value | +| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | +| **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | | +| **DATABASE_USER** | Username (**required**) | | +| **DATABASE_PASS** | User password (**required**) | | +| **DATABASE_NAME** | The database to connect to (**required**) | | +| **DATABASE_HOST** | Hostname of the database server (**required**) | | +| **DATABASE_PORT** | Port of the database server | 5432 | +| **DATABASE_POOL_SIZE** | Size of the database connection pool | 10 | +| **DATABASE_TIMEOUT** | The time in milliseconds to wait for database query calls to finish | 60000 | +| **DATABASE_SSL** | Set to `true` if SSL should be enabled or `noverify` if certificate verification should not be performed. | false | +| **DATABASE_SSL_CA_CERT_FILE** | Path to a file containing PEM-encoded CA certificates (required if `DATABASE_SSL` is set to `true`) | | +| **DATABASE_SSL_SNI** | set SNI for host undel ssl mode | | +| **DATABASE_IPV6** | Set to `true` if IPv6 should be used | false | +| **VIRTUAL_HOST** | Host part used for generating URLs throughout the app | localhost | +| **URL_PATH** | Path used for generating URLs (can be used with a reverse proxy) | / | +| **CHECK_ORIGIN** | Configures whether to check the origin header or not. May be `true` (**recommended**), `false` (_default_) or a comma-separated list of hosts that are allowed (e.g. `https://example.com,//another.com:8080`). Hosts also support wildcards. If `true`, it will check against the host value in `VIRTUAL_HOST`. | false | +| **PORT** | Port where the web interface is exposed | 4000 | +| **HTTP_BINDING_ADDRESS** | IP address where the web interface is exposed, or blank (_default_) meaning all addresses. | | +| **DISABLE_MQTT** | Disables the MQTT feature if `true` | false | +| **MQTT_HOST** | Hostname of the broker (**required** unless DISABLE_MQTT is `true`) | | +| **MQTT_PORT** | Port of the broker | 1883 (8883 for MQTT over TLS) | +| **MQTT_USERNAME** | Username | | +| **MQTT_PASSWORD** | Password | | +| **MQTT_TLS** | Enables TLS if `true` | false | +| **MQTT_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates if `true` | false | +| **MQTT_IPV6** | Set to `true` if IPv6 should be used | false | +| **MQTT_NAMESPACE** | Inserts a custom namespace into the MQTT topic . For example, with `MQTT_NAMESPACE=account_0`: `teslamate/account_0/cars/$car_id/state`. | | +| **IMPORT_DIR** | The path of the directory for the import of data (e.g. TeslaFi) | ./import | +| **TZ** | Used to establish the local time zone, e.g. to use the local time in logs. See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | | +| **DEFAULT_GEOFENCE** | The default GEOFENCE to send via GEOFENCE if car not in geofence. Overrides the default of "" which will delete any retained value. | "" (no quotes) | +| **TESLA_API_DOMAIN** | The Tesla API domain | https://owner-api.teslamotors.com (or for chinese: https://owner-api.vn.cloud.tesla.cn) | +| **TESLA_AUTH_DOMAIN** | The Tesla authentification domain | https://auth.tesla.com | +| **TESLA_AUTH_URL** | The Tesla authentification URL | https://auth.tesla.com/oauth2/v3 | +| **TESLA_WSS_URL** | The Tesla streaming URL | wss://streaming.vn.teslamotors.com/streaming/ (or for chinese: wss://streaming.vn.cloud.tesla.cn/streaming/) | +| **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on `TESLA_WSS_URL` if `true` | | From 07c057f61ad5b4a363f8fc3f8b16383e0e909e8d Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 02:17:08 +0200 Subject: [PATCH 19/52] fix: typo --- website/docs/configuration/environment_variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 72361cc5a6..1a09c02236 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -38,7 +38,7 @@ TeslaMate accepts the following environment variables for runtime configuration: | **TZ** | Used to establish the local time zone, e.g. to use the local time in logs. See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | | | **DEFAULT_GEOFENCE** | The default GEOFENCE to send via GEOFENCE if car not in geofence. Overrides the default of "" which will delete any retained value. | "" (no quotes) | | **TESLA_API_DOMAIN** | The Tesla API domain | https://owner-api.teslamotors.com (or for chinese: https://owner-api.vn.cloud.tesla.cn) | -| **TESLA_AUTH_DOMAIN** | The Tesla authentification domain | https://auth.tesla.com | -| **TESLA_AUTH_URL** | The Tesla authentification URL | https://auth.tesla.com/oauth2/v3 | +| **TESLA_AUTH_DOMAIN** | The Tesla authentication domain | https://auth.tesla.com | +| **TESLA_AUTH_URL** | The Tesla authentication URL | https://auth.tesla.com/oauth2/v3 | | **TESLA_WSS_URL** | The Tesla streaming URL | wss://streaming.vn.teslamotors.com/streaming/ (or for chinese: wss://streaming.vn.cloud.tesla.cn/streaming/) | | **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on `TESLA_WSS_URL` if `true` | | From d8fd90b6c3f39584a814179eee2347031e40ec2e Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 23:34:40 +0200 Subject: [PATCH 20/52] feat: add env var to change log level --- config/prod.exs | 2 +- website/docs/configuration/environment_variables.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/prod.exs b/config/prod.exs index 065672dc49..f3a908def9 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -7,7 +7,7 @@ config :teslamate, TeslaMateWeb.Endpoint, version: Application.spec(:teslamate, :vsn) config :logger, - level: :info + level: String.to_atom(System.get_env("APP_LOG_LEVEL") || "info") config :logger, :console, format: "$date $time $metadata[$level] $message\n", diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 1a09c02236..38a74e4dd0 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -42,3 +42,5 @@ TeslaMate accepts the following environment variables for runtime configuration: | **TESLA_AUTH_URL** | The Tesla authentication URL | https://auth.tesla.com/oauth2/v3 | | **TESLA_WSS_URL** | The Tesla streaming URL | wss://streaming.vn.teslamotors.com/streaming/ (or for chinese: wss://streaming.vn.cloud.tesla.cn/streaming/) | | **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on `TESLA_WSS_URL` if `true` | | +| **TOKEN** | Token given by a new Tesla API provider (the format must be ?token=xxxx) | | +| **APP_LOG_LEVEL** | Valid log level : trace, debug, info, warn, error or fatal | info | From 65fe38cb62d540a7bdba233ef7c958c7245289b3 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 29 Apr 2024 23:43:22 +0200 Subject: [PATCH 21/52] fix: APP_LOG_LEVEL --- config/prod.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/prod.exs b/config/prod.exs index f3a908def9..1ce8857a60 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -7,7 +7,7 @@ config :teslamate, TeslaMateWeb.Endpoint, version: Application.spec(:teslamate, :vsn) config :logger, - level: String.to_atom(System.get_env("APP_LOG_LEVEL") || "info") + level: String.to_atom(System.get_env("APP_LOG_LEVEL", "info")) config :logger, :console, format: "$date $time $metadata[$level] $message\n", From 086c064c0ffe29b5b868423eebc610d9278a6324 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 30 Apr 2024 02:54:38 +0200 Subject: [PATCH 22/52] feat: add TOKEN documention and wording --- config/prod.exs | 2 +- lib/teslamate_web/live/signin_live/index.html.heex | 2 +- priv/gettext/da/LC_MESSAGES/default.po | 4 ++-- priv/gettext/de/LC_MESSAGES/default.po | 4 ++-- priv/gettext/default.pot | 2 +- priv/gettext/en/LC_MESSAGES/default.po | 4 ++-- priv/gettext/es/LC_MESSAGES/default.po | 4 ++-- priv/gettext/fi/LC_MESSAGES/default.po | 4 ++-- priv/gettext/fr/LC_MESSAGES/default.po | 4 ++-- priv/gettext/it/LC_MESSAGES/default.po | 4 ++-- priv/gettext/ja/LC_MESSAGES/default.po | 4 ++-- priv/gettext/ko/LC_MESSAGES/default.po | 4 ++-- priv/gettext/nb/LC_MESSAGES/default.po | 4 ++-- priv/gettext/nl/LC_MESSAGES/default.po | 4 ++-- priv/gettext/sv/LC_MESSAGES/default.po | 4 ++-- priv/gettext/th/LC_MESSAGES/default.po | 4 ++-- priv/gettext/tr/LC_MESSAGES/default.po | 4 ++-- priv/gettext/uk/LC_MESSAGES/default.po | 4 ++-- priv/gettext/zh_Hans/LC_MESSAGES/default.po | 4 ++-- priv/gettext/zh_Hant/LC_MESSAGES/default.po | 4 ++-- website/docs/configuration/environment_variables.md | 3 +-- 21 files changed, 38 insertions(+), 39 deletions(-) diff --git a/config/prod.exs b/config/prod.exs index 1ce8857a60..065672dc49 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -7,7 +7,7 @@ config :teslamate, TeslaMateWeb.Endpoint, version: Application.spec(:teslamate, :vsn) config :logger, - level: String.to_atom(System.get_env("APP_LOG_LEVEL", "info")) + level: :info config :logger, :console, format: "$date $time $metadata[$level] $message\n", diff --git a/lib/teslamate_web/live/signin_live/index.html.heex b/lib/teslamate_web/live/signin_live/index.html.heex index c6a84821ab..4d750b15ca 100644 --- a/lib/teslamate_web/live/signin_live/index.html.heex +++ b/lib/teslamate_web/live/signin_live/index.html.heex @@ -57,7 +57,7 @@ <%= raw( gettext( - "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}", + "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming.", token: @token, url: safe_to_string(provider_link) ) diff --git a/priv/gettext/da/LC_MESSAGES/default.po b/priv/gettext/da/LC_MESSAGES/default.po index a6b6305f3e..80bcac9c21 100644 --- a/priv/gettext/da/LC_MESSAGES/default.po +++ b/priv/gettext/da/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index ca30a964aa..b83e6b8ce4 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "Erwartete Endzeit" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 1f0b8f0f50..bac92fc06a 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -657,5 +657,5 @@ msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 #, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index 2976abc0e5..cd5b54a813 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/es/LC_MESSAGES/default.po b/priv/gettext/es/LC_MESSAGES/default.po index 15259c94c5..5aa1471f43 100644 --- a/priv/gettext/es/LC_MESSAGES/default.po +++ b/priv/gettext/es/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/fi/LC_MESSAGES/default.po b/priv/gettext/fi/LC_MESSAGES/default.po index dc911bc22b..4ef4682e38 100644 --- a/priv/gettext/fi/LC_MESSAGES/default.po +++ b/priv/gettext/fi/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/fr/LC_MESSAGES/default.po b/priv/gettext/fr/LC_MESSAGES/default.po index 3a7b26a58b..1024621acd 100644 --- a/priv/gettext/fr/LC_MESSAGES/default.po +++ b/priv/gettext/fr/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "Fin de charge estimée" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/it/LC_MESSAGES/default.po b/priv/gettext/it/LC_MESSAGES/default.po index 2a6870afee..b77d4c1a0c 100644 --- a/priv/gettext/it/LC_MESSAGES/default.po +++ b/priv/gettext/it/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/ja/LC_MESSAGES/default.po b/priv/gettext/ja/LC_MESSAGES/default.po index 002e8fe5bb..2facc3c3de 100644 --- a/priv/gettext/ja/LC_MESSAGES/default.po +++ b/priv/gettext/ja/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/ko/LC_MESSAGES/default.po b/priv/gettext/ko/LC_MESSAGES/default.po index 533c498af7..ed6182b57e 100644 --- a/priv/gettext/ko/LC_MESSAGES/default.po +++ b/priv/gettext/ko/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "예상 종료 시간" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/nb/LC_MESSAGES/default.po b/priv/gettext/nb/LC_MESSAGES/default.po index aa1e865439..5de40a686c 100644 --- a/priv/gettext/nb/LC_MESSAGES/default.po +++ b/priv/gettext/nb/LC_MESSAGES/default.po @@ -657,6 +657,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/nl/LC_MESSAGES/default.po b/priv/gettext/nl/LC_MESSAGES/default.po index 262f07dc71..7c9bc0c91d 100644 --- a/priv/gettext/nl/LC_MESSAGES/default.po +++ b/priv/gettext/nl/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/sv/LC_MESSAGES/default.po b/priv/gettext/sv/LC_MESSAGES/default.po index 2f2caa4811..bb32a7a9f0 100644 --- a/priv/gettext/sv/LC_MESSAGES/default.po +++ b/priv/gettext/sv/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "Förväntad sluttid" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/th/LC_MESSAGES/default.po b/priv/gettext/th/LC_MESSAGES/default.po index bca973d40d..e0f2c387ce 100644 --- a/priv/gettext/th/LC_MESSAGES/default.po +++ b/priv/gettext/th/LC_MESSAGES/default.po @@ -655,6 +655,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/tr/LC_MESSAGES/default.po b/priv/gettext/tr/LC_MESSAGES/default.po index b4c6159e84..046ccea76e 100644 --- a/priv/gettext/tr/LC_MESSAGES/default.po +++ b/priv/gettext/tr/LC_MESSAGES/default.po @@ -656,6 +656,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/uk/LC_MESSAGES/default.po b/priv/gettext/uk/LC_MESSAGES/default.po index 685c7aa446..14787bb62f 100644 --- a/priv/gettext/uk/LC_MESSAGES/default.po +++ b/priv/gettext/uk/LC_MESSAGES/default.po @@ -658,6 +658,6 @@ msgid "Expected Finish Time" msgstr "" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/zh_Hans/LC_MESSAGES/default.po b/priv/gettext/zh_Hans/LC_MESSAGES/default.po index 12bb54b654..f1f3869203 100644 --- a/priv/gettext/zh_Hans/LC_MESSAGES/default.po +++ b/priv/gettext/zh_Hans/LC_MESSAGES/default.po @@ -657,6 +657,6 @@ msgid "Expected Finish Time" msgstr "预计完成时间" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/priv/gettext/zh_Hant/LC_MESSAGES/default.po b/priv/gettext/zh_Hant/LC_MESSAGES/default.po index 5fa6cc5bc5..13a9bbf9e0 100644 --- a/priv/gettext/zh_Hant/LC_MESSAGES/default.po +++ b/priv/gettext/zh_Hant/LC_MESSAGES/default.po @@ -654,6 +654,6 @@ msgid "Expected Finish Time" msgstr "預計充電完成時間" #: lib/teslamate_web/live/signin_live/index.html.heex:59 -#, elixir-autogen, elixir-format -msgid "You are using the official Tesla Fleet API and Tesla Telemetry with this token (%{token}) from %{url}" +#, elixir-autogen, elixir-format, fuzzy +msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming." msgstr "" diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 38a74e4dd0..f16092f576 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -42,5 +42,4 @@ TeslaMate accepts the following environment variables for runtime configuration: | **TESLA_AUTH_URL** | The Tesla authentication URL | https://auth.tesla.com/oauth2/v3 | | **TESLA_WSS_URL** | The Tesla streaming URL | wss://streaming.vn.teslamotors.com/streaming/ (or for chinese: wss://streaming.vn.cloud.tesla.cn/streaming/) | | **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on `TESLA_WSS_URL` if `true` | | -| **TOKEN** | Token given by a new Tesla API provider (the format must be ?token=xxxx) | | -| **APP_LOG_LEVEL** | Valid log level : trace, debug, info, warn, error or fatal | info | +| **TOKEN** | Token given by a new Tesla API provider (the format must be `?token=YOUR_TOKEN`) | | From dcc2acb822b4d3c4f4e3f5f79250d0323a458b68 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 30 Apr 2024 12:22:55 +0200 Subject: [PATCH 23/52] fix: refacto insecure param --- lib/tesla_api/stream.ex | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index 83fb4f4a5a..5a2079794c 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -46,12 +46,7 @@ defmodule TeslaApi.Stream do socket_recv_timeout: :timer.seconds(30), name: :"stream_#{state.vehicle_id}", cacerts: @cacerts, - insecure: - if System.get_env("TESLA_WSS_TLS_ACCEPT_INVALID_CERTS", "") == "true" do - true - else - false - end, + insecure: System.get_env("TESLA_WSS_TLS_ACCEPT_INVALID_CERTS", "") == "true", async: true ) end From b72992759e6761c453c28a7b40aff34aec8d42ca Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 3 May 2024 02:16:28 +0200 Subject: [PATCH 24/52] feat: naming and doc --- lib/tesla_api/auth.ex | 17 ++++- lib/tesla_api/auth/refresh.ex | 2 +- lib/tesla_api/stream.ex | 6 +- lib/tesla_api/vehicle.ex | 12 +-- lib/teslamate/http.ex | 2 +- lib/teslamate/vehicles/vehicle.ex | 2 +- lib/teslamate_web/live/signin_live/index.ex | 2 +- .../configuration/environment_variables.md | 75 ++++++++++--------- 8 files changed, 65 insertions(+), 53 deletions(-) diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index 3347e4ec0b..e045710b6d 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -18,7 +18,7 @@ defmodule TeslaApi.Auth do adapter Tesla.Adapter.Finch, name: TeslaMate.HTTP, receive_timeout: 60_000 plug TeslaApi.Middleware.FollowRedirects, except: [@redirect_uri] - plug Tesla.Middleware.BaseUrl, System.get_env("TESLA_AUTH_DOMAIN", "https://auth.tesla.com") + plug Tesla.Middleware.BaseUrl, System.get_env("TESLA_AUTH_HOST", "https://auth.tesla.com") plug Tesla.Middleware.Headers, @default_headers plug Tesla.Middleware.JSON plug Tesla.Middleware.Logger, debug: true, log_level: &log_level/1 @@ -57,13 +57,22 @@ defmodule TeslaApi.Auth do end defp derive_issuer_url_from_oat("qts-" <> _), - do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} + do: + {:ok, + System.get_env("TESLA_AUTH_HOST", "https://auth.tesla.com") <> + System.get_env("TESLA_AUTH_PATH", "/oauth2/v3")} defp derive_issuer_url_from_oat("eu-" <> _), - do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.com/oauth2/v3")} + do: + {:ok, + System.get_env("TESLA_AUTH_HOST", "https://auth.tesla.com") <> + System.get_env("TESLA_AUTH_PATH", "/oauth2/v3")} defp derive_issuer_url_from_oat("cn-" <> _), - do: {:ok, System.get_env("TESLA_AUTH_URL", "https://auth.tesla.cn/oauth2/v3")} + do: + {:ok, + System.get_env("TESLA_AUTH_HOST", "https://auth.tesla.com") <> + System.get_env("TESLA_AUTH_PATH", "/oauth2/v3")} defp derive_issuer_url_from_oat(_), do: :error diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index 06ef7091aa..ea998c4b0f 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -6,7 +6,7 @@ defmodule TeslaApi.Auth.Refresh do @web_client_id TeslaApi.Auth.web_client_id() def refresh(%Auth{} = auth) do - issuer_url = System.get_env("TESLA_AUTH_URL", "") + issuer_url = System.get_env("TESLA_AUTH_HOST", "") <> System.get_env("TESLA_AUTH_PATH", "") if issuer_url == "" do ^issuer_url = Auth.issuer_url(auth) diff --git a/lib/tesla_api/stream.ex b/lib/tesla_api/stream.ex index 5a2079794c..ac420b96dc 100644 --- a/lib/tesla_api/stream.ex +++ b/lib/tesla_api/stream.ex @@ -33,11 +33,13 @@ defmodule TeslaApi.Stream do endpoint_url = case Auth.region(state.auth) do :chinese -> - System.get_env("TESLA_WSS_URL", "wss://streaming.vn.cloud.tesla.cn/streaming/") <> + System.get_env("TESLA_WSS_HOST", "wss://streaming.vn.cloud.tesla.cn") <> + "/streaming/" <> System.get_env("TOKEN", "") _global -> - System.get_env("TESLA_WSS_URL", "wss://streaming.vn.teslamotors.com/streaming/") <> + System.get_env("TESLA_WSS_HOST", "wss://streaming.vn.teslamotors.com") <> + "/streaming/" <> System.get_env("TOKEN", "") end diff --git a/lib/tesla_api/vehicle.ex b/lib/tesla_api/vehicle.ex index 06ffcecd6e..069f1fe6f5 100644 --- a/lib/tesla_api/vehicle.ex +++ b/lib/tesla_api/vehicle.ex @@ -25,8 +25,8 @@ defmodule TeslaApi.Vehicle do def list(%Auth{} = auth) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.vn.cloud.tesla.cn") - _global -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") + :chinese -> System.get_env("TESLA_API_HOST", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_HOST", "https://owner-api.teslamotors.com") end TeslaApi.get(endpoint_url <> "/api/1/products" <> System.get_env("TOKEN", ""), @@ -38,8 +38,8 @@ defmodule TeslaApi.Vehicle do def get(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.vn.cloud.tesla.cn") - _global -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") + :chinese -> System.get_env("TESLA_API_HOST", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_HOST", "https://owner-api.teslamotors.com") end TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}" <> System.get_env("TOKEN", ""), @@ -51,8 +51,8 @@ defmodule TeslaApi.Vehicle do def get_with_state(%Auth{} = auth, id) do endpoint_url = case Auth.region(auth) do - :chinese -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.vn.cloud.tesla.cn") - _global -> System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") + :chinese -> System.get_env("TESLA_API_HOST", "https://owner-api.vn.cloud.tesla.cn") + _global -> System.get_env("TESLA_API_HOST", "https://owner-api.teslamotors.com") end TeslaApi.get( diff --git a/lib/teslamate/http.ex b/lib/teslamate/http.ex index 650aa1d248..4b5dc3cfb8 100644 --- a/lib/teslamate/http.ex +++ b/lib/teslamate/http.ex @@ -1,6 +1,6 @@ defmodule TeslaMate.HTTP do @pools %{ - System.get_env("TESLA_API_DOMAIN", "https://owner-api.teslamotors.com") => [size: 10], + System.get_env("TESLA_API_HOST", "https://owner-api.teslamotors.com") => [size: 10], "https://nominatim.openstreetmap.org" => [size: 3], "https://api.github.com" => [size: 1], :default => [size: 5] diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 71215c881d..cd85f2f8da 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1588,7 +1588,7 @@ defmodule TeslaMate.Vehicles.Vehicle do me = self() id = - if System.get_env("TESLA_API_DOMAIN") do + if System.get_env("TESLA_API_HOST") do data.car.vin else data.car.vid diff --git a/lib/teslamate_web/live/signin_live/index.ex b/lib/teslamate_web/live/signin_live/index.ex index a3d6fe3282..d66d43fd2a 100644 --- a/lib/teslamate_web/live/signin_live/index.ex +++ b/lib/teslamate_web/live/signin_live/index.ex @@ -15,7 +15,7 @@ defmodule TeslaMateWeb.SignInLive.Index do task: nil, changeset: Auth.change_tokens(), token: System.get_env("TOKEN", ""), - provider: System.get_env("TESLA_AUTH_DOMAIN", "https://auth.tesla.com") + provider: System.get_env("TESLA_AUTH_HOST", "https://auth.tesla.com") } {:ok, assign(socket, assigns)} diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index f16092f576..314093371d 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -6,40 +6,41 @@ sidebar_label: Environment Variables TeslaMate accepts the following environment variables for runtime configuration: -| Variable Name | Description | Default Value | -| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | -| **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | | -| **DATABASE_USER** | Username (**required**) | | -| **DATABASE_PASS** | User password (**required**) | | -| **DATABASE_NAME** | The database to connect to (**required**) | | -| **DATABASE_HOST** | Hostname of the database server (**required**) | | -| **DATABASE_PORT** | Port of the database server | 5432 | -| **DATABASE_POOL_SIZE** | Size of the database connection pool | 10 | -| **DATABASE_TIMEOUT** | The time in milliseconds to wait for database query calls to finish | 60000 | -| **DATABASE_SSL** | Set to `true` if SSL should be enabled or `noverify` if certificate verification should not be performed. | false | -| **DATABASE_SSL_CA_CERT_FILE** | Path to a file containing PEM-encoded CA certificates (required if `DATABASE_SSL` is set to `true`) | | -| **DATABASE_SSL_SNI** | set SNI for host undel ssl mode | | -| **DATABASE_IPV6** | Set to `true` if IPv6 should be used | false | -| **VIRTUAL_HOST** | Host part used for generating URLs throughout the app | localhost | -| **URL_PATH** | Path used for generating URLs (can be used with a reverse proxy) | / | -| **CHECK_ORIGIN** | Configures whether to check the origin header or not. May be `true` (**recommended**), `false` (_default_) or a comma-separated list of hosts that are allowed (e.g. `https://example.com,//another.com:8080`). Hosts also support wildcards. If `true`, it will check against the host value in `VIRTUAL_HOST`. | false | -| **PORT** | Port where the web interface is exposed | 4000 | -| **HTTP_BINDING_ADDRESS** | IP address where the web interface is exposed, or blank (_default_) meaning all addresses. | | -| **DISABLE_MQTT** | Disables the MQTT feature if `true` | false | -| **MQTT_HOST** | Hostname of the broker (**required** unless DISABLE_MQTT is `true`) | | -| **MQTT_PORT** | Port of the broker | 1883 (8883 for MQTT over TLS) | -| **MQTT_USERNAME** | Username | | -| **MQTT_PASSWORD** | Password | | -| **MQTT_TLS** | Enables TLS if `true` | false | -| **MQTT_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates if `true` | false | -| **MQTT_IPV6** | Set to `true` if IPv6 should be used | false | -| **MQTT_NAMESPACE** | Inserts a custom namespace into the MQTT topic . For example, with `MQTT_NAMESPACE=account_0`: `teslamate/account_0/cars/$car_id/state`. | | -| **IMPORT_DIR** | The path of the directory for the import of data (e.g. TeslaFi) | ./import | -| **TZ** | Used to establish the local time zone, e.g. to use the local time in logs. See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | | -| **DEFAULT_GEOFENCE** | The default GEOFENCE to send via GEOFENCE if car not in geofence. Overrides the default of "" which will delete any retained value. | "" (no quotes) | -| **TESLA_API_DOMAIN** | The Tesla API domain | https://owner-api.teslamotors.com (or for chinese: https://owner-api.vn.cloud.tesla.cn) | -| **TESLA_AUTH_DOMAIN** | The Tesla authentication domain | https://auth.tesla.com | -| **TESLA_AUTH_URL** | The Tesla authentication URL | https://auth.tesla.com/oauth2/v3 | -| **TESLA_WSS_URL** | The Tesla streaming URL | wss://streaming.vn.teslamotors.com/streaming/ (or for chinese: wss://streaming.vn.cloud.tesla.cn/streaming/) | -| **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on `TESLA_WSS_URL` if `true` | | -| **TOKEN** | Token given by a new Tesla API provider (the format must be `?token=YOUR_TOKEN`) | | +| Variable Name | Description | Default Value | +| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | | +| **DATABASE_USER** | Username (**required**) | | +| **DATABASE_PASS** | User password (**required**) | | +| **DATABASE_NAME** | The database to connect to (**required**) | | +| **DATABASE_HOST** | Hostname of the database server (**required**) | | +| **DATABASE_PORT** | Port of the database server | 5432 | +| **DATABASE_POOL_SIZE** | Size of the database connection pool | 10 | +| **DATABASE_TIMEOUT** | The time in milliseconds to wait for database query calls to finish | 60000 | +| **DATABASE_SSL** | Set to `true` if SSL should be enabled or `noverify` if certificate verification should not be performed. | false | +| **DATABASE_SSL_CA_CERT_FILE** | Path to a file containing PEM-encoded CA certificates (required if `DATABASE_SSL` is set to `true`) | | +| **DATABASE_SSL_SNI** | set SNI for host undel ssl mode | | +| **DATABASE_IPV6** | Set to `true` if IPv6 should be used | false | +| **VIRTUAL_HOST** | Host part used for generating URLs throughout the app | localhost | +| **URL_PATH** | Path used for generating URLs (can be used with a reverse proxy) | / | +| **CHECK_ORIGIN** | Configures whether to check the origin header or not. May be `true` (**recommended**), `false` (_default_) or a comma-separated list of hosts that are allowed (e.g. `https://example.com,//another.com:8080`). Hosts also support wildcards. If `true`, it will check against the host value in `VIRTUAL_HOST`. | false | +| **PORT** | Port where the web interface is exposed | 4000 | +| **HTTP_BINDING_ADDRESS** | IP address where the web interface is exposed, or blank (_default_) meaning all addresses. | | +| **DISABLE_MQTT** | Disables the MQTT feature if `true` | false | +| **MQTT_HOST** | Hostname of the broker (**required** unless DISABLE_MQTT is `true`) | | +| **MQTT_PORT** | Port of the broker | 1883 (8883 for MQTT over TLS) | +| **MQTT_USERNAME** | Username | | +| **MQTT_PASSWORD** | Password | | +| **MQTT_TLS** | Enables TLS if `true` | false | +| **MQTT_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates if `true` | false | +| **MQTT_IPV6** | Set to `true` if IPv6 should be used | false | +| **MQTT_NAMESPACE** | Inserts a custom namespace into the MQTT topic . For example, with `MQTT_NAMESPACE=account_0`: `teslamate/account_0/cars/$car_id/state`. | | +| **IMPORT_DIR** | The path of the directory for the import of data (e.g. TeslaFi) | ./import | +| **TZ** | Used to establish the local time zone, e.g. to use the local time in logs. See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | | +| **DEFAULT_GEOFENCE** | The default GEOFENCE to send via GEOFENCE if car not in geofence. Overrides the default of "" which will delete any retained value. | "" (no quotes) | +| **TESLA_API_HOST** | Hostname of the Tesla API | https://owner-api.teslamotors.com (or for chinese: https://owner-api.vn.cloud.tesla.cn) | +| **TESLA_AUTH_HOST** | Hostname of the Tesla authentication API | https://auth.tesla.com | +| **TESLA_AUTH_PATH** | The Tesla authentication path | /oauth2/v3 | +| **TESLA_WSS_HOST** | Hostname of the Tesla streaming | wss://streaming.vn.teslamotors.com (or for chinese: wss://streaming.vn.cloud.tesla.cn) | +| **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on TESLA_WSS_HOST if `true` | | +| **TESLA_WSS_USE_VIN** | Use the `vin` field instead of `vid` to connect stream if `true` | | +| **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | | From dd6d920a35a0bcdeaf8f3b0b2c7c8bc9db19ee90 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 3 May 2024 02:22:04 +0200 Subject: [PATCH 25/52] fix: missing env var usage --- lib/teslamate/vehicles/vehicle.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index cd85f2f8da..a3e05c2a14 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1588,7 +1588,7 @@ defmodule TeslaMate.Vehicles.Vehicle do me = self() id = - if System.get_env("TESLA_API_HOST") do + if System.get_env("TESLA_WSS_USE_VIN") do data.car.vin else data.car.vid From 6a96b7cfe3eb3be390b1930524c2de305d64c0b1 Mon Sep 17 00:00:00 2001 From: jlestel Date: Tue, 21 May 2024 17:57:12 +0200 Subject: [PATCH 26/52] fix: rebound variable issuer_url --- lib/tesla_api/auth/refresh.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index ea998c4b0f..9d9c82410b 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -9,7 +9,7 @@ defmodule TeslaApi.Auth.Refresh do issuer_url = System.get_env("TESLA_AUTH_HOST", "") <> System.get_env("TESLA_AUTH_PATH", "") if issuer_url == "" do - ^issuer_url = Auth.issuer_url(auth) + issuer_url = Auth.issuer_url(auth) end data = %{ From cdef4492ae4e2805ffe1a84527c3889958408f38 Mon Sep 17 00:00:00 2001 From: jlestel Date: Tue, 21 May 2024 18:18:36 +0200 Subject: [PATCH 27/52] fix: compilation warning on the issuer_url variable --- lib/tesla_api/auth/refresh.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index 9d9c82410b..17a764f9a1 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -8,8 +8,10 @@ defmodule TeslaApi.Auth.Refresh do def refresh(%Auth{} = auth) do issuer_url = System.get_env("TESLA_AUTH_HOST", "") <> System.get_env("TESLA_AUTH_PATH", "") - if issuer_url == "" do - issuer_url = Auth.issuer_url(auth) + issuer_url = if issuer_url == "" do + Auth.issuer_url(auth) + else + issuer_url end data = %{ From fd25e9195fd2de56a0aa159e80d4e141b85c71f7 Mon Sep 17 00:00:00 2001 From: jlestel Date: Tue, 21 May 2024 18:22:11 +0200 Subject: [PATCH 28/52] fix: format code --- lib/tesla_api/auth/refresh.ex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index 17a764f9a1..2c8eb1af82 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -7,12 +7,12 @@ defmodule TeslaApi.Auth.Refresh do def refresh(%Auth{} = auth) do issuer_url = System.get_env("TESLA_AUTH_HOST", "") <> System.get_env("TESLA_AUTH_PATH", "") - - issuer_url = if issuer_url == "" do - Auth.issuer_url(auth) - else - issuer_url - end + issuer_url = + if issuer_url == "" do + Auth.issuer_url(auth) + else + issuer_url + end data = %{ grant_type: "refresh_token", From 69d4a49fc4cadd308306bad7a0e4d558b713f467 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 21 May 2024 22:39:04 +0200 Subject: [PATCH 29/52] fix: issuer_url assignments --- lib/tesla_api/auth/refresh.ex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/tesla_api/auth/refresh.ex b/lib/tesla_api/auth/refresh.ex index 2c8eb1af82..f61110b1af 100644 --- a/lib/tesla_api/auth/refresh.ex +++ b/lib/tesla_api/auth/refresh.ex @@ -6,12 +6,11 @@ defmodule TeslaApi.Auth.Refresh do @web_client_id TeslaApi.Auth.web_client_id() def refresh(%Auth{} = auth) do - issuer_url = System.get_env("TESLA_AUTH_HOST", "") <> System.get_env("TESLA_AUTH_PATH", "") issuer_url = - if issuer_url == "" do + if System.get_env("TESLA_AUTH_HOST", "") == "" do Auth.issuer_url(auth) else - issuer_url + System.get_env("TESLA_AUTH_HOST", "") <> System.get_env("TESLA_AUTH_PATH", "") end data = %{ From 996140bf609b88378b5ffa6bc1591f19976c49f5 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 02:30:10 +0200 Subject: [PATCH 30/52] feat: customize polling intervals --- lib/teslamate/vehicles/vehicle.ex | 49 +++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index a3e05c2a14..e72032e92d 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -29,10 +29,21 @@ defmodule TeslaMate.Vehicles.Vehicle do @asleep_interval 30 @driving_interval 2.5 + @default_interval 15 @drive_timeout_min 15 - # Static + def interval(env_var, default) do + System.get_env(env_var) + |> case do + nil -> default + interval -> String.to_integer(interval) + end + end + + def asleep_interval, do: interval("POLLING_ASLEEP_INTERVAL", @asleep_interval) + def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", @driving_interval) + def default_interval, do: interval("POLLING_DEFAULT_INTERVAL", @default_interval) def identify(%Vehicle{display_name: name, vehicle_config: config}) do case config do @@ -396,7 +407,7 @@ defmodule TeslaMate.Vehicles.Vehicle do interval = case state do {:driving, _, _} -> 10 - {:charging, _} -> 15 + {:charging, _} -> default_interval() :online -> 20 _ -> 30 end @@ -690,7 +701,7 @@ defmodule TeslaMate.Vehicles.Vehicle do :ok = disconnect_stream(data) - {:next_state, {:asleep, @asleep_interval}, + {:next_state, {:asleep, asleep_interval()}, %Data{data | last_state_change: last_state_change, stream_pid: nil}, [broadcast_summary(), schedule_fetch(data)]} end @@ -703,7 +714,7 @@ defmodule TeslaMate.Vehicles.Vehicle do :ok = disconnect_stream(data) - {:next_state, {:offline, @asleep_interval}, + {:next_state, {:offline, asleep_interval()}, %Data{data | last_state_change: last_state_change, stream_pid: nil}, [broadcast_summary(), schedule_fetch(data)]} end @@ -804,7 +815,10 @@ defmodule TeslaMate.Vehicles.Vehicle do {drive, data} = start_drive(create_position(vehicle, data), data) {:next_state, {:driving, :available, drive}, data, - [broadcast_summary(), schedule_fetch(@driving_interval, data)]} + [ + broadcast_summary(), + schedule_fetch(driving_interval(), data) + ]} %V{charge_state: %Charge{charging_state: charging_state, battery_level: lvl}} when charging_state in ["Starting", "Charging"] -> @@ -1009,7 +1023,7 @@ defmodule TeslaMate.Vehicles.Vehicle do end def handle_event(:internal, {:update, {:online, vehicle}}, {:driving, :available, drv}, data) do - interval = if streaming?(data), do: 15, else: @driving_interval + interval = if streaming?(data), do: default_interval(), else: driving_interval() case vehicle do %Vehicle{drive_state: %Drive{shift_state: shift_state}} when shift_state in ~w(D N R) -> @@ -1073,7 +1087,8 @@ defmodule TeslaMate.Vehicles.Vehicle do {:keep_state, %Data{data | last_used: DateTime.utc_now()}, schedule_fetch(5, data)} %VehicleState{software_update: %SW{status: "installing"}} -> - {:keep_state, %Data{data | last_used: DateTime.utc_now()}, schedule_fetch(15, data)} + {:keep_state, %Data{data | last_used: DateTime.utc_now()}, + schedule_fetch(default_interval(), data)} %VehicleState{software_update: %SW{status: "available"} = update} -> {:ok, %Log.Update{}} = call(data.deps.log, :cancel_update, [update]) @@ -1112,12 +1127,12 @@ defmodule TeslaMate.Vehicles.Vehicle do def handle_event(:internal, {:update, {state, _}}, {state, @asleep_interval}, data) when state in [:asleep, :offline] do - {:keep_state_and_data, [schedule_fetch(@asleep_interval, data), broadcast_summary()]} + {:keep_state_and_data, [schedule_fetch(asleep_interval(), data), broadcast_summary()]} end def handle_event(:internal, {:update, {state, _}}, {state, interval}, data) when state in [:asleep, :offline] do - {:next_state, {state, min(interval * 2, @asleep_interval)}, data, + {:next_state, {state, min(interval * 2, asleep_interval())}, data, schedule_fetch(interval, data)} end @@ -1374,29 +1389,31 @@ defmodule TeslaMate.Vehicles.Vehicle do if suspend?, do: Logger.warning("User present ...", car_id: car.id) {:keep_state, %Data{data | last_used: DateTime.utc_now()}, - [broadcast_summary(), schedule_fetch(15, data)]} + [broadcast_summary(), schedule_fetch(default_interval(), data)]} {:error, :downloading_update} -> if suspend?, do: Logger.warning("Downloading update ...", car_id: car.id) {:keep_state, %Data{data | last_used: DateTime.utc_now()}, - [broadcast_summary(), schedule_fetch(15 * i, data)]} + [broadcast_summary(), schedule_fetch(default_interval() * i, data)]} {:error, :doors_open} -> if suspend?, do: Logger.warning("Doors open ...", car_id: car.id) {:keep_state, %Data{data | last_used: DateTime.utc_now()}, - [broadcast_summary(), schedule_fetch(15 * i, data)]} + [broadcast_summary(), schedule_fetch(default_interval() * i, data)]} {:error, :trunk_open} -> if suspend?, do: Logger.warning("Trunk open ...", car_id: car.id) {:keep_state, %Data{data | last_used: DateTime.utc_now()}, - [broadcast_summary(), schedule_fetch(15 * i, data)]} + [broadcast_summary(), schedule_fetch(default_interval() * i, data)]} {:error, :unlocked} -> if suspend?, do: Logger.warning("Unlocked ...", car_id: car.id) - {:keep_state_and_data, [broadcast_summary(), schedule_fetch(15 * i, data)]} + + {:keep_state_and_data, + [broadcast_summary(), schedule_fetch(default_interval() * i, data)]} :ok -> if suspend? do @@ -1416,7 +1433,8 @@ defmodule TeslaMate.Vehicles.Vehicle do %Data{data | last_state_change: DateTime.utc_now()}, events} end else - {:keep_state_and_data, [broadcast_summary(), schedule_fetch(15 * i, data)]} + {:keep_state_and_data, + [broadcast_summary(), schedule_fetch(default_interval() * i, data)]} end end end @@ -1614,6 +1632,7 @@ defmodule TeslaMate.Vehicles.Vehicle do defp determince_interval(n), do: round(250 / n) |> min(20) |> max(5) defp fuse_name(:vehicle_not_found, car_id), do: :"#{__MODULE__}_#{car_id}_not_found" + defp fuse_name(:too_many_requests, car_id), do: :"#{__MODULE__}_#{car_id}_too_many_requests" defp fuse_name(:api_error, car_id), do: :"#{__MODULE__}_#{car_id}_api_error" defp broadcast_summary, do: {:next_event, :internal, :broadcast_summary} From d8c2859ad038af5b333b9a62cd246d25d90a4e3b Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 02:32:22 +0200 Subject: [PATCH 31/52] typo --- lib/teslamate/vehicles/vehicle.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index e72032e92d..96ef26ecc9 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1632,7 +1632,6 @@ defmodule TeslaMate.Vehicles.Vehicle do defp determince_interval(n), do: round(250 / n) |> min(20) |> max(5) defp fuse_name(:vehicle_not_found, car_id), do: :"#{__MODULE__}_#{car_id}_not_found" - defp fuse_name(:too_many_requests, car_id), do: :"#{__MODULE__}_#{car_id}_too_many_requests" defp fuse_name(:api_error, car_id), do: :"#{__MODULE__}_#{car_id}_api_error" defp broadcast_summary, do: {:next_event, :internal, :broadcast_summary} From 38b81386c8a9dccb0ed05d5a5d898a6f497e0be9 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 02:49:23 +0200 Subject: [PATCH 32/52] update doc --- website/docs/configuration/environment_variables.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 7f2f6e84c1..54f7dcd073 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -7,7 +7,7 @@ sidebar_label: Environment Variables TeslaMate accepts the following environment variables for runtime configuration: | Variable Name | Description | Default Value | -| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------| | **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | | | **DATABASE_USER** | Username (**required**) | | | **DATABASE_PASS** | User password (**required**) | | @@ -37,11 +37,14 @@ TeslaMate accepts the following environment variables for runtime configuration: | **IMPORT_DIR** | The path of the directory for the import of data (e.g. TeslaFi) | ./import | | **TZ** | Used to establish the local time zone, e.g. to use the local time in logs. See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | | | **DEFAULT_GEOFENCE** | The default GEOFENCE to send via GEOFENCE if car not in geofence. Overrides the default of "" which will delete any retained value. | "" (no quotes) | -| **TESLAFI_IMPORT_VEHICLE_ID** | The default Vehicle ID used when importing from TeslaFi. If it is not defined and the import source does not contain the data, 1 is used. +| **TESLAFI_IMPORT_VEHICLE_ID** | The default Vehicle ID used when importing from TeslaFi. If it is not defined and the import source does not contain the data, 1 is used. | | | **TESLA_API_HOST** | Hostname of the Tesla API | https://owner-api.teslamotors.com (or for chinese: https://owner-api.vn.cloud.tesla.cn) | | **TESLA_AUTH_HOST** | Hostname of the Tesla authentication API | https://auth.tesla.com | | **TESLA_AUTH_PATH** | The Tesla authentication path | /oauth2/v3 | | **TESLA_WSS_HOST** | Hostname of the Tesla streaming | wss://streaming.vn.teslamotors.com (or for chinese: wss://streaming.vn.cloud.tesla.cn) | | **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on TESLA_WSS_HOST if `true` | | | **TESLA_WSS_USE_VIN** | Use the `vin` field instead of `vid` to connect stream if `true` | | -| **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | | \ No newline at end of file +| **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | | +| **POLLING_ASLEEP_INTERVAL** | Interval between API fetch when vehicle is asleep | 30 | +| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch | 15 | +| **POLLING_DRIVING_INTERVAL** | Interval between API fetch when vehicle is driving | 2.5 | From 0620bc05de56699e9edb10bb539b3b40295700bb Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 02:53:05 +0200 Subject: [PATCH 33/52] typo --- lib/teslamate/vehicles/vehicle.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 96ef26ecc9..7d073f878a 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -33,6 +33,7 @@ defmodule TeslaMate.Vehicles.Vehicle do @drive_timeout_min 15 + # Static def interval(env_var, default) do System.get_env(env_var) |> case do From 668ba1ffc3d204e5556c509cad1e7bb1bea4eabe Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 03:44:39 +0200 Subject: [PATCH 34/52] add online interval --- website/docs/configuration/environment_variables.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 54f7dcd073..d5b2e6c523 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -46,5 +46,6 @@ TeslaMate accepts the following environment variables for runtime configuration: | **TESLA_WSS_USE_VIN** | Use the `vin` field instead of `vid` to connect stream if `true` | | | **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | | | **POLLING_ASLEEP_INTERVAL** | Interval between API fetch when vehicle is asleep | 30 | -| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch | 15 | +| **POLLING_ONLINE_INTERVAL** | Default interval between API fetch when vehicle is online | 60 | | **POLLING_DRIVING_INTERVAL** | Interval between API fetch when vehicle is driving | 2.5 | +| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch | 15 | From e2204ddcb9f57d4df3c1980247a6a0b32070115c Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 03:46:11 +0200 Subject: [PATCH 35/52] add POLLING_ONLINE_INTERVAL --- lib/teslamate/vehicles/vehicle.ex | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 7d073f878a..ff81506081 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -28,8 +28,6 @@ defmodule TeslaMate.Vehicles.Vehicle do end @asleep_interval 30 - @driving_interval 2.5 - @default_interval 15 @drive_timeout_min 15 @@ -43,8 +41,9 @@ defmodule TeslaMate.Vehicles.Vehicle do end def asleep_interval, do: interval("POLLING_ASLEEP_INTERVAL", @asleep_interval) - def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", @driving_interval) - def default_interval, do: interval("POLLING_DEFAULT_INTERVAL", @default_interval) + def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", 2.5) + def default_interval, do: interval("POLLING_DEFAULT_INTERVAL", 15) + def online_interval, do: interval("POLLING_ONLINE_INTERVAL", 60) def identify(%Vehicle{display_name: name, vehicle_config: config}) do case config do @@ -370,10 +369,10 @@ defmodule TeslaMate.Vehicles.Vehicle do ) {:next_state, :start, %Data{data | last_used: DateTime.utc_now()}, - [broadcast_fetch(false), broadcast_summary(), schedule_fetch(60, data)]} + [broadcast_fetch(false), broadcast_summary(), schedule_fetch(online_interval(), data)]} _ -> - {:keep_state, data, [broadcast_fetch(false), schedule_fetch(60, data)]} + {:keep_state, data, [broadcast_fetch(false), schedule_fetch(online_interval(), data)]} end {:error, :not_signed_in} -> From a1c0b37669da3ec44e8d332ee99bf5696a042d46 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 03:48:04 +0200 Subject: [PATCH 36/52] format --- lib/teslamate/vehicles/vehicle.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index ff81506081..3d2f91b251 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -369,7 +369,11 @@ defmodule TeslaMate.Vehicles.Vehicle do ) {:next_state, :start, %Data{data | last_used: DateTime.utc_now()}, - [broadcast_fetch(false), broadcast_summary(), schedule_fetch(online_interval(), data)]} + [ + broadcast_fetch(false), + broadcast_summary(), + schedule_fetch(online_interval(), data) + ]} _ -> {:keep_state, data, [broadcast_fetch(false), schedule_fetch(online_interval(), data)]} From 6408ac6379cc159f69e50a593779bc732653aed3 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 5 Jun 2024 10:35:41 +0200 Subject: [PATCH 37/52] add minimum interval --- lib/teslamate/vehicles/vehicle.ex | 3 ++- website/docs/configuration/environment_variables.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 3d2f91b251..33225ed7ef 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -44,6 +44,7 @@ defmodule TeslaMate.Vehicles.Vehicle do def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", 2.5) def default_interval, do: interval("POLLING_DEFAULT_INTERVAL", 15) def online_interval, do: interval("POLLING_ONLINE_INTERVAL", 60) + def minimum_interval, do: interval("POLLING_MINIMUM_INTERVAL", 5) def identify(%Vehicle{display_name: name, vehicle_config: config}) do case config do @@ -1633,7 +1634,7 @@ defmodule TeslaMate.Vehicles.Vehicle do defp fetch_topic(car_id) when is_number(car_id), do: "#{__MODULE__}/fetch/#{car_id}" defp determince_interval(n) when is_nil(n) or n <= 0, do: 5 - defp determince_interval(n), do: round(250 / n) |> min(20) |> max(5) + defp determince_interval(n), do: round(250 / n) |> min(20) |> max(minimum_interval()) defp fuse_name(:vehicle_not_found, car_id), do: :"#{__MODULE__}_#{car_id}_not_found" defp fuse_name(:api_error, car_id), do: :"#{__MODULE__}_#{car_id}_api_error" diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index d5b2e6c523..9f4a1563c2 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -49,3 +49,4 @@ TeslaMate accepts the following environment variables for runtime configuration: | **POLLING_ONLINE_INTERVAL** | Default interval between API fetch when vehicle is online | 60 | | **POLLING_DRIVING_INTERVAL** | Interval between API fetch when vehicle is driving | 2.5 | | **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch | 15 | +| **POLLING_MINIMUM_INTERVAL** | Minimum interval between API fetch | 5 | From 08817df802212bf20c266e7274f4ec440c984b6d Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 11 Jun 2024 00:57:48 +0200 Subject: [PATCH 38/52] Add minimum on fetch parameter --- .vscode/launch.json | 46 +++++++++++++++++++++++++++++++ lib/teslamate/vehicles/vehicle.ex | 17 +++++++----- 2 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..261bb6e42c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "mix_task", + "name": "mix (Default task)", + "request": "launch", + "task": "phx.server", + "projectDir": "${workspaceRoot}", + "exitAfterTaskReturns": false, + "env": { + "TESLA_API_HOST": "https://api.myteslamate.com", + "TESLA_AUTH_HOST": "https://api.myteslamate.com", + "TESLA_AUTH_PATH": "/api/oauth2/v3", + "TESLA_WSS_HOST": "wss://streaming.myteslamate.com", + "TESLA_WSS_TLS_ACCEPT_INVALID_CERTS": "true", + "TESLA_WSS_USE_VIN": "true", + "TOKEN": "?token=j2vy4xi7df-fmnuizcsey-cw4mkl4jx4-qxqeaybffy", + "ENCRYPTION_KEY": "yoyo", + "TESLA_WSS_INSECURE": "true", + "POLLING_ASLEEP_INTERVAL": "30", + "POLLING_DEFAULT_INTERVAL": "15", + "POLLING_ONLINE_INTERVAL": "10", + "POLLING_MINIMUM_INTERVAL": "60" + } + }, + { + "type": "mix_task", + "name": "mix test", + "request": "launch", + "task": "test", + "taskArgs": [ + "--trace" + ], + "startApps": true, + "projectDir": "${workspaceRoot}", + "requireFiles": [ + "test/**/test_helper.exs", + "test/**/*_test.exs" + ] + } + ] +} \ No newline at end of file diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 33225ed7ef..871cd681a9 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -28,6 +28,7 @@ defmodule TeslaMate.Vehicles.Vehicle do end @asleep_interval 30 + @minimum_interval 5 @drive_timeout_min 15 @@ -41,10 +42,10 @@ defmodule TeslaMate.Vehicles.Vehicle do end def asleep_interval, do: interval("POLLING_ASLEEP_INTERVAL", @asleep_interval) - def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", 2.5) + def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", @minimum_interval) def default_interval, do: interval("POLLING_DEFAULT_INTERVAL", 15) def online_interval, do: interval("POLLING_ONLINE_INTERVAL", 60) - def minimum_interval, do: interval("POLLING_MINIMUM_INTERVAL", 5) + def minimum_interval, do: interval("POLLING_MINIMUM_INTERVAL", @minimum_interval) def identify(%Vehicle{display_name: name, vehicle_config: config}) do case config do @@ -411,10 +412,10 @@ defmodule TeslaMate.Vehicles.Vehicle do interval = case state do - {:driving, _, _} -> 10 + {:driving, _, _} -> round(default_interval() * 2 / 3) {:charging, _} -> default_interval() - :online -> 20 - _ -> 30 + :online -> round(default_interval() * 4 / 3) + _ -> default_interval() * 2 end {:keep_state, data, @@ -1652,8 +1653,10 @@ defmodule TeslaMate.Vehicles.Vehicle do defp parse_timestamp(ts), do: DateTime.from_unix!(ts, :millisecond) - defp schedule_fetch(%Data{} = data), do: schedule_fetch(10, :seconds, data) - defp schedule_fetch(n, %Data{} = data), do: schedule_fetch(n, :seconds, data) + defp schedule_fetch(%Data{} = data), do: schedule_fetch(10 |> max(minimum_interval()), :seconds, data) + + defp schedule_fetch(n, %Data{} = data), + do: schedule_fetch(n |> max(minimum_interval()), :seconds, data) defp schedule_fetch(_n, _unit, %Data{import?: true}), do: {:state_timeout, 0, :fetch} defp schedule_fetch(n, unit, _), do: {:state_timeout, fetch_timeout(n, unit), :fetch} From 07bfb3dd9a4ff20b7b37a1820d67fc9ce4b75f6e Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 11 Jun 2024 00:58:22 +0200 Subject: [PATCH 39/52] typo --- .vscode/launch.json | 46 --------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 261bb6e42c..0000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "mix_task", - "name": "mix (Default task)", - "request": "launch", - "task": "phx.server", - "projectDir": "${workspaceRoot}", - "exitAfterTaskReturns": false, - "env": { - "TESLA_API_HOST": "https://api.myteslamate.com", - "TESLA_AUTH_HOST": "https://api.myteslamate.com", - "TESLA_AUTH_PATH": "/api/oauth2/v3", - "TESLA_WSS_HOST": "wss://streaming.myteslamate.com", - "TESLA_WSS_TLS_ACCEPT_INVALID_CERTS": "true", - "TESLA_WSS_USE_VIN": "true", - "TOKEN": "?token=j2vy4xi7df-fmnuizcsey-cw4mkl4jx4-qxqeaybffy", - "ENCRYPTION_KEY": "yoyo", - "TESLA_WSS_INSECURE": "true", - "POLLING_ASLEEP_INTERVAL": "30", - "POLLING_DEFAULT_INTERVAL": "15", - "POLLING_ONLINE_INTERVAL": "10", - "POLLING_MINIMUM_INTERVAL": "60" - } - }, - { - "type": "mix_task", - "name": "mix test", - "request": "launch", - "task": "test", - "taskArgs": [ - "--trace" - ], - "startApps": true, - "projectDir": "${workspaceRoot}", - "requireFiles": [ - "test/**/test_helper.exs", - "test/**/*_test.exs" - ] - } - ] -} \ No newline at end of file From 122367e22b15992243236498ddbb07b56cef67df Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 11 Jun 2024 01:02:04 +0200 Subject: [PATCH 40/52] format --- lib/teslamate/vehicles/vehicle.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 85ba9bebab..6c59f152da 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -1659,7 +1659,8 @@ defmodule TeslaMate.Vehicles.Vehicle do defp parse_timestamp(ts), do: DateTime.from_unix!(ts, :millisecond) - defp schedule_fetch(%Data{} = data), do: schedule_fetch(10 |> max(minimum_interval()), :seconds, data) + defp schedule_fetch(%Data{} = data), + do: schedule_fetch(10 |> max(minimum_interval()), :seconds, data) defp schedule_fetch(n, %Data{} = data), do: schedule_fetch(n |> max(minimum_interval()), :seconds, data) From 91927974896c54bd7bfc3372f26a3987695026b0 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 12 Jun 2024 02:52:23 +0200 Subject: [PATCH 41/52] respect immediate fetch, add charging interval --- lib/teslamate/vehicles/vehicle.ex | 8 ++++++-- website/docs/configuration/environment_variables.md | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index 6c59f152da..e4e9c44206 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -45,6 +45,7 @@ defmodule TeslaMate.Vehicles.Vehicle do def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", @minimum_interval) def default_interval, do: interval("POLLING_DEFAULT_INTERVAL", 15) def online_interval, do: interval("POLLING_ONLINE_INTERVAL", 60) + def charging_interval, do: interval("POLLING_CHARGING_INTERVAL", 5) def minimum_interval, do: interval("POLLING_MINIMUM_INTERVAL", @minimum_interval) def identify(%Vehicle{display_name: name, vehicle_config: config}) do @@ -1641,7 +1642,7 @@ defmodule TeslaMate.Vehicles.Vehicle do defp fetch_topic(car_id) when is_number(car_id), do: "#{__MODULE__}/fetch/#{car_id}" defp determince_interval(n) when is_nil(n) or n <= 0, do: 5 - defp determince_interval(n), do: round(250 / n) |> min(20) |> max(minimum_interval()) + defp determince_interval(n), do: round(250 / n) |> min(20) |> max(charging_interval()) defp fuse_name(:vehicle_not_found, car_id), do: :"#{__MODULE__}_#{car_id}_not_found" defp fuse_name(:api_error, car_id), do: :"#{__MODULE__}_#{car_id}_api_error" @@ -1660,7 +1661,10 @@ defmodule TeslaMate.Vehicles.Vehicle do defp parse_timestamp(ts), do: DateTime.from_unix!(ts, :millisecond) defp schedule_fetch(%Data{} = data), - do: schedule_fetch(10 |> max(minimum_interval()), :seconds, data) + do: schedule_fetch(10, :seconds, data) + + defp schedule_fetch(0, %Data{} = data), + do: schedule_fetch(0, :seconds, data) defp schedule_fetch(n, %Data{} = data), do: schedule_fetch(n |> max(minimum_interval()), :seconds, data) diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 9f4a1563c2..52d99dbe96 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -46,7 +46,9 @@ TeslaMate accepts the following environment variables for runtime configuration: | **TESLA_WSS_USE_VIN** | Use the `vin` field instead of `vid` to connect stream if `true` | | | **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | | | **POLLING_ASLEEP_INTERVAL** | Interval between API fetch when vehicle is asleep | 30 | -| **POLLING_ONLINE_INTERVAL** | Default interval between API fetch when vehicle is online | 60 | +| **POLLING_CHARGING_INTERVAL** | Minimum interval between API fetch when vehicle is charging | 5 | | **POLLING_DRIVING_INTERVAL** | Interval between API fetch when vehicle is driving | 2.5 | +| **POLLING_ONLINE_INTERVAL** | Default interval between API fetch when vehicle is online | 60 | | **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch | 15 | | **POLLING_MINIMUM_INTERVAL** | Minimum interval between API fetch | 5 | +| **LOG_LEVEL** | Log verbosity (debug, info, warn or error) | info | From 510275c5890a66ef491d8f2eb8ec1ce8c3cc6d74 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 12 Jun 2024 02:52:37 +0200 Subject: [PATCH 42/52] add log level --- config/prod.exs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/prod.exs b/config/prod.exs index 065672dc49..9617cd5eca 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -6,8 +6,11 @@ config :teslamate, TeslaMateWeb.Endpoint, server: true, version: Application.spec(:teslamate, :vsn) +log_level = System.get_env("LOG_LEVEL", "info") +log_level_atom = String.to_existing_atom(log_level) + config :logger, - level: :info + level: log_level_atom config :logger, :console, format: "$date $time $metadata[$level] $message\n", From 3a40af56fd1d91bf43e60b4d418da7d79ae0a569 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 12 Jun 2024 09:28:20 +0200 Subject: [PATCH 43/52] Respect log_level --- lib/tesla_api.ex | 4 ++-- lib/tesla_api/auth.ex | 2 +- lib/teslamate/locations/geocoder.ex | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tesla_api.ex b/lib/tesla_api.ex index 14f2269a6a..ec533257c1 100644 --- a/lib/tesla_api.ex +++ b/lib/tesla_api.ex @@ -12,6 +12,6 @@ defmodule TeslaApi do plug Tesla.Middleware.Logger, debug: true, log_level: &log_level/1 defp log_level(%Tesla.Env{} = env) when env.status >= 500, do: :warning - defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :info - defp log_level(%Tesla.Env{}), do: :debug + defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: Mix.Project.config()[:logger][:level] || :info + defp log_level(%Tesla.Env{}), do: Mix.Project.config()[:logger][:level] || :info end diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index e045710b6d..38ab5cfcc7 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -94,5 +94,5 @@ defmodule TeslaApi.Auth do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :error - defp log_level(%Tesla.Env{}), do: :info + defp log_level(%Tesla.Env{}), do: Mix.Project.config()[:logger][:level] || :info end diff --git a/lib/teslamate/locations/geocoder.ex b/lib/teslamate/locations/geocoder.ex index ae4771ee09..69a08644ce 100644 --- a/lib/teslamate/locations/geocoder.ex +++ b/lib/teslamate/locations/geocoder.ex @@ -179,5 +179,5 @@ defmodule TeslaMate.Locations.Geocoder do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :warning - defp log_level(%Tesla.Env{}), do: :info + defp log_level(%Tesla.Env{}), do: Mix.Project.config()[:logger][:level] || :info end From 1ef1919b8956e0532e7dc09e7940405dd377f144 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 12 Jun 2024 09:28:54 +0200 Subject: [PATCH 44/52] format --- lib/tesla_api.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tesla_api.ex b/lib/tesla_api.ex index ec533257c1..635482caa9 100644 --- a/lib/tesla_api.ex +++ b/lib/tesla_api.ex @@ -12,6 +12,9 @@ defmodule TeslaApi do plug Tesla.Middleware.Logger, debug: true, log_level: &log_level/1 defp log_level(%Tesla.Env{} = env) when env.status >= 500, do: :warning - defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: Mix.Project.config()[:logger][:level] || :info + + defp log_level(%Tesla.Env{} = env) when env.status >= 400, + do: Mix.Project.config()[:logger][:level] || :info + defp log_level(%Tesla.Env{}), do: Mix.Project.config()[:logger][:level] || :info end From 99051702b3871dbad4a37b0e761fafd93ad6f34c Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 12 Jun 2024 09:41:43 +0200 Subject: [PATCH 45/52] use LOG_LEVEL env var to facilitate debug --- config/prod.exs | 5 +---- lib/tesla_api.ex | 4 ++-- lib/tesla_api/auth.ex | 2 +- lib/teslamate/locations/geocoder.ex | 2 +- lib/teslamate/updater.ex | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/config/prod.exs b/config/prod.exs index 9617cd5eca..25b92479a9 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -6,11 +6,8 @@ config :teslamate, TeslaMateWeb.Endpoint, server: true, version: Application.spec(:teslamate, :vsn) -log_level = System.get_env("LOG_LEVEL", "info") -log_level_atom = String.to_existing_atom(log_level) - config :logger, - level: log_level_atom + level: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) config :logger, :console, format: "$date $time $metadata[$level] $message\n", diff --git a/lib/tesla_api.ex b/lib/tesla_api.ex index 635482caa9..77e59af4cf 100644 --- a/lib/tesla_api.ex +++ b/lib/tesla_api.ex @@ -14,7 +14,7 @@ defmodule TeslaApi do defp log_level(%Tesla.Env{} = env) when env.status >= 500, do: :warning defp log_level(%Tesla.Env{} = env) when env.status >= 400, - do: Mix.Project.config()[:logger][:level] || :info + do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) - defp log_level(%Tesla.Env{}), do: Mix.Project.config()[:logger][:level] || :info + defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) end diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index 38ab5cfcc7..aabcd273d5 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -94,5 +94,5 @@ defmodule TeslaApi.Auth do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :error - defp log_level(%Tesla.Env{}), do: Mix.Project.config()[:logger][:level] || :info + defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) end diff --git a/lib/teslamate/locations/geocoder.ex b/lib/teslamate/locations/geocoder.ex index 69a08644ce..8a4d54f081 100644 --- a/lib/teslamate/locations/geocoder.ex +++ b/lib/teslamate/locations/geocoder.ex @@ -179,5 +179,5 @@ defmodule TeslaMate.Locations.Geocoder do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :warning - defp log_level(%Tesla.Env{}), do: Mix.Project.config()[:logger][:level] || :info + defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) end diff --git a/lib/teslamate/updater.ex b/lib/teslamate/updater.ex index 4767f92ee0..736149c4d2 100644 --- a/lib/teslamate/updater.ex +++ b/lib/teslamate/updater.ex @@ -114,5 +114,5 @@ defmodule TeslaMate.Updater do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :warning - defp log_level(%Tesla.Env{}), do: :debug + defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "debug")) end From b3045ea6ac4bfe7cf974172106061c81c7b6c0eb Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 15 Jun 2024 00:25:15 +0200 Subject: [PATCH 46/52] revert on log_level --- config/prod.exs | 2 +- lib/tesla_api.ex | 4 ++-- lib/tesla_api/auth.ex | 2 +- lib/teslamate/locations/geocoder.ex | 2 +- lib/teslamate/updater.ex | 2 +- website/docs/configuration/environment_variables.md | 1 - 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config/prod.exs b/config/prod.exs index 25b92479a9..065672dc49 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -7,7 +7,7 @@ config :teslamate, TeslaMateWeb.Endpoint, version: Application.spec(:teslamate, :vsn) config :logger, - level: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) + level: :info config :logger, :console, format: "$date $time $metadata[$level] $message\n", diff --git a/lib/tesla_api.ex b/lib/tesla_api.ex index 77e59af4cf..a4bd106667 100644 --- a/lib/tesla_api.ex +++ b/lib/tesla_api.ex @@ -14,7 +14,7 @@ defmodule TeslaApi do defp log_level(%Tesla.Env{} = env) when env.status >= 500, do: :warning defp log_level(%Tesla.Env{} = env) when env.status >= 400, - do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) + do: :info - defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) + defp log_level(%Tesla.Env{}), do: :info end diff --git a/lib/tesla_api/auth.ex b/lib/tesla_api/auth.ex index aabcd273d5..e045710b6d 100644 --- a/lib/tesla_api/auth.ex +++ b/lib/tesla_api/auth.ex @@ -94,5 +94,5 @@ defmodule TeslaApi.Auth do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :error - defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) + defp log_level(%Tesla.Env{}), do: :info end diff --git a/lib/teslamate/locations/geocoder.ex b/lib/teslamate/locations/geocoder.ex index 8a4d54f081..ae4771ee09 100644 --- a/lib/teslamate/locations/geocoder.ex +++ b/lib/teslamate/locations/geocoder.ex @@ -179,5 +179,5 @@ defmodule TeslaMate.Locations.Geocoder do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :warning - defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "info")) + defp log_level(%Tesla.Env{}), do: :info end diff --git a/lib/teslamate/updater.ex b/lib/teslamate/updater.ex index 736149c4d2..4767f92ee0 100644 --- a/lib/teslamate/updater.ex +++ b/lib/teslamate/updater.ex @@ -114,5 +114,5 @@ defmodule TeslaMate.Updater do end defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :warning - defp log_level(%Tesla.Env{}), do: String.to_existing_atom(System.get_env("LOG_LEVEL", "debug")) + defp log_level(%Tesla.Env{}), do: :debug end diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 52d99dbe96..f46ac58672 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -51,4 +51,3 @@ TeslaMate accepts the following environment variables for runtime configuration: | **POLLING_ONLINE_INTERVAL** | Default interval between API fetch when vehicle is online | 60 | | **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch | 15 | | **POLLING_MINIMUM_INTERVAL** | Minimum interval between API fetch | 5 | -| **LOG_LEVEL** | Log verbosity (debug, info, warn or error) | info | From d3c67d27affbe4bf6cd1945cc60d48ba29ed213c Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 15 Jun 2024 00:40:15 +0200 Subject: [PATCH 47/52] format --- lib/tesla_api.ex | 4 +--- lib/teslamate/vehicles/vehicle.ex | 11 +++-------- website/docs/configuration/environment_variables.md | 12 ++++++------ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/tesla_api.ex b/lib/tesla_api.ex index a4bd106667..3bcc129f39 100644 --- a/lib/tesla_api.ex +++ b/lib/tesla_api.ex @@ -13,8 +13,6 @@ defmodule TeslaApi do defp log_level(%Tesla.Env{} = env) when env.status >= 500, do: :warning - defp log_level(%Tesla.Env{} = env) when env.status >= 400, - do: :info - + defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :info defp log_level(%Tesla.Env{}), do: :info end diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index e4e9c44206..d3bcd2ff6d 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -28,7 +28,6 @@ defmodule TeslaMate.Vehicles.Vehicle do end @asleep_interval 30 - @minimum_interval 5 @drive_timeout_min 15 @@ -42,11 +41,11 @@ defmodule TeslaMate.Vehicles.Vehicle do end def asleep_interval, do: interval("POLLING_ASLEEP_INTERVAL", @asleep_interval) - def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", @minimum_interval) + def driving_interval, do: interval("POLLING_DRIVING_INTERVAL", 2.5) def default_interval, do: interval("POLLING_DEFAULT_INTERVAL", 15) def online_interval, do: interval("POLLING_ONLINE_INTERVAL", 60) def charging_interval, do: interval("POLLING_CHARGING_INTERVAL", 5) - def minimum_interval, do: interval("POLLING_MINIMUM_INTERVAL", @minimum_interval) + def minimum_interval, do: interval("POLLING_MINIMUM_INTERVAL", 0) def identify(%Vehicle{display_name: name, vehicle_config: config}) do case config do @@ -1660,11 +1659,7 @@ defmodule TeslaMate.Vehicles.Vehicle do defp parse_timestamp(ts), do: DateTime.from_unix!(ts, :millisecond) - defp schedule_fetch(%Data{} = data), - do: schedule_fetch(10, :seconds, data) - - defp schedule_fetch(0, %Data{} = data), - do: schedule_fetch(0, :seconds, data) + defp schedule_fetch(%Data{} = data), do: schedule_fetch(10, :seconds, data) defp schedule_fetch(n, %Data{} = data), do: schedule_fetch(n |> max(minimum_interval()), :seconds, data) diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index f46ac58672..65d126748a 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -45,9 +45,9 @@ TeslaMate accepts the following environment variables for runtime configuration: | **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on TESLA_WSS_HOST if `true` | | | **TESLA_WSS_USE_VIN** | Use the `vin` field instead of `vid` to connect stream if `true` | | | **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | | -| **POLLING_ASLEEP_INTERVAL** | Interval between API fetch when vehicle is asleep | 30 | -| **POLLING_CHARGING_INTERVAL** | Minimum interval between API fetch when vehicle is charging | 5 | -| **POLLING_DRIVING_INTERVAL** | Interval between API fetch when vehicle is driving | 2.5 | -| **POLLING_ONLINE_INTERVAL** | Default interval between API fetch when vehicle is online | 60 | -| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch | 15 | -| **POLLING_MINIMUM_INTERVAL** | Minimum interval between API fetch | 5 | +| **POLLING_ASLEEP_INTERVAL** | Interval between API fetch when vehicle is asleep (in seconds) | 30 | +| **POLLING_CHARGING_INTERVAL** | Minimum interval between API fetch when vehicle is charging (in seconds) | 5 | +| **POLLING_DRIVING_INTERVAL** | Interval between API fetch when vehicle is driving (in seconds) | 2.5 | +| **POLLING_ONLINE_INTERVAL** | Interval between API fetch when vehicle is online (in seconds) | 60 | +| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch (in seconds) | 15 | +| **POLLING_MINIMUM_INTERVAL** | Minimum interval in between API fetch. No minimum by default. | 0 | From 550a7b042ee63e7ee818e1fbd7781e9a688070f6 Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 15 Jun 2024 00:40:56 +0200 Subject: [PATCH 48/52] typo --- lib/tesla_api.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tesla_api.ex b/lib/tesla_api.ex index 3bcc129f39..88c693745c 100644 --- a/lib/tesla_api.ex +++ b/lib/tesla_api.ex @@ -14,5 +14,5 @@ defmodule TeslaApi do defp log_level(%Tesla.Env{} = env) when env.status >= 500, do: :warning defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :info - defp log_level(%Tesla.Env{}), do: :info + defp log_level(%Tesla.Env{}), do: :debug end From 7098cc9cb820e16ff6d071d9735718721235513c Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 15 Jun 2024 01:32:13 +0200 Subject: [PATCH 49/52] format again --- lib/tesla_api.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tesla_api.ex b/lib/tesla_api.ex index 88c693745c..14f2269a6a 100644 --- a/lib/tesla_api.ex +++ b/lib/tesla_api.ex @@ -12,7 +12,6 @@ defmodule TeslaApi do plug Tesla.Middleware.Logger, debug: true, log_level: &log_level/1 defp log_level(%Tesla.Env{} = env) when env.status >= 500, do: :warning - defp log_level(%Tesla.Env{} = env) when env.status >= 400, do: :info defp log_level(%Tesla.Env{}), do: :debug end From a5156828e748290d88c3cbd50b56ddff6ec7eefc Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 15 Jun 2024 23:55:07 +0200 Subject: [PATCH 50/52] revert on default error intervals --- lib/teslamate/vehicles/vehicle.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index d3bcd2ff6d..f9aad120b0 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -418,10 +418,10 @@ defmodule TeslaMate.Vehicles.Vehicle do interval = case state do - {:driving, _, _} -> round(default_interval() * 2 / 3) - {:charging, _} -> default_interval() - :online -> round(default_interval() * 4 / 3) - _ -> default_interval() * 2 + {:driving, _, _} -> 10 + {:charging, _} -> 15 + :online -> 20 + _ -> 30 end {:keep_state, data, From a777c790a5e32df645ae13d8588439ac681cada0 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 16 Jun 2024 00:03:51 +0200 Subject: [PATCH 51/52] Add a note in MD about polling settings --- website/docs/configuration/environment_variables.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/configuration/environment_variables.md b/website/docs/configuration/environment_variables.md index 65d126748a..82e83cd96a 100644 --- a/website/docs/configuration/environment_variables.md +++ b/website/docs/configuration/environment_variables.md @@ -45,9 +45,9 @@ TeslaMate accepts the following environment variables for runtime configuration: | **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on TESLA_WSS_HOST if `true` | | | **TESLA_WSS_USE_VIN** | Use the `vin` field instead of `vid` to connect stream if `true` | | | **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | | -| **POLLING_ASLEEP_INTERVAL** | Interval between API fetch when vehicle is asleep (in seconds) | 30 | -| **POLLING_CHARGING_INTERVAL** | Minimum interval between API fetch when vehicle is charging (in seconds) | 5 | -| **POLLING_DRIVING_INTERVAL** | Interval between API fetch when vehicle is driving (in seconds) | 2.5 | -| **POLLING_ONLINE_INTERVAL** | Interval between API fetch when vehicle is online (in seconds) | 60 | -| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch (in seconds) | 15 | -| **POLLING_MINIMUM_INTERVAL** | Minimum interval in between API fetch. No minimum by default. | 0 | +| **POLLING_ASLEEP_INTERVAL** | Interval between API fetch when the vehicle is asleep (in seconds). **Important: Do not alter this setting unless you are certain of the implications.** | 30 | +| **POLLING_CHARGING_INTERVAL** | Minimum interval between API fetch when the vehicle is charging (in seconds). **Important: Do not alter this setting unless you are certain of the implications.** | 5 | +| **POLLING_DRIVING_INTERVAL** | Interval between API fetch when the vehicle is driving (in seconds). **Important: Do not alter this setting unless you are certain of the implications.** | 2.5 | +| **POLLING_ONLINE_INTERVAL** | Interval between API fetch when the vehicle is online (in seconds). **Important: Do not alter this setting unless you are certain of the implications.** | 60 | +| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch (in seconds). **Important: Do not alter this setting unless you are certain of the implications.** | 15 | +| **POLLING_MINIMUM_INTERVAL** | Minimum interval between API fetch. No minimum by default. **Important: Do not alter this setting unless you are certain of the implications.** | 0 | From e1b3bcc0f7f9a23446248adceb4cc4aaf2d2af2d Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 19 Jun 2024 00:50:47 +0200 Subject: [PATCH 52/52] not let the user set intervals via env variables shorter than our defaults --- lib/teslamate/vehicles/vehicle.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index f9aad120b0..1047b715e2 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -36,7 +36,7 @@ defmodule TeslaMate.Vehicles.Vehicle do System.get_env(env_var) |> case do nil -> default - interval -> String.to_integer(interval) + interval -> String.to_integer(interval) |> max(default) end end