Skip to content

Commit

Permalink
Merge pull request #1703 from pkuehnel/feat/useCloudTeslaTokens
Browse files Browse the repository at this point in the history
Feat/use cloud tesla tokens
  • Loading branch information
pkuehnel authored Jan 16, 2025
2 parents 25748b1 + 17f7e40 commit 59804b9
Show file tree
Hide file tree
Showing 102 changed files with 7,646 additions and 1,715 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface ITeslaSolarChargerContext
Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken());
DatabaseFacade Database { get; }
DbSet<SpotPrice> SpotPrices { get; set; }
DbSet<TeslaToken> TeslaTokens { get; set; }
DbSet<BackendToken> BackendTokens { get; set; }
DbSet<TscConfiguration> TscConfigurations { get; set; }
DbSet<Car> Cars { get; set; }
DbSet<RestValueConfiguration> RestValueConfigurations { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace TeslaSolarCharger.Model.Entities.TeslaSolarCharger;

public class BackendToken(string accessToken, string refreshToken)
{
public int Id { get; set; }
public string AccessToken { get; set; } = accessToken;
public string RefreshToken { get; set; } = refreshToken;
public DateTimeOffset ExpiresAtUtc { get; set; }
}
22 changes: 9 additions & 13 deletions TeslaSolarCharger.Model/Entities/TeslaSolarCharger/Car.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Car
public string? Name { get; set; }
public string? Vin { get; set; }
public TeslaCarFleetApiState? TeslaFleetApiState { get; set; }
public bool IsFleetTelemetryHardwareIncompatible { get; set; }
public ChargeMode ChargeMode { get; set; }
public int MinimumSoc { get; set; }
public DateTime LatestTimeToReachSoC { get; set; }
Expand Down Expand Up @@ -40,24 +41,19 @@ public class Car
public CarStateEnum? State { get; set; }

public bool VehicleCommandProtocolRequired { get; set; }
public DateTime? VehicleRateLimitedUntil { get; set; }
public DateTime? VehicleDataRateLimitedUntil { get; set; }
public DateTime? CommandsRateLimitedUntil { get; set; }
public DateTime? WakeUpRateLimitedUntil { get; set; }
public DateTime? ChargingCommandsRateLimitedUntil { get; set; }
public bool UseBle { get; set; }
public string? BleApiBaseUrl { get; set; }
public bool UseFleetTelemetry { get; set; }
public bool UseFleetTelemetryForLocationData { get; set; }
public bool IncludeTrackingRelevantFields { get; set; }
public bool IsAvailableInTeslaAccount { get; set; }

public string? WakeUpCalls { get; set; }
public string? VehicleDataCalls { get; set; }
public string? VehicleCalls { get; set; }
public string? ChargeStartCalls { get; set; }
public string? ChargeStopCalls { get; set; }
public string? SetChargingAmpsCall { get; set; }
public string? OtherCommandCalls { get; set; }
public List<DateTime> WakeUpCalls { get; set; } = new();
public List<DateTime> VehicleDataCalls { get; set; } = new();
public List<DateTime> VehicleCalls { get; set; } = new();
public List<DateTime> ChargeStartCalls { get; set; } = new();
public List<DateTime> ChargeStopCalls { get; set; } = new();
public List<DateTime> SetChargingAmpsCall { get; set; } = new();
public List<DateTime> OtherCommandCalls { get; set; } = new();

public List<ChargingProcess> ChargingProcesses { get; set; } = new List<ChargingProcess>();
public List<CarValueLog> CarValueLogs { get; set; } = new List<CarValueLog>();
Expand Down
15 changes: 0 additions & 15 deletions TeslaSolarCharger.Model/Entities/TeslaSolarCharger/TeslaToken.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TeslaSolarChargerContext : DbContext, ITeslaSolarChargerContext
public DbSet<HandledCharge> HandledCharges { get; set; } = null!;
public DbSet<PowerDistribution> PowerDistributions { get; set; } = null!;
public DbSet<SpotPrice> SpotPrices { get; set; } = null!;
public DbSet<TeslaToken> TeslaTokens { get; set; } = null!;
public DbSet<BackendToken> BackendTokens { get; set; } = null!;
public DbSet<TscConfiguration> TscConfigurations { get; set; } = null!;
public DbSet<Car> Cars { get; set; } = null!;
public DbSet<RestValueConfiguration> RestValueConfigurations { get; set; } = null!;
Expand Down Expand Up @@ -124,6 +124,41 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

modelBuilder.Entity<Car>()
.Property(e => e.WakeUpCalls)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

modelBuilder.Entity<Car>()
.Property(e => e.VehicleDataCalls)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

modelBuilder.Entity<Car>()
.Property(e => e.VehicleCalls)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

modelBuilder.Entity<Car>()
.Property(e => e.ChargeStartCalls)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

modelBuilder.Entity<Car>()
.Property(e => e.ChargeStopCalls)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

modelBuilder.Entity<Car>()
.Property(e => e.SetChargingAmpsCall)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

modelBuilder.Entity<Car>()
.Property(e => e.OtherCommandCalls)
.HasConversion(timeListToString)
.Metadata.SetValueComparer(valueComparer);

}

#pragma warning disable CS8618
Expand Down
Loading

0 comments on commit 59804b9

Please sign in to comment.