Skip to content

Commit

Permalink
geo coordinates seem to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
zivillian committed Aug 8, 2024
1 parent 312b600 commit fa63695
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libgwmapi/DTO/Vehicle/VehicleStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public class VehicleStatus
public VehicleStatusItems[] Items { get; set; }

[JsonPropertyName("latitude")]
public double Latitude { get; set; }
public double? Latitude { get; set; }

[JsonPropertyName("longitude")]
public double Longitude { get; set; }
public double? Longitude { get; set; }

[JsonPropertyName("oilQty")]
public object OilQty { get; set; }
Expand Down
8 changes: 6 additions & 2 deletions ora2mqtt/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ private async Task PublishStatusAsync(IMqttClient mqtt, GwmApiClient gwm, Cancel
var topicPrefix = $"GWM/{vehicle.Vin}/status";
await PublishMessageAsync(mqtt, $"{topicPrefix}/AcquisitionTime", status.AcquisitionTime, cancellationToken);
await PublishMessageAsync(mqtt, $"{topicPrefix}/UpdateTime", status.UpdateTime, cancellationToken);
await PublishMessageAsync(mqtt, $"{topicPrefix}/Latitude", status.Latitude, cancellationToken);
await PublishMessageAsync(mqtt, $"{topicPrefix}/Longitude", status.Longitude, cancellationToken);
if (status.Latitude.HasValue && status.Longitude.HasValue)
{
await PublishMessageAsync(mqtt, $"{topicPrefix}/Latitude", status.Latitude.Value, cancellationToken);
await PublishMessageAsync(mqtt, $"{topicPrefix}/Longitude", status.Longitude.Value, cancellationToken);
}

foreach (var item in status.Items)
{
if (item.Value is null) continue;
Expand Down

0 comments on commit fa63695

Please sign in to comment.