Skip to content

Commit

Permalink
Merge pull request #998 from pkuehnel/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pkuehnel authored Dec 6, 2023
2 parents b41c943 + fc1fa2c commit 361c6d9
Show file tree
Hide file tree
Showing 55 changed files with 2,132 additions and 62 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TeslaSolarCharger is a service to set one or multiple Teslas' charging current u
- [How to use](#how-to-use)
- [Charge Modes](#charge-modes)
- [Generate logfiles](#generate-logfiles)
- [Privacy notes](#privacy-notes)

## How to install

Expand Down Expand Up @@ -1031,3 +1032,9 @@ If you get an error like `Error: No such container:` you can look up the contain
```bash
docker ps
```


As the new Tesla Fleet API requires a domain and external Token creation from version 2.23.0 onwards, TSC transfers some data to the owner of this repository. By using this software, you accept the transfer of this data. As this is open source, you can see which data is transferred. For now (6th December 2023), the following data is transferred:
- Your access code is used to get the access token from Tesla (Note: the token itself is only stored locally in your TSC installation. It is only transferred via my server, but the token only exists in memory on the server itself. It is not stored in a database or log file)
- Your installation ID (GUID) is at the bottom of the page. Do not post this GUID in public forums, as it is used to deliver the Tesla access token to your installation. Note: There is only a five-minute time window between requesting and providing the token using the installation ID. After these 5 minutes, all requests are blocked.)
- Your installed version.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +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<TscConfiguration> TscConfigurations { get; set; }
void RejectChanges();
}
14 changes: 14 additions & 0 deletions TeslaSolarCharger.Model/Entities/TeslaSolarCharger/TeslaToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.Extensions.Primitives;
using TeslaSolarCharger.Model.Enums;

namespace TeslaSolarCharger.Model.Entities.TeslaSolarCharger;

public class TeslaToken
{
public int Id { get; set; }
public string AccessToken { get; set; }
public string RefreshToken { get; set; }
public string IdToken { get; set; }
public DateTime ExpiresAtUtc { get; set; }
public TeslaFleetApiRegion Region { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TeslaSolarCharger.Model.Entities.TeslaSolarCharger;

public class TscConfiguration
{
public int Id { get; set; }
public string Key { get; set; }
public string? Value { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ 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<TscConfiguration> TscConfigurations { get; set; } = null!;

// ReSharper disable once UnassignedGetOnlyAutoProperty
public string DbPath { get; }
Expand Down Expand Up @@ -41,6 +43,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<ChargePrice>()
.Property(c => c.EnergyProvider)
.HasDefaultValue(EnergyProvider.OldTeslaSolarChargerConfig);

modelBuilder.Entity<TscConfiguration>()
.HasIndex(c => c.Key)
.IsUnique();
}

#pragma warning disable CS8618
Expand Down
7 changes: 7 additions & 0 deletions TeslaSolarCharger.Model/Enums/TeslaFleetApiRegion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace TeslaSolarCharger.Model.Enums;

public enum TeslaFleetApiRegion
{
Emea,
NorthAmerica,
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions TeslaSolarCharger.Model/Migrations/20231127233402_AddTeslaToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TeslaSolarCharger.Model.Migrations
{
/// <inheritdoc />
public partial class AddTeslaToken : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TeslaTokens",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccessToken = table.Column<string>(type: "TEXT", nullable: false),
RefreshToken = table.Column<string>(type: "TEXT", nullable: false),
IdToken = table.Column<string>(type: "TEXT", nullable: false),
ExpiresAtUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
Region = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TeslaTokens", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TeslaTokens");
}
}
}
Loading

0 comments on commit 361c6d9

Please sign in to comment.