From 21b676286a133ac9f00a8a509a752991cfe40515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Wed, 9 Aug 2023 21:05:00 +0200 Subject: [PATCH 1/9] fix(CarState): set parentheses for charging power calculation --- TeslaSolarCharger/Shared/Dtos/Settings/CarState.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/TeslaSolarCharger/Shared/Dtos/Settings/CarState.cs b/TeslaSolarCharger/Shared/Dtos/Settings/CarState.cs index e278fff31..eb874e8bf 100644 --- a/TeslaSolarCharger/Shared/Dtos/Settings/CarState.cs +++ b/TeslaSolarCharger/Shared/Dtos/Settings/CarState.cs @@ -50,7 +50,7 @@ private int? ChargingPower { float? currentToUse; //Next lines because of wrong actual current on currents below 5A - if (ChargerRequestedCurrent < 5 && ChargerActualCurrent == ChargerRequestedCurrent + 1) + if ((ChargerRequestedCurrent < 5) && (ChargerActualCurrent == (ChargerRequestedCurrent + 1))) { currentToUse = (float?)(ChargerActualCurrent + ChargerRequestedCurrent) / 2; } @@ -63,15 +63,6 @@ private int? ChargingPower } } - public int? SetChargingPower - { - get - { - var power = ChargerRequestedCurrent * ChargerVoltage * ActualPhases; - return power; - } - } - public string? StateString { get; set; } public CarStateEnum? State { get; set; } public bool? Healthy { get; set; } From acae32cf1058a8766cd85cf6094bc75738b24208 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 03:26:13 +0000 Subject: [PATCH 2/9] build(deps): Bump Moq from 4.20.2 to 4.20.69 Bumps [Moq](https://github.com/moq/moq) from 4.20.2 to 4.20.69. - [Release notes](https://github.com/moq/moq/releases) - [Changelog](https://github.com/moq/moq/blob/main/CHANGELOG.md) - [Commits](https://github.com/moq/moq/compare/v4.20.2...v4.20.69) --- updated-dependencies: - dependency-name: Moq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj b/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj index ef63e5853..30535579b 100644 --- a/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj +++ b/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj @@ -12,7 +12,7 @@ - + From 4c307f3233576d40302372020dd43670530fe4ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 07:54:00 +0000 Subject: [PATCH 3/9] build(deps): Bump Microsoft.NET.Test.Sdk from 17.7.0 to 17.7.1 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.7.0 to 17.7.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.7.0...v17.7.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj b/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj index 30535579b..24510bda8 100644 --- a/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj +++ b/TeslaSolarCharger.Tests/TeslaSolarCharger.Tests.csproj @@ -11,7 +11,7 @@ - + From d7f248018c760a61514856af1c31a17f06f1effa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Fri, 18 Aug 2023 09:56:55 +0200 Subject: [PATCH 4/9] feat(ConfigJsonService): use last 1000 entries instead of random entries to calculate charger voltage --- TeslaSolarCharger/Server/Services/ConfigJsonService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/TeslaSolarCharger/Server/Services/ConfigJsonService.cs b/TeslaSolarCharger/Server/Services/ConfigJsonService.cs index 01154894f..9e3cd7922 100644 --- a/TeslaSolarCharger/Server/Services/ConfigJsonService.cs +++ b/TeslaSolarCharger/Server/Services/ConfigJsonService.cs @@ -276,6 +276,7 @@ public async Task UpdateAverageGridVoltage() .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); From f56b5ddf385173a73ebc776cc0c3050796bd0cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Wed, 23 Aug 2023 01:51:10 +0200 Subject: [PATCH 5/9] workaround(TeslaMateMqttService): set scheduled charge time to null if in past --- .../Server/Services/TeslaMateMqttService.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/TeslaSolarCharger/Server/Services/TeslaMateMqttService.cs b/TeslaSolarCharger/Server/Services/TeslaMateMqttService.cs index db9b2e8a3..0bf7a25c5 100644 --- a/TeslaSolarCharger/Server/Services/TeslaMateMqttService.cs +++ b/TeslaSolarCharger/Server/Services/TeslaMateMqttService.cs @@ -16,6 +16,7 @@ public class TeslaMateMqttService : ITeslaMateMqttService private readonly ISettings _settings; private readonly IConfigurationWrapper _configurationWrapper; private readonly IConfigJsonService _configJsonService; + private readonly IDateTimeProvider _dateTimeProvider; // ReSharper disable once InconsistentNaming private const string TopicDisplayName = "display_name"; @@ -56,7 +57,7 @@ public class TeslaMateMqttService : ITeslaMateMqttService public TeslaMateMqttService(ILogger logger, IMqttClient mqttClient, MqttFactory mqttFactory, ISettings settings, IConfigurationWrapper configurationWrapper, - IConfigJsonService configJsonService) + IConfigJsonService configJsonService, IDateTimeProvider dateTimeProvider) { _logger = logger; _mqttClient = mqttClient; @@ -64,6 +65,7 @@ public TeslaMateMqttService(ILogger logger, IMqttClient mq _settings = settings; _configurationWrapper = configurationWrapper; _configJsonService = configJsonService; + _dateTimeProvider = dateTimeProvider; } public async Task ConnectMqttClient() @@ -351,7 +353,16 @@ internal void UpdateCar(TeslaMateValue value) _logger.LogTrace("{topicName} changed to {value}", nameof(TopicScheduledChargingStartTime), value.Value); if (!string.IsNullOrWhiteSpace(value.Value)) { - car.CarState.ScheduledChargingStartTime = DateTimeOffset.Parse(value.Value); + var parsedScheduledChargingStartTime = DateTimeOffset.Parse(value.Value); + if (parsedScheduledChargingStartTime < _dateTimeProvider.DateTimeOffSetNow().AddDays(-14)) + { + _logger.LogWarning("TeslaMate set scheduled charging start time to {teslaMateValue}. As this is in the past, it will be ignored.", parsedScheduledChargingStartTime); + car.CarState.ScheduledChargingStartTime = null; + } + else + { + car.CarState.ScheduledChargingStartTime = parsedScheduledChargingStartTime; + } } else { From 8514ea1ec6509944ad8b6a05528f9334a578ab78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Wed, 23 Aug 2023 01:55:16 +0200 Subject: [PATCH 6/9] fix(IndexRazor): use homeChargePower to determin if display start or stop --- TeslaSolarCharger/Client/Pages/Index.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Client/Pages/Index.razor b/TeslaSolarCharger/Client/Pages/Index.razor index 51d5ef634..ec3093cc2 100644 --- a/TeslaSolarCharger/Client/Pages/Index.razor +++ b/TeslaSolarCharger/Client/Pages/Index.razor @@ -238,7 +238,7 @@ else @if (car.ChargeInformation.Count > 0) {

- Car will @(car.State == CarStateEnum.Charging ? "stop" : "start") charging when following conditions are met:
+ Car will @((car.HomeChargePower > 0) ? "stop" : "start") charging when following conditions are met:

    @foreach (var chargeInfo in car.ChargeInformation) { From 051efd119fa411324270e8212e97274fb5d99949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Wed, 23 Aug 2023 02:02:11 +0200 Subject: [PATCH 7/9] refactor(IndexRazor): remove redundent paranthes --- TeslaSolarCharger/Client/Pages/Index.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Client/Pages/Index.razor b/TeslaSolarCharger/Client/Pages/Index.razor index ec3093cc2..68a6ddaa9 100644 --- a/TeslaSolarCharger/Client/Pages/Index.razor +++ b/TeslaSolarCharger/Client/Pages/Index.razor @@ -238,7 +238,7 @@ else @if (car.ChargeInformation.Count > 0) {

    - Car will @((car.HomeChargePower > 0) ? "stop" : "start") charging when following conditions are met:
    + Car will @(car.HomeChargePower > 0 ? "stop" : "start") charging when following conditions are met:

      @foreach (var chargeInfo in car.ChargeInformation) { From 413ef12917bd21b068af697030cb3b1fd76eee3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 03:42:44 +0000 Subject: [PATCH 8/9] build(deps): Bump Serilog.Settings.Configuration from 7.0.0 to 7.0.1 Bumps [Serilog.Settings.Configuration](https://github.com/serilog/serilog-settings-configuration) from 7.0.0 to 7.0.1. - [Release notes](https://github.com/serilog/serilog-settings-configuration/releases) - [Changelog](https://github.com/serilog/serilog-settings-configuration/blob/dev/CHANGES.md) - [Commits](https://github.com/serilog/serilog-settings-configuration/commits) --- updated-dependencies: - dependency-name: Serilog.Settings.Configuration dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Plugins.Modbus/Plugins.Modbus.csproj | 2 +- Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj | 2 +- Plugins.SolarEdge/Plugins.SolarEdge.csproj | 2 +- Plugins.Solax/Plugins.Solax.csproj | 2 +- TeslaSolarCharger/Server/TeslaSolarCharger.Server.csproj | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins.Modbus/Plugins.Modbus.csproj b/Plugins.Modbus/Plugins.Modbus.csproj index 42c818ad1..eb727105b 100644 --- a/Plugins.Modbus/Plugins.Modbus.csproj +++ b/Plugins.Modbus/Plugins.Modbus.csproj @@ -12,7 +12,7 @@ - + diff --git a/Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj b/Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj index ba1fe234a..10052f6fe 100644 --- a/Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj +++ b/Plugins.SmaEnergymeter/Plugins.SmaEnergymeter.csproj @@ -13,7 +13,7 @@ - + diff --git a/Plugins.SolarEdge/Plugins.SolarEdge.csproj b/Plugins.SolarEdge/Plugins.SolarEdge.csproj index f6d53e8c1..c72e1350e 100644 --- a/Plugins.SolarEdge/Plugins.SolarEdge.csproj +++ b/Plugins.SolarEdge/Plugins.SolarEdge.csproj @@ -12,7 +12,7 @@ - + diff --git a/Plugins.Solax/Plugins.Solax.csproj b/Plugins.Solax/Plugins.Solax.csproj index 2390a1b34..a85d443ce 100644 --- a/Plugins.Solax/Plugins.Solax.csproj +++ b/Plugins.Solax/Plugins.Solax.csproj @@ -11,7 +11,7 @@ - + diff --git a/TeslaSolarCharger/Server/TeslaSolarCharger.Server.csproj b/TeslaSolarCharger/Server/TeslaSolarCharger.Server.csproj index e613c532d..6106e6b48 100644 --- a/TeslaSolarCharger/Server/TeslaSolarCharger.Server.csproj +++ b/TeslaSolarCharger/Server/TeslaSolarCharger.Server.csproj @@ -51,7 +51,7 @@ - + From bb13085a241cbc7de46129f13780031ed3e901eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Wed, 23 Aug 2023 11:26:17 +0200 Subject: [PATCH 9/9] fix(ChargeTimeCalculationService): Use + 1 day for max power charging slot --- .../Server/Services/ChargeTimeCalculationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Server/Services/ChargeTimeCalculationService.cs b/TeslaSolarCharger/Server/Services/ChargeTimeCalculationService.cs index adfd146ca..38faf9761 100644 --- a/TeslaSolarCharger/Server/Services/ChargeTimeCalculationService.cs +++ b/TeslaSolarCharger/Server/Services/ChargeTimeCalculationService.cs @@ -183,7 +183,7 @@ internal async Task> PlanChargingSlots(Car car, DateTimeOf plannedChargingSlots.Add(new DtoChargingSlot() { ChargeStart = dateTimeOffSetNow, - ChargeEnd = DateTimeOffset.MaxValue, + ChargeEnd = dateTimeOffSetNow.AddDays(1), }); break;