Skip to content

Commit

Permalink
fix active_route location parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasehlert committed Jun 19, 2024
1 parent 32a535b commit 92657ea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/v1_TeslaMateAPICarsStatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,19 @@ func (s *statusCache) newMessage(c mqtt.Client, msg mqtt.Message) {
DistanceToArrival float64 `json:"miles_to_arrival"`
MinutesToArrival float64 `json:"minutes_to_arrival"`
TrafficMinutesDelay float64 `json:"traffic_minutes_delay"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Location struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"location"`
}
_ = json.Unmarshal(msg.Payload(), &tmp)
stat.MQTTDataActiveRoute.Destination = tmp.Destination
stat.MQTTDataActiveRoute.EnergyAtArrival = tmp.EnergyAtArrival
stat.MQTTDataActiveRoute.DistanceToArrival = milesToKilometers(tmp.DistanceToArrival)
stat.MQTTDataActiveRoute.MinutesToArrival = tmp.MinutesToArrival
stat.MQTTDataActiveRoute.TrafficMinutesDelay = tmp.TrafficMinutesDelay
stat.MQTTDataActiveRoute.Latitude = tmp.Latitude
stat.MQTTDataActiveRoute.Longitude = tmp.Longitude
stat.MQTTDataActiveRoute.Latitude = tmp.Location.Latitude
stat.MQTTDataActiveRoute.Longitude = tmp.Location.Longitude

// deprecated
case "latitude", "longitude", "active_route_destination", "active_route_latitude", "active_route_longitude":
Expand Down

0 comments on commit 92657ea

Please sign in to comment.