Skip to content

Commit

Permalink
fix(TeslaFleetApiService): do not send commands if fleet telemetry is…
Browse files Browse the repository at this point in the history
… not connected but should be
  • Loading branch information
pkuehnel committed Jan 26, 2025
1 parent ad5fa5f commit a021e1a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions TeslaSolarCharger/Server/Services/TeslaFleetApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,18 @@ private async Task WakeUpCarIfNeeded(int carId)
private async Task<DtoGenericTeslaResponse<T>?> SendCommandToTeslaApi<T>(string vin, DtoFleetApiRequest fleetApiRequest, int? intParam = null) where T : class
{
logger.LogTrace("{method}({vin}, {@fleetApiRequest}, {intParam})", nameof(SendCommandToTeslaApi), vin, fleetApiRequest, intParam);
var fleetTelemetryEnabled = await teslaSolarChargerContext.Cars
.Where(c => c.Vin == vin)
.Select(c => c.UseFleetTelemetry)
.FirstAsync();
if (fleetTelemetryEnabled)
{
if(!fleetTelemetryWebSocketService.IsClientConnected(vin))
{
logger.LogError("Do not send command to car {vin} as Fleet Telemetry is enabled but client is not connected", vin);
return null;
}
}
if (await tokenHelper.GetBackendTokenState(true) != TokenState.UpToDate)
{
//Do not show base api not licensed error if not connected to backend
Expand Down

0 comments on commit a021e1a

Please sign in to comment.