Skip to content

Commit

Permalink
Changed when stream reports offline to fetch data and let result deci…
Browse files Browse the repository at this point in the history
…de the real state instead of switching directly to offline.
  • Loading branch information
micves committed Feb 13, 2024
1 parent f929657 commit 6a3bd7d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/teslamate/vehicles/vehicle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,12 @@ defmodule TeslaMate.Vehicles.Vehicle do

def handle_event(:info, {:stream, msg}, _state, data)
when msg in [:vehicle_offline] do
Logger.info("Stream reports vehicle as offline … ", car_id: data.car.id)
Logger.info("Stream reports vehicle as offline, fetching vehicle state ...",
car_id: data.car.id
)

{:next_state, :start, data,
[broadcast_fetch(false), {:next_event, :internal, {:update, {:offline, data.last_response}}}]}
# fetch data right away and let the result decide the real state
{:keep_state_and_data, schedule_fetch(0, data)}
end

def handle_event(:info, {:stream, stream_data}, _state, data) do
Expand Down

0 comments on commit 6a3bd7d

Please sign in to comment.