Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien committed Jun 14, 2024
1 parent b3045ea commit d3c67d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
4 changes: 1 addition & 3 deletions lib/tesla_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 3 additions & 8 deletions lib/teslamate/vehicles/vehicle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ defmodule TeslaMate.Vehicles.Vehicle do
end

@asleep_interval 30
@minimum_interval 5

@drive_timeout_min 15

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions website/docs/configuration/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

0 comments on commit d3c67d2

Please sign in to comment.