From 43a9cb860f17b9cf3b8dc14736e1034dc629ae6e Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 8 Oct 2020 10:33:56 +0200 Subject: [PATCH] Display update version in the homescreen update tooltip (#976) * Make update_version of the API available * Add update version to the update tooltip * Fix formatting * Update translations to reflect the new tooltip * Fix car controller test * Add update_version to the mqtt documentation --- lib/teslamate/vehicles/vehicle/summary.ex | 12 +++++-- .../live/car_live/summary.html.leex | 2 +- priv/gettext/da/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/de/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/default.pot | 14 ++++---- priv/gettext/en/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/es/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/fr/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/ko/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/nb/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/nl/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/sv/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/zh_Hans/LC_MESSAGES/default.po | 14 ++++---- priv/gettext/zh_Hant/LC_MESSAGES/default.po | 14 ++++---- test/support/vehicle_case.ex | 12 +++++-- .../mqtt/pubsub/vehicle_subscriber_test.exs | 1 + .../vehicles/vehicle/updating_test.exs | 32 ++++++++++++++----- .../controllers/car_controller_test.exs | 4 +-- .../live/car_summary_live_test.exs | 8 +++-- website/docs/integrations/mqtt.md | 1 + 20 files changed, 138 insertions(+), 102 deletions(-) diff --git a/lib/teslamate/vehicles/vehicle/summary.ex b/lib/teslamate/vehicles/vehicle/summary.ex index 542a87d247..250b504f99 100644 --- a/lib/teslamate/vehicles/vehicle/summary.ex +++ b/lib/teslamate/vehicles/vehicle/summary.ex @@ -11,7 +11,7 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do speed outside_temp inside_temp is_climate_on is_preconditioning locked sentry_mode plugged_in scheduled_charging_start_time charge_limit_soc charger_power windows_open doors_open odometer shift_state charge_port_door_open time_to_full_charge charger_phases - charger_actual_current charger_voltage version update_available is_user_present geofence + charger_actual_current charger_voltage version update_available update_version is_user_present geofence model trim_badging exterior_color wheel_type spoiler_type trunk_open frunk_open elevation )a @@ -113,7 +113,8 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do frunk_open: frunk_open(vehicle), is_user_present: get_in_struct(vehicle, [:vehicle_state, :is_user_present]), version: version(vehicle), - update_available: update_available(vehicle) + update_available: update_available(vehicle), + update_version: update_version(vehicle) } end @@ -179,6 +180,13 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do end end + defp update_version(vehicle) do + case get_in_struct(vehicle, [:vehicle_state, :software_update, :version]) do + version when is_binary(version) -> List.first(String.split(version, " ")) + nil -> nil + end + end + defp to_datetime(val) when val in [nil, :unknown], do: val defp to_datetime(ts), do: DateTime.from_unix!(ts) diff --git a/lib/teslamate_web/live/car_live/summary.html.leex b/lib/teslamate_web/live/car_live/summary.html.leex index 8799ebc677..be3ec4d5f8 100644 --- a/lib/teslamate_web/live/car_live/summary.html.leex +++ b/lib/teslamate_web/live/car_live/summary.html.leex @@ -71,7 +71,7 @@ <% end %> <%= if @summary.update_available do %> - + <% end %> diff --git a/priv/gettext/da/LC_MESSAGES/default.po b/priv/gettext/da/LC_MESSAGES/default.po index 372563b05e..a649b4dcdf 100644 --- a/priv/gettext/da/LC_MESSAGES/default.po +++ b/priv/gettext/da/LC_MESSAGES/default.po @@ -221,12 +221,12 @@ msgid "Driver present" msgstr "Fører tilstede" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "afbryd forsøg på at sove" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "forsøg at sove" @@ -321,11 +321,6 @@ msgstr "Udetemperatur" msgid "Version" msgstr "Version" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "Softwareopdatering tilgængelig" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -578,3 +573,8 @@ msgstr "Bagklap åben" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "Softwareopdatering tilgængelig (%{version})" diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index 29572c0f89..11e57de869 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -221,12 +221,12 @@ msgid "Driver present" msgstr "Fahrer anwesend" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "Schlafversuch abbrechen" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "versuchen zu schlafen" @@ -321,11 +321,6 @@ msgstr "Außentemperatur" msgid "Version" msgstr "" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "Software Update verfügbar" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -578,3 +573,8 @@ msgstr "Kofferraum is geöffnet" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "Pro Minute" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "Software Update verfügbar (%{version})" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index ac637d2c5b..273be14f63 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -220,12 +220,12 @@ msgid "Driver present" msgstr "" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "" @@ -320,11 +320,6 @@ msgstr "" msgid "Version" msgstr "" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -577,3 +572,8 @@ msgstr "" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index 58c37edd1e..3e6aec8e8e 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -221,12 +221,12 @@ msgid "Driver present" msgstr "" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "" @@ -321,11 +321,6 @@ msgstr "" msgid "Version" msgstr "" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -578,3 +573,8 @@ msgstr "" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "" diff --git a/priv/gettext/es/LC_MESSAGES/default.po b/priv/gettext/es/LC_MESSAGES/default.po index 3d6392e196..1405a14556 100644 --- a/priv/gettext/es/LC_MESSAGES/default.po +++ b/priv/gettext/es/LC_MESSAGES/default.po @@ -221,12 +221,12 @@ msgid "Driver present" msgstr "Conductor presente" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "cancelar intento de poner en estado reposo" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "intentando poner en estado reposo" @@ -321,11 +321,6 @@ msgstr "Temperatura en el exterior" msgid "Version" msgstr "Versión" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "Actualización de software disponible" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -578,3 +573,8 @@ msgstr "" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "Actualización de software disponible (%{version})" diff --git a/priv/gettext/fr/LC_MESSAGES/default.po b/priv/gettext/fr/LC_MESSAGES/default.po index 429b35599a..11679de0d0 100644 --- a/priv/gettext/fr/LC_MESSAGES/default.po +++ b/priv/gettext/fr/LC_MESSAGES/default.po @@ -220,12 +220,12 @@ msgid "Driver present" msgstr "Conducteur présent" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "Annuler la tentative de sommeil" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "Tentative de mise en veille" @@ -320,11 +320,6 @@ msgstr "Température extérieure" msgid "Version" msgstr "Version" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "Mise à jour disponible" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -577,3 +572,8 @@ msgstr "Le coffre est ouvert" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "Mise à jour disponible (%{version})" diff --git a/priv/gettext/ko/LC_MESSAGES/default.po b/priv/gettext/ko/LC_MESSAGES/default.po index 0c9fe9005a..8fcbccb784 100644 --- a/priv/gettext/ko/LC_MESSAGES/default.po +++ b/priv/gettext/ko/LC_MESSAGES/default.po @@ -221,12 +221,12 @@ msgid "Driver present" msgstr "현재 운전자" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "절전모드 시도 취소" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "절전모드 시도" @@ -321,11 +321,6 @@ msgstr "실외 온도" msgid "Version" msgstr "소프트웨어 버전" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "소프트웨어 업데이트 가능" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -578,3 +573,8 @@ msgstr "트렁크가 열려있습니다." #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "소프트웨어 업데이트 가능 (%{version})" diff --git a/priv/gettext/nb/LC_MESSAGES/default.po b/priv/gettext/nb/LC_MESSAGES/default.po index 5d3c3f19be..cc7191e116 100644 --- a/priv/gettext/nb/LC_MESSAGES/default.po +++ b/priv/gettext/nb/LC_MESSAGES/default.po @@ -222,12 +222,12 @@ msgid "Driver present" msgstr "Fører er tilstede" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "Avbryt dvale" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "forsøk på dvale" @@ -322,11 +322,6 @@ msgstr "Temperatur utvendig" msgid "Version" msgstr "Software versjon" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "Ny software tilgjengelig" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -579,3 +574,8 @@ msgstr "Bagasjeluken er åpen" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "Ny software tilgjengelig (%{version})" diff --git a/priv/gettext/nl/LC_MESSAGES/default.po b/priv/gettext/nl/LC_MESSAGES/default.po index 3351e43ed1..9998e0f29e 100644 --- a/priv/gettext/nl/LC_MESSAGES/default.po +++ b/priv/gettext/nl/LC_MESSAGES/default.po @@ -221,12 +221,12 @@ msgid "Driver present" msgstr "Bestuurder aanwezig" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "annuleer slaap-poging" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "probeer te slapen" @@ -321,11 +321,6 @@ msgstr "Buitentemperatuur" msgid "Version" msgstr "Versie" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "Software-update beschikbaar" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -578,3 +573,8 @@ msgstr "Kofferbak is open" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "Per minuut" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "Software-update beschikbaar (%{version})" diff --git a/priv/gettext/sv/LC_MESSAGES/default.po b/priv/gettext/sv/LC_MESSAGES/default.po index faaf164222..863e40ac66 100644 --- a/priv/gettext/sv/LC_MESSAGES/default.po +++ b/priv/gettext/sv/LC_MESSAGES/default.po @@ -221,12 +221,12 @@ msgid "Driver present" msgstr "Förare närvarande" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "avbryt försök att vila" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "försök att vila" @@ -321,11 +321,6 @@ msgstr "Utetemperatur" msgid "Version" msgstr "" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "Mjukvaruuppdatering tillgänglig" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -578,3 +573,8 @@ msgstr "Bakluckan är öppen" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "Mjukvaruuppdatering tillgänglig (%{version})" diff --git a/priv/gettext/zh_Hans/LC_MESSAGES/default.po b/priv/gettext/zh_Hans/LC_MESSAGES/default.po index d11db2f332..396c46b8ea 100644 --- a/priv/gettext/zh_Hans/LC_MESSAGES/default.po +++ b/priv/gettext/zh_Hans/LC_MESSAGES/default.po @@ -222,12 +222,12 @@ msgid "Driver present" msgstr "当前驾驶员" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "取消休眠" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "尝试休眠" @@ -322,11 +322,6 @@ msgstr "车外温度" msgid "Version" msgstr "当前固件版本" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "有可用更新" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -579,3 +574,8 @@ msgstr "行李箱已打开" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "有可用更新 (%{version})" diff --git a/priv/gettext/zh_Hant/LC_MESSAGES/default.po b/priv/gettext/zh_Hant/LC_MESSAGES/default.po index 490b806ea2..5ae1eba69e 100644 --- a/priv/gettext/zh_Hant/LC_MESSAGES/default.po +++ b/priv/gettext/zh_Hant/LC_MESSAGES/default.po @@ -220,12 +220,12 @@ msgid "Driver present" msgstr "駕駛中" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:298 +#: lib/teslamate_web/live/car_live/summary.html.leex:297 msgid "cancel sleep attempt" msgstr "取消休眠" #, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:293 +#: lib/teslamate_web/live/car_live/summary.html.leex:292 msgid "try to sleep" msgstr "嘗試休眠" @@ -322,11 +322,6 @@ msgstr "車外溫度" msgid "Version" msgstr "車輛軟體版本" -#, elixir-format -#: lib/teslamate_web/live/car_live/summary.html.leex:74 -msgid "Software Update available" -msgstr "有可用更新" - #, elixir-format #: lib/teslamate_web/live/car_live/summary.html.leex:79 msgid "Health check failed" @@ -577,3 +572,8 @@ msgstr "後行李箱已打開" #: lib/teslamate_web/live/geofence_live/form.html.leex:66 msgid "Per Minute" msgstr "" + +#, elixir-format, fuzzy +#: lib/teslamate_web/live/car_live/summary.html.leex:74 +msgid "Software Update available (%{version})" +msgstr "有可用更新 (%{version})" diff --git a/test/support/vehicle_case.ex b/test/support/vehicle_case.ex index c411a01164..747fc794a4 100644 --- a/test/support/vehicle_case.ex +++ b/test/support/vehicle_case.ex @@ -124,14 +124,20 @@ defmodule TeslaMate.VehicleCase do ) end - defp update_event(ts, state, version) do + defp update_event(ts, state, car_version, opts \\ []) do alias TeslaApi.Vehicle.State.VehicleState.SoftwareUpdate + update_version = Keyword.get(opts, :update_version) + online_event( vehicle_state: %{ timestamp: ts, - car_version: version, - software_update: %SoftwareUpdate{expected_duration_sec: 2700, status: state} + car_version: car_version, + software_update: %SoftwareUpdate{ + expected_duration_sec: 2700, + status: state, + version: update_version + } }, drive_state: %{timestamp: ts, latitude: 0.0, longitude: 0.0} ) diff --git a/test/teslamate/mqtt/pubsub/vehicle_subscriber_test.exs b/test/teslamate/mqtt/pubsub/vehicle_subscriber_test.exs index c9a22885e4..a165174444 100644 --- a/test/teslamate/mqtt/pubsub/vehicle_subscriber_test.exs +++ b/test/teslamate/mqtt/pubsub/vehicle_subscriber_test.exs @@ -49,6 +49,7 @@ defmodule TeslaMate.Mqtt.PubSub.VehicleSubscriberTest do plugged_in: false, version: "2019.42", update_available: false, + update_version: "2019.43", is_preconditioning: true, is_user_present: false, is_climate_on: true, diff --git a/test/teslamate/vehicles/vehicle/updating_test.exs b/test/teslamate/vehicles/vehicle/updating_test.exs index aafc9e1084..f74474fa75 100644 --- a/test/teslamate/vehicles/vehicle/updating_test.exs +++ b/test/teslamate/vehicles/vehicle/updating_test.exs @@ -8,7 +8,7 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do events = [ {:ok, online_event()}, - {:ok, update_event(now_ts - 1, "available", nil)}, + {:ok, update_event(now_ts - 1, "available", nil, update_version: "2019.8.5 3aaa23d")}, {:ok, update_event(now_ts, "installing", "2019.8.4 530d1d3")}, {:ok, update_event(now_ts + 1, "installing", "2019.8.4 530d1d3")}, {:ok, update_event(now_ts + 2, "installing", "2019.8.4 530d1d3")}, @@ -31,7 +31,12 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do assert_receive {:pubsub, {:broadcast, _server, _topic, - %Summary{state: :online, since: s0, update_available: true}}} + %Summary{ + state: :online, + since: s0, + update_available: true, + update_version: "2019.8.5" + }}} assert_receive {:start_update, ^car_id, [date: ^start_date]} @@ -62,7 +67,7 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do events = [ {:ok, online_event()}, - {:ok, update_event(now_ts - 1, "available", nil)}, + {:ok, update_event(now_ts - 1, "available", nil, update_version: "2019.8.5 3aaa23d")}, {:ok, update_event(now_ts, "installing", "2019.8.4 530d1d3")}, {:ok, update_event(now_ts + 1, "foo", "2019.8.5 3aaa23d")}, fn -> Process.sleep(10_000) end @@ -79,7 +84,12 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do assert_receive {:pubsub, {:broadcast, _server, _topic, - %Summary{state: :online, since: s0, update_available: true}}} + %Summary{ + state: :online, + since: s0, + update_available: true, + update_version: "2019.8.5" + }}} assert_receive {:start_update, ^car_id, date: ^start_date} assert_receive {:pubsub, {:broadcast, _server, _topic, %Summary{state: :updating, since: s1}}} @@ -102,8 +112,12 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do events = [ {:ok, online_event()}, - {:ok, update_event(now_ts, "installing", "2019.8.4 530d1d3")}, - {:ok, update_event(now_ts + 10, "available", "2019.8.4 530d1d3")}, + {:ok, + update_event(now_ts, "installing", "2019.8.4 530d1d3", update_version: "2019.8.5 3aaa23d")}, + {:ok, + update_event(now_ts + 10, "available", "2019.8.4 530d1d3", + update_version: "2019.8.5 3aaa23d" + )}, fn -> Process.sleep(10_000) end ] @@ -118,7 +132,8 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do assert_receive {:start_update, ^car_id, date: ^date} assert_receive {:pubsub, - {:broadcast, _server, _topic, %Summary{state: :updating, version: "2019.8.4"}}} + {:broadcast, _server, _topic, + %Summary{state: :updating, version: "2019.8.4", update_version: "2019.8.5"}}} assert_receive {:cancel_update, _upate_id}, 200 @@ -127,7 +142,8 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do assert_receive {:insert_position, ^car_id, %{}} assert_receive {:pubsub, - {:broadcast, _server, _topic, %Summary{state: :online, version: "2019.8.4"}}} + {:broadcast, _server, _topic, + %Summary{state: :online, version: "2019.8.4", update_version: "2019.8.5"}}} refute_receive _ end diff --git a/test/teslamate_web/controllers/car_controller_test.exs b/test/teslamate_web/controllers/car_controller_test.exs index 793f1cbf66..1f9bf18950 100644 --- a/test/teslamate_web/controllers/car_controller_test.exs +++ b/test/teslamate_web/controllers/car_controller_test.exs @@ -142,7 +142,7 @@ defmodule TeslaMateWeb.CarControllerTest do vehicle_state: %{ timestamp: 0, car_version: "2019.40.50.7 ad132c7b057e", - software_update: %{status: "available"}, + software_update: %{status: "available", version: "2020.4.1 4a4ad401858f"}, locked: true, sentry_mode: true, fd_window: 1, @@ -179,7 +179,7 @@ defmodule TeslaMateWeb.CarControllerTest do assert icon(html, "Sentry Mode", "shield-check") assert icon(html, "Windows open", "window-open") assert icon(html, "Doors open", "car-door") - assert icon(html, "Software Update available", "gift-outline") + assert icon(html, "Software Update available (2020.4.1)", "gift-outline") assert table_row(html, "Outside Temperature", "24 °C") assert table_row(html, "Inside Temperature", "23.2 °C") assert table_row(html, "Mileage", "42000 km") diff --git a/test/teslamate_web/live/car_summary_live_test.exs b/test/teslamate_web/live/car_summary_live_test.exs index 37b6b1d634..d58987ff9d 100644 --- a/test/teslamate_web/live/car_summary_live_test.exs +++ b/test/teslamate_web/live/car_summary_live_test.exs @@ -371,7 +371,8 @@ defmodule TeslaMateWeb.CarLive.SummaryTest do test "shows tag if update is available ", %{conn: conn} do events = [ {:ok, online_event()}, - {:ok, update_event(0, "available", nil)}, + {:ok, + update_event(0, "available", "2019.8.4 530d1d3", update_version: "2019.8.5 3aaad23")}, {:error, :unknown} ] @@ -389,7 +390,10 @@ defmodule TeslaMateWeb.CarLive.SummaryTest do |> Floki.parse_document!() |> Floki.find(".icons .icon") |> Enum.find( - &match?({"span", [_, {"data-tooltip", "Software Update available"}], _}, &1) + &match?( + {"span", [_, {"data-tooltip", "Software Update available (2019.8.5)"}], _}, + &1 + ) ) end diff --git a/website/docs/integrations/mqtt.md b/website/docs/integrations/mqtt.md index 9986cb8f09..b147f80cef 100644 --- a/website/docs/integrations/mqtt.md +++ b/website/docs/integrations/mqtt.md @@ -17,6 +17,7 @@ Vehicle data will be published to the following topics: | `teslamate/cars/$car_id/healthy` | true | Health status of the logger for that vehicle | | `teslamate/cars/$car_id/version` | 2019.32.12.2 | Software Version | | `teslamate/cars/$car_id/update_available` | false | Indicates if a software update is available | +| `teslamate/cars/$car_id/update_version` | 2019.32.12.3 | Software version of the available update | |   |   |   | | `teslamate/cars/$car_id/model` | 3 | Either "S", "3", "X" or "Y" | | `teslamate/cars/$car_id/trim_badging` | P100D | Trim badging |