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 #1102

Merged
merged 8 commits into from
Feb 12, 2024
2 changes: 1 addition & 1 deletion TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="Moq.EntityFrameworkCore" Version="7.0.0.2" />
<PackageReference Include="Moq.EntityFrameworkCore" Version="8.0.1.2" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.5" />
<PackageReference Include="xunit" Version="2.6.6" />
Expand Down
10 changes: 5 additions & 5 deletions TeslaSolarCharger/Client/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<NavLink class="nav-link px-3" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Overview
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="CarSettings">
<NavLink class="nav-link px-3" href="CarSettings">
<span class="oi oi-wrench" aria-hidden="true"></span> Car Settings
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="ChargePrices">
<NavLink class="nav-link px-3" href="ChargePrices">
<span class="material-symbols-outlined" aria-hidden="true">attach_money</span> Charge Prices
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="BaseConfiguration">
<NavLink class="nav-link px-3" href="BaseConfiguration">
<span class="oi oi-cog" aria-hidden="true"></span> Base Configuration
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="backupAndRestore">
<NavLink class="nav-link px-3" href="backupAndRestore">
<span class="oi oi-data-transfer-download" aria-hidden="true"></span> Backup and Restore
</NavLink>
</div>
Expand Down
12 changes: 5 additions & 7 deletions TeslaSolarCharger/Server/Services/TeslaFleetApiService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using System;
using System.Globalization;
using System.Net;
using System.Net.Http.Headers;
Expand All @@ -18,7 +17,6 @@
using TeslaSolarCharger.Shared.Enums;
using TeslaSolarCharger.SharedBackend.Contracts;
using TeslaSolarCharger.SharedBackend.Dtos;
using static System.Net.WebRequestMethods;
using Car = TeslaSolarCharger.Shared.Dtos.Settings.Car;

namespace TeslaSolarCharger.Server.Services;
Expand Down Expand Up @@ -762,7 +760,7 @@ private async Task HandleNonSuccessTeslaApiStatusCodes(HttpStatusCode statusCode
if (statusCode == HttpStatusCode.Unauthorized)
{
logger.LogError(
"Your token or refresh token is invalid. Very likely you have changed your Tesla password.");
"Your token or refresh token is invalid. Very likely you have changed your Tesla password. Response: {responseString}", responseString);
teslaSolarChargerContext.TeslaTokens.Remove(token);
teslaSolarChargerContext.TscConfigurations.Add(new TscConfiguration()
{
Expand All @@ -771,7 +769,7 @@ private async Task HandleNonSuccessTeslaApiStatusCodes(HttpStatusCode statusCode
}
else if (statusCode == HttpStatusCode.Forbidden)
{
logger.LogError("You did not select all scopes, so TSC can't send commands to your car.");
logger.LogError("You did not select all scopes, so TSC can't send commands to your car. Response: {responseString}", responseString);
teslaSolarChargerContext.TeslaTokens.Remove(token);
teslaSolarChargerContext.TscConfigurations.Add(new TscConfiguration()
{
Expand All @@ -781,16 +779,16 @@ private async Task HandleNonSuccessTeslaApiStatusCodes(HttpStatusCode statusCode
else if (statusCode == HttpStatusCode.InternalServerError
&& responseString.Contains("vehicle rejected request: your public key has not been paired with the vehicle"))
{
logger.LogError("Vehicle {vin} is not paired with TSC. Add The public key to the vehicle", vin);
logger.LogError("Vehicle {vin} is not paired with TSC. Add The public key to the vehicle. Response: {responseString}", vin, responseString);
var teslaMateCarId = teslamateContext.Cars.First(c => c.Vin == vin).Id;
var car = teslaSolarChargerContext.Cars.First(c => c.TeslaMateCarId == teslaMateCarId);
car.TeslaFleetApiState = TeslaCarFleetApiState.NotWorking;
}
else
{
logger.LogWarning(
"Staus Code {statusCode} is currently not handled, look into https://developer.tesla.com/docs/fleet-api#response-codes to check status code information",
statusCode);
"Staus Code {statusCode} is currently not handled, look into https://developer.tesla.com/docs/fleet-api#response-codes to check status code information. Response: {responseString}",
statusCode, responseString);
return;
}

Expand Down
Loading