diff --git a/TeslaSolarCharger.Model/Entities/TeslaSolarCharger/Car.cs b/TeslaSolarCharger.Model/Entities/TeslaSolarCharger/Car.cs
index ece3589f0..bd5ec6f18 100644
--- a/TeslaSolarCharger.Model/Entities/TeslaSolarCharger/Car.cs
+++ b/TeslaSolarCharger.Model/Entities/TeslaSolarCharger/Car.cs
@@ -49,6 +49,7 @@ public class Car
public string? BleApiBaseUrl { get; set; }
public bool UseFleetTelemetry { get; set; }
public bool UseFleetTelemetryForLocationData { get; set; }
+ public bool IsAvailableInTeslaAccount { get; set; }
public string? WakeUpCalls { get; set; }
public string? VehicleDataCalls { get; set; }
diff --git a/TeslaSolarCharger.Model/Migrations/20241207134909_AddIsAvailableInTeslaAccount.Designer.cs b/TeslaSolarCharger.Model/Migrations/20241207134909_AddIsAvailableInTeslaAccount.Designer.cs
new file mode 100644
index 000000000..7f11d1ced
--- /dev/null
+++ b/TeslaSolarCharger.Model/Migrations/20241207134909_AddIsAvailableInTeslaAccount.Designer.cs
@@ -0,0 +1,926 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using TeslaSolarCharger.Model.EntityFramework;
+
+#nullable disable
+
+namespace TeslaSolarCharger.Model.Migrations
+{
+ [DbContext(typeof(TeslaSolarChargerContext))]
+ [Migration("20241207134909_AddIsAvailableInTeslaAccount")]
+ partial class AddIsAvailableInTeslaAccount
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.10");
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.BackendNotification", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BackendIssueId")
+ .HasColumnType("INTEGER");
+
+ b.Property("DetailText")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Headline")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("IsConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.Property("ValidFromDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ValidFromVersion")
+ .HasColumnType("TEXT");
+
+ b.Property("ValidToDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ValidToVersion")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("BackendNotifications");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.CachedCarState", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CarId")
+ .HasColumnType("INTEGER");
+
+ b.Property("CarStateJson")
+ .HasColumnType("TEXT");
+
+ b.Property("Key")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("LastUpdated")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("CachedCarStates");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.Car", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BleApiBaseUrl")
+ .HasColumnType("TEXT");
+
+ b.Property("ChargeMode")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargeStartCalls")
+ .HasColumnType("TEXT");
+
+ b.Property("ChargeStopCalls")
+ .HasColumnType("TEXT");
+
+ b.Property("ChargerActualCurrent")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargerPhases")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargerPilotCurrent")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargerRequestedCurrent")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargerVoltage")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargingCommandsRateLimitedUntil")
+ .HasColumnType("TEXT");
+
+ b.Property("ChargingPriority")
+ .HasColumnType("INTEGER");
+
+ b.Property("ClimateOn")
+ .HasColumnType("INTEGER");
+
+ b.Property("CommandsRateLimitedUntil")
+ .HasColumnType("TEXT");
+
+ b.Property("IgnoreLatestTimeToReachSocDate")
+ .HasColumnType("INTEGER");
+
+ b.Property("IgnoreLatestTimeToReachSocDateOnWeekend")
+ .HasColumnType("INTEGER");
+
+ b.Property("IsAvailableInTeslaAccount")
+ .HasColumnType("INTEGER");
+
+ b.Property("LatestTimeToReachSoC")
+ .HasColumnType("TEXT");
+
+ b.Property("Latitude")
+ .HasColumnType("REAL");
+
+ b.Property("Longitude")
+ .HasColumnType("REAL");
+
+ b.Property("MaximumAmpere")
+ .HasColumnType("INTEGER");
+
+ b.Property("MinimumAmpere")
+ .HasColumnType("INTEGER");
+
+ b.Property("MinimumSoc")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("OtherCommandCalls")
+ .HasColumnType("TEXT");
+
+ b.Property("PluggedIn")
+ .HasColumnType("INTEGER");
+
+ b.Property("SetChargingAmpsCall")
+ .HasColumnType("TEXT");
+
+ b.Property("ShouldBeManaged")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoC")
+ .HasColumnType("INTEGER");
+
+ b.Property("SocLimit")
+ .HasColumnType("INTEGER");
+
+ b.Property("State")
+ .HasColumnType("INTEGER");
+
+ b.Property("TeslaFleetApiState")
+ .HasColumnType("INTEGER");
+
+ b.Property("TeslaMateCarId")
+ .HasColumnType("INTEGER");
+
+ b.Property("UsableEnergy")
+ .HasColumnType("INTEGER");
+
+ b.Property("UseBle")
+ .HasColumnType("INTEGER");
+
+ b.Property("UseFleetTelemetry")
+ .HasColumnType("INTEGER");
+
+ b.Property("UseFleetTelemetryForLocationData")
+ .HasColumnType("INTEGER");
+
+ b.Property("VehicleCalls")
+ .HasColumnType("TEXT");
+
+ b.Property("VehicleCommandProtocolRequired")
+ .HasColumnType("INTEGER");
+
+ b.Property("VehicleDataCalls")
+ .HasColumnType("TEXT");
+
+ b.Property("VehicleDataRateLimitedUntil")
+ .HasColumnType("TEXT");
+
+ b.Property("VehicleRateLimitedUntil")
+ .HasColumnType("TEXT");
+
+ b.Property("Vin")
+ .HasColumnType("TEXT");
+
+ b.Property("WakeUpCalls")
+ .HasColumnType("TEXT");
+
+ b.Property("WakeUpRateLimitedUntil")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TeslaMateCarId")
+ .IsUnique();
+
+ b.HasIndex("Vin")
+ .IsUnique();
+
+ b.ToTable("Cars");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.CarValueLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BooleanValue")
+ .HasColumnType("INTEGER");
+
+ b.Property("CarId")
+ .HasColumnType("INTEGER");
+
+ b.Property("DoubleValue")
+ .HasColumnType("REAL");
+
+ b.Property("IntValue")
+ .HasColumnType("INTEGER");
+
+ b.Property("InvalidValue")
+ .HasColumnType("INTEGER");
+
+ b.Property("Source")
+ .HasColumnType("INTEGER");
+
+ b.Property("StringValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Timestamp")
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.Property("UnknownValue")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CarId");
+
+ b.ToTable("CarValueLogs");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ChargePrice", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AddSpotPriceToGridPrice")
+ .HasColumnType("INTEGER");
+
+ b.Property("EnergyProvider")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(6);
+
+ b.Property("EnergyProviderConfiguration")
+ .HasColumnType("TEXT");
+
+ b.Property("GridPrice")
+ .HasColumnType("TEXT");
+
+ b.Property("SolarPrice")
+ .HasColumnType("TEXT");
+
+ b.Property("SpotPriceCorrectionFactor")
+ .HasColumnType("TEXT");
+
+ b.Property("ValidSince")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("ChargePrices");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ChargingDetail", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargerVoltage")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargingProcessId")
+ .HasColumnType("INTEGER");
+
+ b.Property("GridPower")
+ .HasColumnType("INTEGER");
+
+ b.Property("HomeBatteryPower")
+ .HasColumnType("INTEGER");
+
+ b.Property("SolarPower")
+ .HasColumnType("INTEGER");
+
+ b.Property("TimeStamp")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChargingProcessId");
+
+ b.ToTable("ChargingDetails");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ChargingProcess", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CarId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Cost")
+ .HasColumnType("TEXT");
+
+ b.Property("EndDate")
+ .HasColumnType("TEXT");
+
+ b.Property("OldHandledChargeId")
+ .HasColumnType("INTEGER");
+
+ b.Property("StartDate")
+ .HasColumnType("TEXT");
+
+ b.Property("UsedGridEnergyKwh")
+ .HasColumnType("TEXT");
+
+ b.Property("UsedHomeBatteryEnergyKwh")
+ .HasColumnType("TEXT");
+
+ b.Property("UsedSolarEnergyKwh")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CarId");
+
+ b.ToTable("ChargingProcesses");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.HandledCharge", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AverageSpotPrice")
+ .HasColumnType("TEXT");
+
+ b.Property("CalculatedPrice")
+ .HasColumnType("TEXT");
+
+ b.Property("CarId")
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargingProcessId")
+ .HasColumnType("INTEGER");
+
+ b.Property("UsedGridEnergy")
+ .HasColumnType("TEXT");
+
+ b.Property("UsedSolarEnergy")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("HandledCharges");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.LoggedError", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("DismissedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("EndTimeStamp")
+ .HasColumnType("TEXT");
+
+ b.Property("FurtherOccurrences")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Headline")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("IssueKey")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Message")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("MethodName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Source")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("StackTrace")
+ .HasColumnType("TEXT");
+
+ b.Property("StartTimeStamp")
+ .HasColumnType("TEXT");
+
+ b.Property("TelegramNotificationSent")
+ .HasColumnType("INTEGER");
+
+ b.Property("TelegramResolvedMessageSent")
+ .HasColumnType("INTEGER");
+
+ b.Property("Vin")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("LoggedErrors");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ModbusConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ConnectDelayMilliseconds")
+ .HasColumnType("INTEGER");
+
+ b.Property("Endianess")
+ .HasColumnType("INTEGER");
+
+ b.Property("Host")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Port")
+ .HasColumnType("INTEGER");
+
+ b.Property("ReadTimeoutMilliseconds")
+ .HasColumnType("INTEGER");
+
+ b.Property("UnitIdentifier")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("ModbusConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ModbusResultConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Address")
+ .HasColumnType("INTEGER");
+
+ b.Property("BitStartIndex")
+ .HasColumnType("INTEGER");
+
+ b.Property("CorrectionFactor")
+ .HasColumnType("TEXT");
+
+ b.Property("InvertedByModbusResultConfigurationId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Length")
+ .HasColumnType("INTEGER");
+
+ b.Property("ModbusConfigurationId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Operator")
+ .HasColumnType("INTEGER");
+
+ b.Property("RegisterType")
+ .HasColumnType("INTEGER");
+
+ b.Property("UsedFor")
+ .HasColumnType("INTEGER");
+
+ b.Property("ValueType")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InvertedByModbusResultConfigurationId");
+
+ b.HasIndex("ModbusConfigurationId");
+
+ b.ToTable("ModbusResultConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.MqttConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Host")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Password")
+ .HasColumnType("TEXT");
+
+ b.Property("Port")
+ .HasColumnType("INTEGER");
+
+ b.Property("Username")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("MqttConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.MqttResultConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CorrectionFactor")
+ .HasColumnType("TEXT");
+
+ b.Property("MqttConfigurationId")
+ .HasColumnType("INTEGER");
+
+ b.Property("NodePattern")
+ .HasColumnType("TEXT");
+
+ b.Property("NodePatternType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Operator")
+ .HasColumnType("INTEGER");
+
+ b.Property("Topic")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UsedFor")
+ .HasColumnType("INTEGER");
+
+ b.Property("XmlAttributeHeaderName")
+ .HasColumnType("TEXT");
+
+ b.Property("XmlAttributeHeaderValue")
+ .HasColumnType("TEXT");
+
+ b.Property("XmlAttributeValueName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("MqttConfigurationId");
+
+ b.ToTable("MqttResultConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.PowerDistribution", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ChargingPower")
+ .HasColumnType("INTEGER");
+
+ b.Property("GridProportion")
+ .HasColumnType("REAL");
+
+ b.Property("HandledChargeId")
+ .HasColumnType("INTEGER");
+
+ b.Property("PowerFromGrid")
+ .HasColumnType("INTEGER");
+
+ b.Property("TimeStamp")
+ .HasColumnType("TEXT");
+
+ b.Property("UsedWattHours")
+ .HasColumnType("REAL");
+
+ b.HasKey("Id");
+
+ b.HasIndex("HandledChargeId");
+
+ b.ToTable("PowerDistributions");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("HttpMethod")
+ .HasColumnType("INTEGER");
+
+ b.Property("NodePatternType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Url")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("RestValueConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueConfigurationHeader", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Key")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RestValueConfigurationId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RestValueConfigurationId", "Key")
+ .IsUnique();
+
+ b.ToTable("RestValueConfigurationHeaders");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueResultConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CorrectionFactor")
+ .HasColumnType("TEXT");
+
+ b.Property("NodePattern")
+ .HasColumnType("TEXT");
+
+ b.Property("Operator")
+ .HasColumnType("INTEGER");
+
+ b.Property("RestValueConfigurationId")
+ .HasColumnType("INTEGER");
+
+ b.Property("UsedFor")
+ .HasColumnType("INTEGER");
+
+ b.Property("XmlAttributeHeaderName")
+ .HasColumnType("TEXT");
+
+ b.Property("XmlAttributeHeaderValue")
+ .HasColumnType("TEXT");
+
+ b.Property("XmlAttributeValueName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RestValueConfigurationId");
+
+ b.ToTable("RestValueResultConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.SpotPrice", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("EndDate")
+ .HasColumnType("TEXT");
+
+ b.Property("Price")
+ .HasColumnType("TEXT");
+
+ b.Property("StartDate")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("SpotPrices");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.TeslaToken", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccessToken")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ExpiresAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("IdToken")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RefreshToken")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Region")
+ .HasColumnType("INTEGER");
+
+ b.Property("UnauthorizedCounter")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("TeslaTokens");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.TscConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Key")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Key")
+ .IsUnique();
+
+ b.ToTable("TscConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.CarValueLog", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.Car", "Car")
+ .WithMany("CarValueLogs")
+ .HasForeignKey("CarId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Car");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ChargingDetail", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ChargingProcess", "ChargingProcess")
+ .WithMany("ChargingDetails")
+ .HasForeignKey("ChargingProcessId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("ChargingProcess");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ChargingProcess", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.Car", "Car")
+ .WithMany("ChargingProcesses")
+ .HasForeignKey("CarId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Car");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ModbusResultConfiguration", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ModbusResultConfiguration", "InvertedByModbusResultConfiguration")
+ .WithMany()
+ .HasForeignKey("InvertedByModbusResultConfigurationId");
+
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ModbusConfiguration", "ModbusConfiguration")
+ .WithMany("ModbusResultConfigurations")
+ .HasForeignKey("ModbusConfigurationId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("InvertedByModbusResultConfiguration");
+
+ b.Navigation("ModbusConfiguration");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.MqttResultConfiguration", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.MqttConfiguration", "MqttConfiguration")
+ .WithMany("MqttResultConfigurations")
+ .HasForeignKey("MqttConfigurationId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("MqttConfiguration");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.PowerDistribution", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.HandledCharge", "HandledCharge")
+ .WithMany("PowerDistributions")
+ .HasForeignKey("HandledChargeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("HandledCharge");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueConfigurationHeader", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueConfiguration", "RestValueConfiguration")
+ .WithMany("Headers")
+ .HasForeignKey("RestValueConfigurationId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("RestValueConfiguration");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueResultConfiguration", b =>
+ {
+ b.HasOne("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueConfiguration", "RestValueConfiguration")
+ .WithMany("RestValueResultConfigurations")
+ .HasForeignKey("RestValueConfigurationId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("RestValueConfiguration");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.Car", b =>
+ {
+ b.Navigation("CarValueLogs");
+
+ b.Navigation("ChargingProcesses");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ChargingProcess", b =>
+ {
+ b.Navigation("ChargingDetails");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.HandledCharge", b =>
+ {
+ b.Navigation("PowerDistributions");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.ModbusConfiguration", b =>
+ {
+ b.Navigation("ModbusResultConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.MqttConfiguration", b =>
+ {
+ b.Navigation("MqttResultConfigurations");
+ });
+
+ modelBuilder.Entity("TeslaSolarCharger.Model.Entities.TeslaSolarCharger.RestValueConfiguration", b =>
+ {
+ b.Navigation("Headers");
+
+ b.Navigation("RestValueResultConfigurations");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/TeslaSolarCharger.Model/Migrations/20241207134909_AddIsAvailableInTeslaAccount.cs b/TeslaSolarCharger.Model/Migrations/20241207134909_AddIsAvailableInTeslaAccount.cs
new file mode 100644
index 000000000..dee7fc494
--- /dev/null
+++ b/TeslaSolarCharger.Model/Migrations/20241207134909_AddIsAvailableInTeslaAccount.cs
@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace TeslaSolarCharger.Model.Migrations
+{
+ ///
+ public partial class AddIsAvailableInTeslaAccount : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "IsAvailableInTeslaAccount",
+ table: "Cars",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: false);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "IsAvailableInTeslaAccount",
+ table: "Cars");
+ }
+ }
+}
diff --git a/TeslaSolarCharger.Model/Migrations/TeslaSolarChargerContextModelSnapshot.cs b/TeslaSolarCharger.Model/Migrations/TeslaSolarChargerContextModelSnapshot.cs
index 906678952..e4f729503 100644
--- a/TeslaSolarCharger.Model/Migrations/TeslaSolarChargerContextModelSnapshot.cs
+++ b/TeslaSolarCharger.Model/Migrations/TeslaSolarChargerContextModelSnapshot.cs
@@ -132,6 +132,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property("IgnoreLatestTimeToReachSocDateOnWeekend")
.HasColumnType("INTEGER");
+ b.Property("IsAvailableInTeslaAccount")
+ .HasColumnType("INTEGER");
+
b.Property("LatestTimeToReachSoC")
.HasColumnType("TEXT");
diff --git a/TeslaSolarCharger/Server/Services/CarConfigurationService.cs b/TeslaSolarCharger/Server/Services/CarConfigurationService.cs
index f67557fe9..07f4a4ddb 100644
--- a/TeslaSolarCharger/Server/Services/CarConfigurationService.cs
+++ b/TeslaSolarCharger/Server/Services/CarConfigurationService.cs
@@ -56,6 +56,12 @@ public async Task AddAllMissingCarsFromTeslaAccount()
teslaSolarChargerCar.TeslaMateCarId = teslaMateCarId;
await teslaSolarChargerContext.SaveChangesAsync();
}
+
+ if (!teslaSolarChargerCar.IsAvailableInTeslaAccount)
+ {
+ teslaSolarChargerCar.IsAvailableInTeslaAccount = true;
+ await teslaSolarChargerContext.SaveChangesAsync();
+ }
continue;
}
teslaSolarChargerCar = new Car
@@ -78,5 +84,16 @@ public async Task AddAllMissingCarsFromTeslaAccount()
teslaSolarChargerContext.Cars.Add(teslaSolarChargerCar);
await teslaSolarChargerContext.SaveChangesAsync();
}
+
+ foreach (var teslaSolarChargerCar in teslaSolarChargerCars)
+ {
+ if (!teslaAccountCars.Any(c => string.Equals(c.Vin, teslaSolarChargerCar.Vin)))
+ {
+ logger.LogInformation("Car with VIN {vin} is not available in Tesla account anymore.", teslaSolarChargerCar.Vin);
+ teslaSolarChargerCar.IsAvailableInTeslaAccount = false;
+ teslaSolarChargerCar.ShouldBeManaged = false;
+ await teslaSolarChargerContext.SaveChangesAsync();
+ }
+ }
}
}
diff --git a/TeslaSolarCharger/Server/Services/ConfigJsonService.cs b/TeslaSolarCharger/Server/Services/ConfigJsonService.cs
index 1fc4264bf..e7fc1b927 100644
--- a/TeslaSolarCharger/Server/Services/ConfigJsonService.cs
+++ b/TeslaSolarCharger/Server/Services/ConfigJsonService.cs
@@ -184,6 +184,8 @@ public async Task> GetCarBasicConfigurations()
});
var cars = await teslaSolarChargerContext.Cars
+ .Where(c => c.IsAvailableInTeslaAccount)
+ .OrderBy(c => c.ChargingPriority)
.ProjectTo(mapper)
.ToListAsync().ConfigureAwait(false);
@@ -405,47 +407,25 @@ private async Task AddCachedCarStatesToCars(List cars)
public async Task UpdateAverageGridVoltage()
{
logger.LogTrace("{method}()", nameof(UpdateAverageGridVoltage));
- var homeGeofence = configurationWrapper.GeoFence();
const int lowestWorldWideGridVoltage = 100;
const int voltageBuffer = 15;
const int lowestGridVoltageToSearchFor = lowestWorldWideGridVoltage - voltageBuffer;
try
{
- var teslaMateContext = teslaMateDbContextWrapper.GetTeslaMateContextIfAvailable();
- if (teslaMateContext != default && configurationWrapper.UseTeslaMateIntegration())
+ var chargerVoltages = await teslaSolarChargerContext.ChargingDetails
+ .Where(c => (c.ChargerVoltage != null)
+ && (c.ChargerVoltage > lowestGridVoltageToSearchFor))
+ .OrderByDescending(c => c.Id)
+ .Select(c => c.ChargerVoltage)
+ .Take(1000)
+ .ToListAsync().ConfigureAwait(false);
+ if (chargerVoltages.Count > 10)
{
- var chargerVoltages = await teslaMateContext
- .Charges
- .Where(c => c.ChargingProcess.Geofence != null
- && c.ChargingProcess.Geofence.Name == homeGeofence
- && c.ChargerVoltage > lowestGridVoltageToSearchFor)
- .OrderByDescending(c => c.Id)
- .Select(c => c.ChargerVoltage)
- .Take(1000)
- .ToListAsync().ConfigureAwait(false);
- if (chargerVoltages.Count > 10)
- {
- var averageValue = Convert.ToInt32(chargerVoltages.Average(c => c!.Value));
- logger.LogDebug("Use {averageVoltage}V for charge speed calculation", averageValue);
- settings.AverageHomeGridVoltage = averageValue;
- }
+ var averageValue = Convert.ToInt32(chargerVoltages.Average(c => c!.Value));
+ logger.LogDebug("Use {averageVoltage}V for charge speed calculation", averageValue);
+ settings.AverageHomeGridVoltage = averageValue;
}
- else
- {
- var chargerVoltages = await teslaSolarChargerContext.ChargingDetails
- .Where(c => c.ChargerVoltage != null)
- .OrderByDescending(c => c.Id)
- .Select(c => c.ChargerVoltage)
- .Take(1000)
- .ToListAsync().ConfigureAwait(false);
- if (chargerVoltages.Count > 10)
- {
- var averageValue = Convert.ToInt32(chargerVoltages.Average(c => c!.Value));
- logger.LogDebug("Use {averageVoltage}V for charge speed calculation", averageValue);
- settings.AverageHomeGridVoltage = averageValue;
- }
- }
-
+
}
catch (Exception ex)
{