mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
Handle empty :vehicle_state when updating
This commit is contained in:
@@ -560,7 +560,12 @@ defmodule TeslaMate.Vehicles.Vehicle do
|
||||
end
|
||||
|
||||
def handle_event(:internal, {:update, {:online, vehicle}}, {:updating, update_id}, data) do
|
||||
case vehicle.vehicle_state.software_update do
|
||||
case Map.get(vehicle.vehicle_state || %{}, :software_update) do
|
||||
nil ->
|
||||
Logger.warn("Update / no data", car_id: data.car.id)
|
||||
|
||||
{:keep_state, %Data{data | last_used: DateTime.utc_now()}, schedule_fetch(5)}
|
||||
|
||||
%VehicleState.SoftwareUpdate{status: "installing"} ->
|
||||
{:keep_state, %Data{data | last_used: DateTime.utc_now()}, schedule_fetch(15)}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do
|
||||
{:ok, update_event("installing", "2019.8.4 530d1d3")},
|
||||
{:ok, update_event("installing", "2019.8.4 530d1d3")},
|
||||
{:ok, update_event("installing", "2019.8.4 530d1d3")},
|
||||
{:ok, %TeslaApi.Vehicle{state: "online", vehicle_state: nil}},
|
||||
{:error, :vehicle_unavailable},
|
||||
{:ok, %TeslaApi.Vehicle{state: "offline"}},
|
||||
{:ok, update_event("installing", "2019.8.4 530d1d3")},
|
||||
|
||||
@@ -64,11 +64,7 @@ defmodule TeslaMateWeb.GeoFenceLiveTest do
|
||||
assert ["Victory Column", "52.51452, 13.35014", "100 m", _] =
|
||||
html |> Floki.find("td") |> Enum.map(&Floki.text/1)
|
||||
|
||||
assert html =~
|
||||
~r/a class="button.*?" href="#" phx-click="flag" phx-value-id="#{id}"/
|
||||
|
||||
assert render_click(view, :flag, %{"id" => "#{id}"}) =~
|
||||
~r/a class="button.*?" href="#" phx-click="delete" phx-value-id="#{id}"/
|
||||
assert [{"a", _, _}] = html |> Floki.find("[data-id=#{id}]")
|
||||
|
||||
assert [{"tbody", [], []}] =
|
||||
view |> render_click(:delete, %{"id" => "#{id}"}) |> Floki.find("tbody")
|
||||
|
||||
Reference in New Issue
Block a user