Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navigation active route drive state data #3657

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/tesla_api/vehicle/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ defmodule TeslaApi.Vehicle.State do

defmodule Drive do
defstruct [
:active_route_destination,
:active_route_energy_at_arrival,
:active_route_latitude,
:active_route_longitude,
:active_route_miles_to_arrival,
:active_route_minutes_to_arrival,
:active_route_traffic_minutes_delay,
:gps_as_of,
:heading,
:latitude,
Expand All @@ -183,6 +190,13 @@ defmodule TeslaApi.Vehicle.State do

def result(drive) when is_map(drive) do
%__MODULE__{
active_route_destination: drive["active_route_destination"],
active_route_energy_at_arrival: drive["active_route_energy_at_arrival"],
active_route_latitude: drive["active_route_latitude"],
active_route_longitude: drive["active_route_longitude"],
active_route_miles_to_arrival: drive["active_route_miles_to_arrival"],
active_route_minutes_to_arrival: drive["active_route_minutes_to_arrival"],
active_route_traffic_minutes_delay: drive["active_route_traffic_minutes_delay"],
gps_as_of: drive["gps_as_of"],
heading: drive["heading"],
latitude: drive["latitude"],
Expand Down
4 changes: 4 additions & 0 deletions lib/teslamate/vehicles/vehicle/summary.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do
model trim_badging exterior_color wheel_type spoiler_type trunk_open frunk_open elevation power
charge_current_request charge_current_request_max tpms_pressure_fl tpms_pressure_fr tpms_pressure_rl tpms_pressure_rr
tpms_soft_warning_fl tpms_soft_warning_fr tpms_soft_warning_rl tpms_soft_warning_rr climate_keeper_mode
active_route_destination active_route_latitude active_route_longitude
)a

def into(nil, %{state: :start, healthy?: healthy?, car: car}) do
Expand Down Expand Up @@ -75,6 +76,9 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do
display_name: vehicle.display_name,

# Drive State
active_route_destination: get_in_struct(vehicle, [:drive_state, :active_route_destination]),
active_route_latitude: get_in_struct(vehicle, [:drive_state, :active_route_latitude]),
active_route_longitude: get_in_struct(vehicle, [:drive_state, :active_route_longitude]),
latitude: get_in_struct(vehicle, [:drive_state, :latitude]),
longitude: get_in_struct(vehicle, [:drive_state, :longitude]),
power: get_in_struct(vehicle, [:drive_state, :power]),
Expand Down
14 changes: 14 additions & 0 deletions test/teslamate/vehicles/vehicle/streaming_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ defmodule TeslaMate.Vehicles.Vehicle.StreamingTest do
end) =~ """
Discarded stale fetch result: [
now: %TeslaApi.Vehicle.State.Drive{
active_route_destination: nil,
active_route_energy_at_arrival: nil,
active_route_latitude: nil,
active_route_longitude: nil,
active_route_miles_to_arrival: nil,
active_route_minutes_to_arrival: nil,
active_route_traffic_minutes_delay: nil,
gps_as_of: nil,
heading: nil,
latitude: 42.91,
Expand All @@ -250,6 +257,13 @@ defmodule TeslaMate.Vehicles.Vehicle.StreamingTest do
timestamp: #{now_ts}
},
last: %TeslaApi.Vehicle.State.Drive{
active_route_destination: nil,
active_route_energy_at_arrival: nil,
active_route_latitude: nil,
active_route_longitude: nil,
active_route_miles_to_arrival: nil,
active_route_minutes_to_arrival: nil,
active_route_traffic_minutes_delay: nil,
gps_as_of: nil,
heading: 120,
latitude: 42.1,
Expand Down
3 changes: 3 additions & 0 deletions website/docs/integrations/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ Vehicle data will be published to the following topics:
| `teslamate/cars/$car_id/tpms_soft_warning_fr` | false | Indicates if the Tire pressure measure is soft warning, front right tire | |
| `teslamate/cars/$car_id/tpms_soft_warning_rl` | false | Indicates if the Tire pressure measure is soft warning, rear left tire | |
| `teslamate/cars/$car_id/tpms_soft_warning_rr` | false | Indicates if the Tire pressure measure is soft warning, rear right tire |
| `teslamate/cars/$car_id/active_route_destination` | Home | Navigation destination name |
| `teslamate/cars/$car_id/active_route_latitude` | 35.278131 | Navigation destination latitude |
| `teslamate/cars/$car_id/active_route_longitude` | 29.744801 | Navigation destination longitude |

:::note
`$car_id` usually starts at 1
Expand Down
Loading