From 5feb60230f52c3ec35bc91d67ccb0a2afe9e7d4a Mon Sep 17 00:00:00 2001 From: Adrian Kumpf Date: Mon, 28 Oct 2019 13:51:52 +0100 Subject: [PATCH] Temporarily switch to fork of ecto_enum --- CHANGELOG.md | 10 ++++---- lib/teslamate/vehicles/vehicle.ex | 32 +++++++++----------------- mix.exs | 2 +- mix.lock | 2 +- priv/gettext/de/LC_MESSAGES/default.po | 12 ++++------ priv/gettext/default.pot | 12 ++++------ priv/gettext/en/LC_MESSAGES/default.po | 12 ++++------ 7 files changed, 30 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dbe4160..a163c3e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,9 @@ We finally have **documentation**! Many thanks to [@ngardiner](https://github.co Previous versions of TeslaMate shipped with hard-coded efficiency values for the various Tesla models. These efficiency values are needed to calculate trip consumptions, because the Tesla API does not provide them directly. -The hard-coded efficiency values were _probably_ pretty accurate, but I could never ensure the correctness of all of them. In addition, the new Model S and X "Raven" could not be reliably identified because the Tesla API often returned wrong option codes for both. +The hard-coded efficiency values were _probably_ pretty accurate, but it was impossible to ensure the correctness of all of them. In addition, the new Model S and X "Raven" could not be reliably identified because the Tesla API returns wrong option codes for both. -This version eliminates the need to use hard-coded values and instead calculates them dynamically based on the recorded charging data. It takes **at least two** charging sessions to display the first estimate. Each charge will slightly improve the accuracy of the estimate, which is applied retroactively to all data. +This version eliminates the need to use hard-coded values and instead calculates them dynamically based on the recorded charging data. It takes **at least two** charges to display the first estimate. Each subsequent charge will continue to improve the accuracy of the estimate, which is applied retroactively to all data. #### Charge energy used @@ -20,7 +20,7 @@ In addition to the kWh added to the battery during the charge TeslaMate now calc Consider this feature somewhat "experimental". Theoretically, however, it should be pretty accurate as long as the vehicle has a stable internet connection while charging (other _paid_ Tesla loggers use the same calculation method). -It has been seen that some firmware versions have a bug which causes the wrong number of phases to be reported when charging. As a workaround, a phase correction can therefore be activated for a geo-fence. +Currently, a firmware bug in some vehicles causes the wrong number of phases to be reported when charging. As a workaround, a phase correction can therefore be activated per geo-fence. #### New MQTT Topics @@ -33,9 +33,9 @@ It has been seen that some firmware versions have a bug which causes the wrong n - Disable origin check by default to ease the installation of TeslaMate. - ⚠️ If you have a publicly exposed TeslaMate instance, I recommend to re-enable the origin check by adding the environment variable `CHECK_ORIGIN=true` (this requires that the variable `VIRTUAL_HOST` is present). + ⚠️ For publicly exposed TeslaMate instances it is advisable to re-enable the check by adding the environment variable `CHECK_ORIGIN=true`. -- Show icon indicators for various things (sentry mode, locked, windows open, pre-conditioning etc.) +- Show icon indicators for various things (sentry mode, vehicle locked, windows open, pre-conditioning etc.) - Various UI Tweaks - Show the precise duration of a drive in a tooltip - Serve gzipped assets diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex index c0f40afc..d619df23 100644 --- a/lib/teslamate/vehicles/vehicle.ex +++ b/lib/teslamate/vehicles/vehicle.ex @@ -462,12 +462,7 @@ defmodule TeslaMate.Vehicles.Vehicle do end end - def handle_event( - :internal, - {:update, {:online, now}}, - {:driving, {:offline, last}, drive}, - data - ) do + def handle_event(:internal, {:update, {:online, now}}, {:driving, {:offline, last}, drv}, data) do offline_start = parse_timestamp(last.drive_state.timestamp) offline_end = parse_timestamp(now.drive_state.timestamp) @@ -480,7 +475,7 @@ defmodule TeslaMate.Vehicles.Vehicle do cond do has_gained_range? and offline_min >= 5 -> - unless is_nil(drive), do: timeout_drive(drive, data) + unless is_nil(drv), do: timeout_drive(drv, data) {:ok, cproc} = call(data.deps.log, :start_charging_process, [ @@ -504,42 +499,37 @@ defmodule TeslaMate.Vehicles.Vehicle do {:next_event, :internal, {:update, {:online, now}}}} not has_gained_range? and offline_min >= @drive_timout_min -> - unless is_nil(drive), do: timeout_drive(drive, data) + unless is_nil(drv), do: timeout_drive(drv, data) {:next_state, :start, %Data{data | last_used: DateTime.utc_now()}, {:next_event, :internal, {:update, {:online, now}}}} - not is_nil(drive) -> - {:next_state, {:driving, :available, drive}, %Data{data | last_used: DateTime.utc_now()}, + not is_nil(drv) -> + {:next_state, {:driving, :available, drv}, %Data{data | last_used: DateTime.utc_now()}, {:next_event, :internal, {:update, {:online, now}}}} end end #### msg: :online - def handle_event( - :internal, - {:update, {:online, _} = e}, - {:driving, {:unavailable, _}, drive}, - d - ) do + def handle_event(:internal, {:update, {:online, _} = e}, {:driving, {:unavailable, _}, drv}, d) do Logger.info("Vehicle is back online", car_id: d.car.id) - {:next_state, {:driving, :available, drive}, %Data{d | last_used: DateTime.utc_now()}, + {:next_state, {:driving, :available, drv}, %Data{d | last_used: DateTime.utc_now()}, {:next_event, :internal, {:update, e}}} end - def handle_event(:internal, {:update, {:online, vehicle}}, {:driving, :available, drive}, data) do + def handle_event(:internal, {:update, {:online, vehicle}}, {:driving, :available, drv}, data) do case get(vehicle, [:drive_state, :shift_state]) do shift_state when shift_state in ["D", "R", "N"] -> - {:ok, _pos} = call(data.deps.log, :insert_position, [drive, create_position(vehicle)]) + {:ok, _pos} = call(data.deps.log, :insert_position, [drv, create_position(vehicle)]) - {:next_state, {:driving, :available, drive}, %Data{data | last_used: DateTime.utc_now()}, + {:next_state, {:driving, :available, drv}, %Data{data | last_used: DateTime.utc_now()}, [notify_subscribers(), schedule_fetch(@driving_interval)]} shift_state when is_nil(shift_state) or shift_state == "P" -> {:ok, %Log.Drive{distance: km, duration_min: min}} = - call(data.deps.log, :close_drive, [drive]) + call(data.deps.log, :close_drive, [drv]) Logger.info("Driving / Ended / #{round(km)} km – #{min} min", car_id: data.car.id) diff --git a/mix.exs b/mix.exs index cc2c7fdc..4a122cd9 100644 --- a/mix.exs +++ b/mix.exs @@ -49,7 +49,7 @@ defmodule TeslaMate.MixProject do # Custom {:tesla_api, github: "adriankumpf/tesla_api", branch: "v10"}, {:gen_state_machine, "~> 2.0"}, - {:ecto_enum, "~> 1.2"}, + {:ecto_enum, github: "dnsbty/ecto_enum", ref: "a69a9dde72cf98497606f9603bd46e3924979145"}, {:phoenix_live_view, "~> 0.1"}, {:floki, ">= 0.0.0", only: :test}, {:tortoise, "~> 0.9"}, diff --git a/mix.lock b/mix.lock index f376b28a..b3656065 100644 --- a/mix.lock +++ b/mix.lock @@ -7,7 +7,7 @@ "db_connection": {:hex, :db_connection, "2.1.1", "a51e8a2ee54ef2ae6ec41a668c85787ed40cb8944928c191280fe34c15b76ae5", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, "decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm"}, "ecto": {:hex, :ecto, "3.2.3", "51274df79862845b388733fddcf6f107d0c8c86e27abe7131fa98f8d30761bda", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, - "ecto_enum": {:hex, :ecto_enum, "1.3.2", "659f7251b6a201a236db9dceef0f713319f095a23ad1d8718efd7a3d3ef3e21b", [:mix], [{:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm"}, + "ecto_enum": {:git, "https://github.com/dnsbty/ecto_enum.git", "a69a9dde72cf98497606f9603bd46e3924979145", [ref: "a69a9dde72cf98497606f9603bd46e3924979145"]}, "ecto_sql": {:hex, :ecto_sql, "3.2.0", "751cea597e8deb616084894dd75cbabfdbe7255ff01e8c058ca13f0353a3921b", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.2.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "excoveralls": {:hex, :excoveralls, "0.12.0", "50e17a1b116fdb7facc2fe127a94db246169f38d7627b391376a0bc418413ce1", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "file_system": {:hex, :file_system, "0.2.7", "e6f7f155970975789f26e77b8b8d8ab084c59844d8ecfaf58cbda31c494d14aa", [:mix], [], "hexpm"}, diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index 4e22f725..8c59a3d7 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -73,8 +73,7 @@ msgstr "Wächtermodus" #, elixir-format #: lib/teslamate_web/templates/geo_fence/edit.html.leex:3 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:3 -#: lib/teslamate_web/templates/geo_fence/new.html.leex:3 +#: lib/teslamate_web/templates/geo_fence/index.html.leex:3 lib/teslamate_web/templates/geo_fence/new.html.leex:3 #: lib/teslamate_web/templates/settings/index.html.leex:3 msgid "Home" msgstr "Home" @@ -147,8 +146,7 @@ msgstr "Geo-Fence \"%{name}\" erfolgreich aktualisiert" #, elixir-format #: lib/teslamate_web/templates/geo_fence/edit.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/new.html.leex:4 +#: lib/teslamate_web/templates/geo_fence/index.html.leex:4 lib/teslamate_web/templates/geo_fence/new.html.leex:4 msgid "Geo-fences" msgstr "Geo-Fences" @@ -159,8 +157,7 @@ msgstr "Leerlaufzeit vor dem Einschlafversuch" #, elixir-format #: lib/teslamate_web/templates/geo_fence/form.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/form.html.leex:9 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:21 +#: lib/teslamate_web/templates/geo_fence/form.html.leex:9 lib/teslamate_web/templates/geo_fence/index.html.leex:21 msgid "Name" msgstr "" @@ -198,8 +195,7 @@ msgstr "Dauer des Schlafversuchs" #, elixir-format #: lib/teslamate_web/templates/settings/index.html.leex:94 -#: lib/teslamate_web/templates/settings/index.html.leex:94 -#: lib/teslamate_web/templates/settings/index.html.leex:113 +#: lib/teslamate_web/templates/settings/index.html.leex:94 lib/teslamate_web/templates/settings/index.html.leex:113 #: lib/teslamate_web/templates/settings/index.html.leex:113 msgid "min" msgstr "" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 3fe95ee7..19e5899d 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -72,8 +72,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/geo_fence/edit.html.leex:3 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:3 -#: lib/teslamate_web/templates/geo_fence/new.html.leex:3 +#: lib/teslamate_web/templates/geo_fence/index.html.leex:3 lib/teslamate_web/templates/geo_fence/new.html.leex:3 #: lib/teslamate_web/templates/settings/index.html.leex:3 msgid "Home" msgstr "" @@ -146,8 +145,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/geo_fence/edit.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/new.html.leex:4 +#: lib/teslamate_web/templates/geo_fence/index.html.leex:4 lib/teslamate_web/templates/geo_fence/new.html.leex:4 msgid "Geo-fences" msgstr "" @@ -158,8 +156,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/geo_fence/form.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/form.html.leex:9 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:21 +#: lib/teslamate_web/templates/geo_fence/form.html.leex:9 lib/teslamate_web/templates/geo_fence/index.html.leex:21 msgid "Name" msgstr "" @@ -197,8 +194,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/settings/index.html.leex:94 -#: lib/teslamate_web/templates/settings/index.html.leex:94 -#: lib/teslamate_web/templates/settings/index.html.leex:113 +#: lib/teslamate_web/templates/settings/index.html.leex:94 lib/teslamate_web/templates/settings/index.html.leex:113 #: lib/teslamate_web/templates/settings/index.html.leex:113 msgid "min" msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index bc9c6ea6..3ee1b551 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -73,8 +73,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/geo_fence/edit.html.leex:3 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:3 -#: lib/teslamate_web/templates/geo_fence/new.html.leex:3 +#: lib/teslamate_web/templates/geo_fence/index.html.leex:3 lib/teslamate_web/templates/geo_fence/new.html.leex:3 #: lib/teslamate_web/templates/settings/index.html.leex:3 msgid "Home" msgstr "" @@ -147,8 +146,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/geo_fence/edit.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/new.html.leex:4 +#: lib/teslamate_web/templates/geo_fence/index.html.leex:4 lib/teslamate_web/templates/geo_fence/new.html.leex:4 msgid "Geo-fences" msgstr "" @@ -159,8 +157,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/geo_fence/form.html.leex:4 -#: lib/teslamate_web/templates/geo_fence/form.html.leex:9 -#: lib/teslamate_web/templates/geo_fence/index.html.leex:21 +#: lib/teslamate_web/templates/geo_fence/form.html.leex:9 lib/teslamate_web/templates/geo_fence/index.html.leex:21 msgid "Name" msgstr "" @@ -198,8 +195,7 @@ msgstr "" #, elixir-format #: lib/teslamate_web/templates/settings/index.html.leex:94 -#: lib/teslamate_web/templates/settings/index.html.leex:94 -#: lib/teslamate_web/templates/settings/index.html.leex:113 +#: lib/teslamate_web/templates/settings/index.html.leex:94 lib/teslamate_web/templates/settings/index.html.leex:113 #: lib/teslamate_web/templates/settings/index.html.leex:113 msgid "min" msgstr ""