Skip to content

Commit

Permalink
Merge pull request #24 from zivillian/null_location
Browse files Browse the repository at this point in the history
geo coordinates seem to be optional
  • Loading branch information
zivillian committed Aug 9, 2024
2 parents 312b600 + fa63695 commit 2f401eb
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 2f401eb

Please sign in to comment.