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

geo coordinates seem to be optional #24

Merged
merged 1 commit into from
Aug 9, 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
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
Loading