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

Develop #1775

Merged
merged 6 commits into from
Jan 25, 2025
Merged

Develop #1775

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
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,9 @@ public CarBasicConfigurationValidator(IConfigurationWrapper configurationWrapper
});




RuleFor(x => x.UseFleetTelemetry)
.CustomAsync(async (fleetTelemetryEnabled, context, cancellationToken) =>
{
if (fleetTelemetryEnabled != true)
{
return;
}
var tokenState = await tokenHelper.GetFleetApiTokenState(true);
if (tokenState != TokenState.UpToDate)
{
Expand All @@ -80,6 +74,10 @@ public CarBasicConfigurationValidator(IConfigurationWrapper configurationWrapper
{
context.AddFailure("The selected car is not compatible with Fleet Telemetry. Please disable Fleet Telemetry.");
}
else if (fleetTelemetryEnabled != true)
{
context.AddFailure("Enabling Fleet Telemetry is required and will be autodisabled if your car does not support it");
}
});

When(x => x.UseBle, () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ private async Task ConnectToFleetTelemetryApi(string vin, bool includeTrackingRe
using var client = new ClientWebSocket();
try
{
logger.LogInformation("Connecting Fleet Telemetry for car {vin}.", vin);
client.Options.SetRequestHeader("Authorization", $"Bearer {authToken.AccessToken}");
await client.ConnectAsync(new Uri(url), new CancellationTokenSource(_heartbeatsendTimeout).Token).ConfigureAwait(false);
var cancellation = new CancellationTokenSource();
Expand Down
13 changes: 5 additions & 8 deletions TeslaSolarCharger/Server/Services/TeslaFleetApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -937,15 +937,12 @@ await errorHandlingService.HandleError(nameof(TeslaFleetApiService), nameof(Send
}
}

if (fleetApiRequest.BleCompatible && (!await backendApiService.IsFleetApiLicensed(car.Vin, true)))
if (fleetApiRequest.RequestUrl != VehicleRequest.RequestUrl && (!await backendApiService.IsFleetApiLicensed(car.Vin, true)))
{
if (!car.UseBle)
{
await errorHandlingService.HandleError(nameof(TeslaFleetApiService), nameof(SendCommandToTeslaApi), $"Fleet API not licensed for car {car.Vin}",
"Can not send Fleet API commands to car as Fleet API is not licensed",
issueKeys.FleetApiNotLicensed, car.Vin, null).ConfigureAwait(false);
}

await errorHandlingService.HandleError(nameof(TeslaFleetApiService), nameof(SendCommandToTeslaApi), $"Fleet API not licensed for car {car.Vin}",
"Can not send Fleet API commands to car as Fleet API is not licensed",
issueKeys.FleetApiNotLicensed, car.Vin, null).ConfigureAwait(false);

logger.LogError("Can not send Fleet API commands to car {vin} as car is not licensed", car.Vin);
return null;
}
Expand Down
1 change: 0 additions & 1 deletion TeslaSolarCharger/Shared/Dtos/CarBasicConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class CarBasicConfiguration
{
public CarBasicConfiguration()

Check warning on line 9 in TeslaSolarCharger/Shared/Dtos/CarBasicConfiguration.cs

View workflow job for this annotation

GitHub Actions / Building TeslaSolarCharger image

Non-nullable property 'Vin' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
{
}

Expand Down Expand Up @@ -61,7 +61,6 @@
.WithMessage("MaximumAmpere must be greater than MinimumAmpere.");
RuleFor(x => x.UsableEnergy).GreaterThan(5);
RuleFor(x => x.ChargingPriority).GreaterThan(0);
RuleFor(x => x.UseFleetTelemetry).Equal(true).WithMessage("Enabling Fleet Telemetry is required and will be autodisabled if your car does not support it.");
});

}
Expand Down
Loading