From af8b38ce5d7aecca5e63f6d39246d39549240ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Thu, 8 Sep 2022 20:54:07 +0200 Subject: [PATCH 01/20] refactor(chore): rename mqttService to TeslaMateMqttService --- TeslaSolarCharger.Tests/Services/Server/MqttService.cs | 2 +- .../{IMqttService.cs => ITeslaMateMqttService.cs} | 4 ++-- TeslaSolarCharger/Server/Program.cs | 6 +++--- .../Server/Services/BaseConfigurationService.cs | 8 ++++---- TeslaSolarCharger/Server/Services/ChargingService.cs | 8 ++++---- .../Server/Services/IssueValidationService.cs | 8 ++++---- .../Services/{MqttService.cs => TeslaMateMqttService.cs} | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) rename TeslaSolarCharger/Server/Contracts/{IMqttService.cs => ITeslaMateMqttService.cs} (74%) rename TeslaSolarCharger/Server/Services/{MqttService.cs => TeslaMateMqttService.cs} (98%) diff --git a/TeslaSolarCharger.Tests/Services/Server/MqttService.cs b/TeslaSolarCharger.Tests/Services/Server/MqttService.cs index 7c8172eb2..e53b89411 100644 --- a/TeslaSolarCharger.Tests/Services/Server/MqttService.cs +++ b/TeslaSolarCharger.Tests/Services/Server/MqttService.cs @@ -38,7 +38,7 @@ public void ReducesActualCurrentToLastSetAmpIfDifferenceIsOneAndBelow5AAndEqualT }; Mock.Mock().Setup(s => s.Cars).Returns(cars); - var mqttService = Mock.Create(); + var mqttService = Mock.Create(); var teslamateValue = new TeslaMateValue() { diff --git a/TeslaSolarCharger/Server/Contracts/IMqttService.cs b/TeslaSolarCharger/Server/Contracts/ITeslaMateMqttService.cs similarity index 74% rename from TeslaSolarCharger/Server/Contracts/IMqttService.cs rename to TeslaSolarCharger/Server/Contracts/ITeslaMateMqttService.cs index 65b196bcc..4bc1ff8b7 100644 --- a/TeslaSolarCharger/Server/Contracts/IMqttService.cs +++ b/TeslaSolarCharger/Server/Contracts/ITeslaMateMqttService.cs @@ -1,7 +1,7 @@ namespace TeslaSolarCharger.Server.Contracts; -public interface IMqttService +public interface ITeslaMateMqttService { Task ConnectMqttClient(); bool IsMqttClientConnected { get; } -} \ No newline at end of file +} diff --git a/TeslaSolarCharger/Server/Program.cs b/TeslaSolarCharger/Server/Program.cs index 7a8022143..cef2f5fc4 100644 --- a/TeslaSolarCharger/Server/Program.cs +++ b/TeslaSolarCharger/Server/Program.cs @@ -60,7 +60,7 @@ .AddSingleton() .AddSingleton() .AddTransient() - .AddTransient() + .AddTransient() .AddTransient() .AddTransient() .AddTransient() @@ -120,9 +120,9 @@ var carDbUpdateService = app.Services.GetRequiredService(); await carDbUpdateService.UpdateMissingCarDataFromDatabase().ConfigureAwait(false); -var mqttHelper = app.Services.GetRequiredService(); +var teslaMateMqttService = app.Services.GetRequiredService(); -await mqttHelper.ConnectMqttClient().ConfigureAwait(false); +await teslaMateMqttService.ConnectMqttClient().ConfigureAwait(false); var jobManager = app.Services.GetRequiredService(); await jobManager.StartJobs().ConfigureAwait(false); diff --git a/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs b/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs index c5321fbf5..b62ebb587 100644 --- a/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs +++ b/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs @@ -10,15 +10,15 @@ public class BaseConfigurationService : IBaseConfigurationService private readonly ILogger _logger; private readonly IConfigurationWrapper _configurationWrapper; private readonly JobManager _jobManager; - private readonly IMqttService _mqttService; + private readonly ITeslaMateMqttService _teslaMateMqttService; public BaseConfigurationService(ILogger logger, IConfigurationWrapper configurationWrapper, - JobManager jobManager, IMqttService mqttService) + JobManager jobManager, ITeslaMateMqttService teslaMateMqttService) { _logger = logger; _configurationWrapper = configurationWrapper; _jobManager = jobManager; - _mqttService = mqttService; + _teslaMateMqttService = teslaMateMqttService; } public async Task UpdateBaseConfigurationAsync(DtoBaseConfiguration baseConfiguration) @@ -26,7 +26,7 @@ public async Task UpdateBaseConfigurationAsync(DtoBaseConfiguration baseConfigur _logger.LogTrace("{method}({@baseConfiguration})", nameof(UpdateBaseConfigurationAsync), baseConfiguration); await _jobManager.StopJobs().ConfigureAwait(false); await _configurationWrapper.UpdateBaseConfigurationAsync(baseConfiguration).ConfigureAwait(false); - await _mqttService.ConnectMqttClient().ConfigureAwait(false); + await _teslaMateMqttService.ConnectMqttClient().ConfigureAwait(false); await _jobManager.StartJobs().ConfigureAwait(false); } } diff --git a/TeslaSolarCharger/Server/Services/ChargingService.cs b/TeslaSolarCharger/Server/Services/ChargingService.cs index 8f0418f81..c185bdfa7 100644 --- a/TeslaSolarCharger/Server/Services/ChargingService.cs +++ b/TeslaSolarCharger/Server/Services/ChargingService.cs @@ -18,13 +18,13 @@ public class ChargingService : IChargingService private readonly ITeslaService _teslaService; private readonly IConfigurationWrapper _configurationWrapper; private readonly IPvValueService _pvValueService; - private readonly IMqttService _mqttService; + private readonly ITeslaMateMqttService _teslaMateMqttService; private readonly GlobalConstants _globalConstants; public ChargingService(ILogger logger, ISettings settings, IDateTimeProvider dateTimeProvider, ITelegramService telegramService, ITeslaService teslaService, IConfigurationWrapper configurationWrapper, IPvValueService pvValueService, - IMqttService mqttService, GlobalConstants globalConstants) + ITeslaMateMqttService teslaMateMqttService, GlobalConstants globalConstants) { _logger = logger; _settings = settings; @@ -33,7 +33,7 @@ public ChargingService(ILogger logger, _teslaService = teslaService; _configurationWrapper = configurationWrapper; _pvValueService = pvValueService; - _mqttService = mqttService; + _teslaMateMqttService = teslaMateMqttService; _globalConstants = globalConstants; } @@ -46,7 +46,7 @@ public async Task SetNewChargingValues() var geofence = _configurationWrapper.GeoFence(); _logger.LogDebug("Relevant Geofence: {geofence}", geofence); - if (!_mqttService.IsMqttClientConnected) + if (!_teslaMateMqttService.IsMqttClientConnected) { _logger.LogWarning("TeslaMate Mqtt Client is not connected. Charging Values won't be set."); } diff --git a/TeslaSolarCharger/Server/Services/IssueValidationService.cs b/TeslaSolarCharger/Server/Services/IssueValidationService.cs index c6b8649ae..682d566cb 100644 --- a/TeslaSolarCharger/Server/Services/IssueValidationService.cs +++ b/TeslaSolarCharger/Server/Services/IssueValidationService.cs @@ -15,7 +15,7 @@ public class IssueValidationService : IIssueValidationService private readonly ITeslaService _teslaService; private readonly IPvValueService _pvValueService; private readonly ISettings _settings; - private readonly IMqttService _mqttService; + private readonly ITeslaMateMqttService _teslaMateMqttService; private readonly IPossibleIssues _possibleIssues; private readonly IssueKeys _issueKeys; private readonly GlobalConstants _globalConstants; @@ -24,7 +24,7 @@ public class IssueValidationService : IIssueValidationService public IssueValidationService(ILogger logger, ITeslaService teslaService, IPvValueService pvValueService, ISettings settings, - IMqttService mqttService, IPossibleIssues possibleIssues, IssueKeys issueKeys, + ITeslaMateMqttService teslaMateMqttService, IPossibleIssues possibleIssues, IssueKeys issueKeys, GlobalConstants globalConstants, IConfigurationWrapper configurationWrapper, ITeslamateContext teslamateContext) { @@ -32,7 +32,7 @@ public IssueValidationService(ILogger logger, _teslaService = teslaService; _pvValueService = pvValueService; _settings = settings; - _mqttService = mqttService; + _teslaMateMqttService = teslaMateMqttService; _possibleIssues = possibleIssues; _issueKeys = issueKeys; _globalConstants = globalConstants; @@ -113,7 +113,7 @@ private List GetMqttIssues() { _logger.LogTrace("{method}()", nameof(GetMqttIssues)); var issues = new List(); - if (!_mqttService.IsMqttClientConnected) + if (!_teslaMateMqttService.IsMqttClientConnected) { issues.Add(_possibleIssues.GetIssueByKey(_issueKeys.MqttNotConnected)); } diff --git a/TeslaSolarCharger/Server/Services/MqttService.cs b/TeslaSolarCharger/Server/Services/TeslaMateMqttService.cs similarity index 98% rename from TeslaSolarCharger/Server/Services/MqttService.cs rename to TeslaSolarCharger/Server/Services/TeslaMateMqttService.cs index b2eeeeb33..6a3f14fdb 100644 --- a/TeslaSolarCharger/Server/Services/MqttService.cs +++ b/TeslaSolarCharger/Server/Services/TeslaMateMqttService.cs @@ -7,9 +7,9 @@ namespace TeslaSolarCharger.Server.Services; -public class MqttService : IMqttService +public class TeslaMateMqttService : ITeslaMateMqttService { - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly IMqttClient _mqttClient; private readonly MqttFactory _mqttFactory; private readonly ISettings _settings; @@ -46,7 +46,7 @@ public class MqttService : IMqttService public bool IsMqttClientConnected => _mqttClient.IsConnected; - public MqttService(ILogger logger, IMqttClient mqttClient, MqttFactory mqttFactory, + public TeslaMateMqttService(ILogger logger, IMqttClient mqttClient, MqttFactory mqttFactory, ISettings settings, IConfigurationWrapper configurationWrapper) { _logger = logger; From 8cd4fe7b3d139ad4b07c58f46e04c083e75bb5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Thu, 8 Sep 2022 21:07:04 +0200 Subject: [PATCH 02/20] fix(DI) allow using multiple mqttClients --- TeslaSolarCharger/Server/Program.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TeslaSolarCharger/Server/Program.cs b/TeslaSolarCharger/Server/Program.cs index cef2f5fc4..a82cb6587 100644 --- a/TeslaSolarCharger/Server/Program.cs +++ b/TeslaSolarCharger/Server/Program.cs @@ -56,11 +56,11 @@ .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() + .AddTransient() + .AddTransient() + .AddTransient() .AddTransient() - .AddTransient() + .AddSingleton() .AddTransient() .AddTransient() .AddTransient() From fb5cb71cac182577a3779a8202360d235893164e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Thu, 8 Sep 2022 21:52:00 +0200 Subject: [PATCH 03/20] feat(SolarMqttService): allow grid value to come from mqtt --- .../Client/Pages/BaseConfiguration.razor | 8 ++ .../Server/Contracts/ISolarMqttService.cs | 6 ++ TeslaSolarCharger/Server/Program.cs | 5 +- .../Server/Services/PvValueService.cs | 34 ++++++--- .../Server/Services/SolarMqttService.cs | 75 +++++++++++++++++++ .../Shared/Contracts/IConfigurationWrapper.cs | 2 + .../BaseConfigurationBase.cs | 5 +- .../Shared/Wrappers/ConfigurationWrapper.cs | 21 ++++-- 8 files changed, 136 insertions(+), 20 deletions(-) create mode 100644 TeslaSolarCharger/Server/Contracts/ISolarMqttService.cs create mode 100644 TeslaSolarCharger/Server/Services/SolarMqttService.cs diff --git a/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor b/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor index d66f60c2f..cae8cb378 100644 --- a/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor +++ b/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor @@ -35,6 +35,14 @@ else Use this if consuming 1 W from the grid is not the value 1. E.g. if sending 1500 Watt to the grid is returned as 1.5 you have to enter -1000 here +
+ + +
+
+ + +
diff --git a/TeslaSolarCharger/Server/Contracts/ISolarMqttService.cs b/TeslaSolarCharger/Server/Contracts/ISolarMqttService.cs new file mode 100644 index 000000000..4074909c2 --- /dev/null +++ b/TeslaSolarCharger/Server/Contracts/ISolarMqttService.cs @@ -0,0 +1,6 @@ +namespace TeslaSolarCharger.Server.Contracts; + +public interface ISolarMqttService +{ + Task ConnectMqttClient(); +} diff --git a/TeslaSolarCharger/Server/Program.cs b/TeslaSolarCharger/Server/Program.cs index a82cb6587..c7fcf3227 100644 --- a/TeslaSolarCharger/Server/Program.cs +++ b/TeslaSolarCharger/Server/Program.cs @@ -61,6 +61,7 @@ .AddTransient() .AddTransient() .AddSingleton() + .AddSingleton() .AddTransient() .AddTransient() .AddTransient() @@ -121,9 +122,11 @@ await carDbUpdateService.UpdateMissingCarDataFromDatabase().ConfigureAwait(false); var teslaMateMqttService = app.Services.GetRequiredService(); - await teslaMateMqttService.ConnectMqttClient().ConfigureAwait(false); +var solarMqttService = app.Services.GetRequiredService(); +await solarMqttService.ConnectMqttClient().ConfigureAwait(false); + var jobManager = app.Services.GetRequiredService(); await jobManager.StartJobs().ConfigureAwait(false); diff --git a/TeslaSolarCharger/Server/Services/PvValueService.cs b/TeslaSolarCharger/Server/Services/PvValueService.cs index 137fde2b1..51ec6ba52 100644 --- a/TeslaSolarCharger/Server/Services/PvValueService.cs +++ b/TeslaSolarCharger/Server/Services/PvValueService.cs @@ -32,20 +32,26 @@ public async Task UpdatePvValues() _logger.LogTrace("{method}()", nameof(UpdatePvValues)); var gridRequestUrl = _configurationWrapper.CurrentPowerToGridUrl(); - var gridRequestHeaders = _configurationWrapper.CurrentPowerToGridHeaders(); - var gridRequest = GenerateHttpRequestMessage(gridRequestUrl, gridRequestHeaders); - var gridHttpResponse = await GetHttpResponse(gridRequest).ConfigureAwait(false); - var gridJsonPattern = _configurationWrapper.CurrentPowerToGridJsonPattern(); - var gridXmlPattern = _configurationWrapper.CurrentPowerToGridXmlPattern(); - var gridCorrectionFactor = (double)_configurationWrapper.CurrentPowerToGridCorrectionFactor(); - var overage = await GetValueByHttpResponse(gridHttpResponse, gridJsonPattern, gridXmlPattern, gridCorrectionFactor).ConfigureAwait(false); - _logger.LogDebug("Overage is {overage}", overage); - _settings.Overage = overage; - if (overage != null) + HttpRequestMessage? gridRequest = default; + HttpResponseMessage? gridHttpResponse = default; + if (!string.IsNullOrWhiteSpace(gridRequestUrl)) { - AddOverageValueToInMemoryList((int)overage); + var gridRequestHeaders = _configurationWrapper.CurrentPowerToGridHeaders(); + gridRequest = GenerateHttpRequestMessage(gridRequestUrl, gridRequestHeaders); + gridHttpResponse = await GetHttpResponse(gridRequest).ConfigureAwait(false); + var gridJsonPattern = _configurationWrapper.CurrentPowerToGridJsonPattern(); + var gridXmlPattern = _configurationWrapper.CurrentPowerToGridXmlPattern(); + var gridCorrectionFactor = (double)_configurationWrapper.CurrentPowerToGridCorrectionFactor(); + var overage = await GetValueByHttpResponse(gridHttpResponse, gridJsonPattern, gridXmlPattern, gridCorrectionFactor).ConfigureAwait(false); + _logger.LogDebug("Overage is {overage}", overage); + _settings.Overage = overage; + if (overage != null) + { + AddOverageValueToInMemoryList((int)overage); + } } + var inverterRequestUrl = _configurationWrapper.CurrentInverterPowerUrl(); HttpRequestMessage? inverterRequest = default; HttpResponseMessage? inverterHttpResponse = default; @@ -207,8 +213,12 @@ private void AddOverageValueToInMemoryList(int overage) } } - internal bool IsSameRequest(HttpRequestMessage httpRequestMessage1, HttpRequestMessage httpRequestMessage2) + internal bool IsSameRequest(HttpRequestMessage? httpRequestMessage1, HttpRequestMessage httpRequestMessage2) { + if (httpRequestMessage1 == null) + { + return false; + } if (httpRequestMessage1.Method != httpRequestMessage2.Method) { return false; diff --git a/TeslaSolarCharger/Server/Services/SolarMqttService.cs b/TeslaSolarCharger/Server/Services/SolarMqttService.cs new file mode 100644 index 000000000..180768394 --- /dev/null +++ b/TeslaSolarCharger/Server/Services/SolarMqttService.cs @@ -0,0 +1,75 @@ +using MQTTnet.Client; +using MQTTnet; +using TeslaSolarCharger.Server.Contracts; +using TeslaSolarCharger.Shared.Contracts; +using TeslaSolarCharger.Shared.Dtos.Contracts; + +namespace TeslaSolarCharger.Server.Services; + +public class SolarMqttService : ISolarMqttService +{ + private readonly ILogger _logger; + private readonly IConfigurationWrapper _configurationWrapper; + private readonly IMqttClient _mqttClient; + private readonly MqttFactory _mqttFactory; + private readonly ISettings _setting; + + public SolarMqttService(ILogger logger, IConfigurationWrapper configurationWrapper, + IMqttClient mqttClient, MqttFactory mqttFactory, ISettings setting) + { + _logger = logger; + _configurationWrapper = configurationWrapper; + _mqttClient = mqttClient; + _mqttFactory = mqttFactory; + _setting = setting; + } + + public async Task ConnectMqttClient() + { + _logger.LogTrace("{method}()", nameof(ConnectMqttClient)); + //ToDo: Client Id dynmaisch machen + var mqqtClientId = "TeslaSolarCharger"; + var mosquitoServer = _configurationWrapper.SolarMqttServer(); + var mqttClientOptions = new MqttClientOptionsBuilder() + .WithClientId(mqqtClientId) + .WithTcpServer(mosquitoServer) + .Build(); + + if (string.IsNullOrWhiteSpace(mosquitoServer)) + { + return; + } + + _mqttClient.ApplicationMessageReceivedAsync += e => + { + var value = e.ApplicationMessage.ConvertPayloadToString(); + _logger.LogTrace("Payload for topic {topic} is {value}", e.ApplicationMessage.Topic, value); + _setting.Overage = Convert.ToInt32(value); + return Task.CompletedTask; + }; + + try + { + if (_mqttClient.IsConnected) + { + await _mqttClient.DisconnectAsync(MqttClientDisconnectReason.AdministrativeAction, + "Reconnecting with new configuration").ConfigureAwait(false); + } + await _mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.LogError(ex, "Could not connect to Solar mqtt server"); + return; + } + + var mqttSubscribeOptions = _mqttFactory.CreateSubscribeOptionsBuilder() + .WithTopicFilter(f => + { + f.WithTopic($"{_configurationWrapper.CurrentPowerToGridMqttTopic()}"); + }) + .Build(); + + await _mqttClient.SubscribeAsync(mqttSubscribeOptions, CancellationToken.None).ConfigureAwait(false); + } +} diff --git a/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs b/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs index 5bff512e8..77235a1fe 100644 --- a/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs +++ b/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs @@ -63,4 +63,6 @@ public interface IConfigurationWrapper int? HomeBatteryMinSoc(); int? HomeBatteryChargingPower(); string SqliteFileFullName(); + string? SolarMqttServer(); + string? CurrentPowerToGridMqttTopic(); } \ No newline at end of file diff --git a/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs b/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs index 63dfe8beb..84905e00a 100644 --- a/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs +++ b/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs @@ -5,7 +5,8 @@ namespace TeslaSolarCharger.Shared.Dtos.BaseConfiguration; public class BaseConfigurationBase { public Version Version { get; set; } = new(1, 0); - [Required] + public string? SolarMqttServer { get; set; } + public string? CurrentPowerToGridMqttTopic { get; set; } public string? CurrentPowerToGridUrl { get; set; } public Dictionary CurrentPowerToGridHeaders { get; set; } = new(); public string? HomeBatterySocUrl { get; set; } @@ -80,4 +81,4 @@ public class BaseConfigurationBase public int? HomeBatteryMinSoc { get; set; } public int? HomeBatteryChargingPower { get; set; } -} \ No newline at end of file +} diff --git a/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs b/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs index ed6b81eca..a04e1e5bb 100644 --- a/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs +++ b/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs @@ -124,7 +124,17 @@ public string TeslaMateDbPassword() { return GetBaseConfiguration().CurrentPowerToGridUrl; } - + + public string? SolarMqttServer() + { + return GetBaseConfiguration().SolarMqttServer; + } + + public string? CurrentPowerToGridMqttTopic() + { + return GetBaseConfiguration().CurrentPowerToGridMqttTopic; + } + public Dictionary CurrentPowerToGridHeaders() { return GetBaseConfiguration().CurrentPowerToGridHeaders; @@ -401,10 +411,11 @@ public async Task GetBaseConfigurationAsync() throw new ArgumentException($"Could not deserialize {jsonFileContent} to {nameof(DtoBaseConfiguration)}"); } - if (string.IsNullOrEmpty(dtoBaseConfiguration.CurrentPowerToGridUrl)) - { - await TryGetGridUrl(dtoBaseConfiguration).ConfigureAwait(false); - } + //ToDo: Move to a point where only called once + //if (string.IsNullOrEmpty(dtoBaseConfiguration.CurrentPowerToGridUrl)) + //{ + // await TryGetGridUrl(dtoBaseConfiguration).ConfigureAwait(false); + //} return dtoBaseConfiguration; } From 99d7b1e25734f45714fbb8e2863d03eb652b7ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Thu, 8 Sep 2022 21:53:20 +0200 Subject: [PATCH 04/20] feat(CICD): own tag --- .github/workflows/alphaRelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/alphaRelease.yml b/.github/workflows/alphaRelease.yml index 729dc8eae..13b762ac1 100644 --- a/.github/workflows/alphaRelease.yml +++ b/.github/workflows/alphaRelease.yml @@ -52,7 +52,7 @@ jobs: file: ./TeslaSolarCharger/Server/Dockerfile platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true - tags: pkuehnel/teslasolarcharger:alpha + tags: pkuehnel/teslasolarcharger:solarmqtt SmaEnergymeterPlugin: name: Building SMAPlugin Image From 3babb876d261fb4d083eb9576b21a2862303e0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Thu, 8 Sep 2022 22:03:23 +0200 Subject: [PATCH 05/20] feat(SolarMqttService): use PowerToGridCorrectionFactor --- TeslaSolarCharger/Server/Services/SolarMqttService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Server/Services/SolarMqttService.cs b/TeslaSolarCharger/Server/Services/SolarMqttService.cs index 180768394..f10d2ea03 100644 --- a/TeslaSolarCharger/Server/Services/SolarMqttService.cs +++ b/TeslaSolarCharger/Server/Services/SolarMqttService.cs @@ -44,7 +44,7 @@ public async Task ConnectMqttClient() { var value = e.ApplicationMessage.ConvertPayloadToString(); _logger.LogTrace("Payload for topic {topic} is {value}", e.ApplicationMessage.Topic, value); - _setting.Overage = Convert.ToInt32(value); + _setting.Overage = (int?)(Convert.ToInt32(value) * _configurationWrapper.CurrentPowerToGridCorrectionFactor()); return Task.CompletedTask; }; From e5156ff067a1056dc3eb3d35141ab38bbbb740a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Fri, 9 Sep 2022 10:06:35 +0200 Subject: [PATCH 06/20] feat(SolarMqttService): can use different port --- .../Services/Server/SolarMqttService.cs | 38 +++++++++++++++++++ ...MqttService.cs => TeslaMateMqttService.cs} | 6 +-- .../Server/Services/SolarMqttService.cs | 20 ++++++++-- 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 TeslaSolarCharger.Tests/Services/Server/SolarMqttService.cs rename TeslaSolarCharger.Tests/Services/Server/{MqttService.cs => TeslaMateMqttService.cs} (94%) diff --git a/TeslaSolarCharger.Tests/Services/Server/SolarMqttService.cs b/TeslaSolarCharger.Tests/Services/Server/SolarMqttService.cs new file mode 100644 index 000000000..b5246065c --- /dev/null +++ b/TeslaSolarCharger.Tests/Services/Server/SolarMqttService.cs @@ -0,0 +1,38 @@ +using TeslaSolarCharger.Shared.Contracts; +using TeslaSolarCharger.Shared.Dtos.Contracts; +using Xunit; +using Xunit.Abstractions; + +namespace TeslaSolarCharger.Tests.Services.Server; + +public class SolarMqttService : TestBase +{ + public SolarMqttService(ITestOutputHelper outputHelper) + : base(outputHelper) + { + } + + [Fact] + public void Can_Extract_MqttServer() + { + var insertedValue = "192.168.1.50"; + Mock.Mock().Setup(s => s.SolarMqttServer()).Returns(insertedValue); + + var solarMqttService = Mock.Create(); + var mqttServer = solarMqttService.GetMqttServerAndPort(out var mqttServerPort); + Assert.Equal(insertedValue, mqttServer); + Assert.Null(mqttServerPort); + } + + [Fact] + public void Can_Extract_MqttServerAndPort() + { + var insertedValue = "192.168.1.50:1883"; + Mock.Mock().Setup(s => s.SolarMqttServer()).Returns(insertedValue); + + var solarMqttService = Mock.Create(); + var mqttServer = solarMqttService.GetMqttServerAndPort(out var mqttServerPort); + Assert.Equal("192.168.1.50", mqttServer); + Assert.Equal(mqttServerPort, 1883); + } +} diff --git a/TeslaSolarCharger.Tests/Services/Server/MqttService.cs b/TeslaSolarCharger.Tests/Services/Server/TeslaMateMqttService.cs similarity index 94% rename from TeslaSolarCharger.Tests/Services/Server/MqttService.cs rename to TeslaSolarCharger.Tests/Services/Server/TeslaMateMqttService.cs index e53b89411..5c8641285 100644 --- a/TeslaSolarCharger.Tests/Services/Server/MqttService.cs +++ b/TeslaSolarCharger.Tests/Services/Server/TeslaMateMqttService.cs @@ -9,9 +9,9 @@ namespace TeslaSolarCharger.Tests.Services.Server; -public class MqttService : TestBase +public class TeslaMateMqttService : TestBase { - public MqttService(ITestOutputHelper outputHelper) + public TeslaMateMqttService(ITestOutputHelper outputHelper) : base(outputHelper) { } @@ -67,4 +67,4 @@ public void ReducesActualCurrentToLastSetAmpIfDifferenceIsOneAndBelow5AAndEqualT throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/TeslaSolarCharger/Server/Services/SolarMqttService.cs b/TeslaSolarCharger/Server/Services/SolarMqttService.cs index f10d2ea03..785c709ce 100644 --- a/TeslaSolarCharger/Server/Services/SolarMqttService.cs +++ b/TeslaSolarCharger/Server/Services/SolarMqttService.cs @@ -29,13 +29,13 @@ public async Task ConnectMqttClient() _logger.LogTrace("{method}()", nameof(ConnectMqttClient)); //ToDo: Client Id dynmaisch machen var mqqtClientId = "TeslaSolarCharger"; - var mosquitoServer = _configurationWrapper.SolarMqttServer(); + var mqttServer = GetMqttServerAndPort(out var mqttServerPort); var mqttClientOptions = new MqttClientOptionsBuilder() .WithClientId(mqqtClientId) - .WithTcpServer(mosquitoServer) + .WithTcpServer(mqttServer, mqttServerPort) .Build(); - if (string.IsNullOrWhiteSpace(mosquitoServer)) + if (string.IsNullOrWhiteSpace(mqttServer)) { return; } @@ -72,4 +72,18 @@ await _mqttClient.DisconnectAsync(MqttClientDisconnectReason.AdministrativeActio await _mqttClient.SubscribeAsync(mqttSubscribeOptions, CancellationToken.None).ConfigureAwait(false); } + + internal string? GetMqttServerAndPort(out int? mqttServerPort) + { + var mqttServerIncludingPort = _configurationWrapper.SolarMqttServer(); + var mqttServerAndPort = mqttServerIncludingPort?.Split(":"); + var mqttServer = mqttServerAndPort?.FirstOrDefault(); + mqttServerPort = null; + if (mqttServerAndPort != null && mqttServerAndPort.Length > 1) + { + mqttServerPort = Convert.ToInt32(mqttServerAndPort[1]); + } + + return mqttServer; + } } From d2d7538d7283663706c1fc493343c62557213bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Sat, 10 Sep 2022 00:11:58 +0200 Subject: [PATCH 07/20] feat(SolarMqttService): Use json and xml patterns --- .../Services/Server/PvValueService.cs | 13 +++++++++++++ .../Server/Contracts/IPvValueService.cs | 1 + .../Server/Services/PvValueService.cs | 15 +++++++++++---- .../Server/Services/SolarMqttService.cs | 9 +++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/TeslaSolarCharger.Tests/Services/Server/PvValueService.cs b/TeslaSolarCharger.Tests/Services/Server/PvValueService.cs index aa6676963..0555243ae 100644 --- a/TeslaSolarCharger.Tests/Services/Server/PvValueService.cs +++ b/TeslaSolarCharger.Tests/Services/Server/PvValueService.cs @@ -52,6 +52,19 @@ public void Can_Get_Integer_From_Json_Result(string text) Assert.Equal(384, intValue); } + [Theory] + [InlineData("384")] + [InlineData("384.0")] + [InlineData("384.00")] + public void Can_Get_Integer_From_Simple_Result(string text) + { + var json = $"{{\"value\": {text}}}"; + var pvValueService = Mock.Create(); + var intValue = pvValueService.GetValueFromResult("$.value", json, NodePatternType.Json, true); + + Assert.Equal(384, intValue); + } + [Theory] [InlineData("384")] [InlineData("384.0")] diff --git a/TeslaSolarCharger/Server/Contracts/IPvValueService.cs b/TeslaSolarCharger/Server/Contracts/IPvValueService.cs index 6e6232558..01f9b4056 100644 --- a/TeslaSolarCharger/Server/Contracts/IPvValueService.cs +++ b/TeslaSolarCharger/Server/Contracts/IPvValueService.cs @@ -4,4 +4,5 @@ public interface IPvValueService { Task UpdatePvValues(); int GetAveragedOverage(); + int? GetIntegerValueByString(string valueString, string? jsonPattern, string? xmlPattern, double correctionFactor); } \ No newline at end of file diff --git a/TeslaSolarCharger/Server/Services/PvValueService.cs b/TeslaSolarCharger/Server/Services/PvValueService.cs index 51ec6ba52..aa1b647bf 100644 --- a/TeslaSolarCharger/Server/Services/PvValueService.cs +++ b/TeslaSolarCharger/Server/Services/PvValueService.cs @@ -257,13 +257,20 @@ internal bool IsSameRequest(HttpRequestMessage? httpRequestMessage1, HttpRequest - public async Task GetIntegerValue(HttpResponseMessage response, string? jsonPattern, string? xmlPattern, double correctionFactor) + private async Task GetIntegerValue(HttpResponseMessage response, string? jsonPattern, string? xmlPattern, double correctionFactor) { - _logger.LogTrace("{method}({jsonPattern}, {xmlPattern}, {correctionFactor})", - nameof(GetIntegerValue), jsonPattern, xmlPattern, correctionFactor); + _logger.LogTrace("{method}({httpResonse}, {jsonPattern}, {xmlPattern}, {correctionFactor})", + nameof(GetIntegerValue), response, jsonPattern, xmlPattern, correctionFactor); var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + return GetIntegerValueByString(result, jsonPattern, xmlPattern, correctionFactor); + } + + public int? GetIntegerValueByString(string valueString, string? jsonPattern, string? xmlPattern, double correctionFactor) + { + _logger.LogTrace("{method}({valueString}, {jsonPattern}, {xmlPattern}, {correctionFactor})", + nameof(GetIntegerValueByString), valueString, jsonPattern, xmlPattern, correctionFactor); var pattern = ""; var nodePatternType = DecideNodePatternType(jsonPattern, xmlPattern); @@ -276,7 +283,7 @@ internal bool IsSameRequest(HttpRequestMessage? httpRequestMessage1, HttpRequest pattern = xmlPattern; } - var doubleValue = GetValueFromResult(pattern, result, nodePatternType, true); + var doubleValue = GetValueFromResult(pattern, valueString, nodePatternType, true); return (int?)(doubleValue * correctionFactor); } diff --git a/TeslaSolarCharger/Server/Services/SolarMqttService.cs b/TeslaSolarCharger/Server/Services/SolarMqttService.cs index 785c709ce..919cb3a67 100644 --- a/TeslaSolarCharger/Server/Services/SolarMqttService.cs +++ b/TeslaSolarCharger/Server/Services/SolarMqttService.cs @@ -13,15 +13,17 @@ public class SolarMqttService : ISolarMqttService private readonly IMqttClient _mqttClient; private readonly MqttFactory _mqttFactory; private readonly ISettings _setting; + private readonly IPvValueService _pvValueService; public SolarMqttService(ILogger logger, IConfigurationWrapper configurationWrapper, - IMqttClient mqttClient, MqttFactory mqttFactory, ISettings setting) + IMqttClient mqttClient, MqttFactory mqttFactory, ISettings setting, IPvValueService pvValueService) { _logger = logger; _configurationWrapper = configurationWrapper; _mqttClient = mqttClient; _mqttFactory = mqttFactory; _setting = setting; + _pvValueService = pvValueService; } public async Task ConnectMqttClient() @@ -44,7 +46,10 @@ public async Task ConnectMqttClient() { var value = e.ApplicationMessage.ConvertPayloadToString(); _logger.LogTrace("Payload for topic {topic} is {value}", e.ApplicationMessage.Topic, value); - _setting.Overage = (int?)(Convert.ToInt32(value) * _configurationWrapper.CurrentPowerToGridCorrectionFactor()); + var gridJsonPattern = _configurationWrapper.CurrentPowerToGridJsonPattern(); + var gridXmlPattern = _configurationWrapper.CurrentPowerToGridXmlPattern(); + var gridCorrectionFactor = (double)_configurationWrapper.CurrentPowerToGridCorrectionFactor(); + _setting.Overage = _pvValueService.GetIntegerValueByString(value, gridJsonPattern, gridXmlPattern, gridCorrectionFactor); return Task.CompletedTask; }; From 152ba798b77da33175f7076a075d1590bb897741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Sat, 10 Sep 2022 12:34:58 +0200 Subject: [PATCH 08/20] feat(SolarMqttService): add overage value to in memory list --- TeslaSolarCharger/Server/Contracts/IPvValueService.cs | 1 + TeslaSolarCharger/Server/Services/PvValueService.cs | 2 +- TeslaSolarCharger/Server/Services/SolarMqttService.cs | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Server/Contracts/IPvValueService.cs b/TeslaSolarCharger/Server/Contracts/IPvValueService.cs index 01f9b4056..5b741857b 100644 --- a/TeslaSolarCharger/Server/Contracts/IPvValueService.cs +++ b/TeslaSolarCharger/Server/Contracts/IPvValueService.cs @@ -5,4 +5,5 @@ public interface IPvValueService Task UpdatePvValues(); int GetAveragedOverage(); int? GetIntegerValueByString(string valueString, string? jsonPattern, string? xmlPattern, double correctionFactor); + void AddOverageValueToInMemoryList(int overage); } \ No newline at end of file diff --git a/TeslaSolarCharger/Server/Services/PvValueService.cs b/TeslaSolarCharger/Server/Services/PvValueService.cs index aa1b647bf..ad905467e 100644 --- a/TeslaSolarCharger/Server/Services/PvValueService.cs +++ b/TeslaSolarCharger/Server/Services/PvValueService.cs @@ -199,7 +199,7 @@ public int GetAveragedOverage() return (int)(weightedSum / weightedCount); } - private void AddOverageValueToInMemoryList(int overage) + public void AddOverageValueToInMemoryList(int overage) { _logger.LogTrace("{method}({overage})", nameof(AddOverageValueToInMemoryList), overage); _inMemoryValues.OverageValues.Add(overage); diff --git a/TeslaSolarCharger/Server/Services/SolarMqttService.cs b/TeslaSolarCharger/Server/Services/SolarMqttService.cs index 919cb3a67..a003010d8 100644 --- a/TeslaSolarCharger/Server/Services/SolarMqttService.cs +++ b/TeslaSolarCharger/Server/Services/SolarMqttService.cs @@ -50,6 +50,10 @@ public async Task ConnectMqttClient() var gridXmlPattern = _configurationWrapper.CurrentPowerToGridXmlPattern(); var gridCorrectionFactor = (double)_configurationWrapper.CurrentPowerToGridCorrectionFactor(); _setting.Overage = _pvValueService.GetIntegerValueByString(value, gridJsonPattern, gridXmlPattern, gridCorrectionFactor); + if (_setting.Overage != null) + { + _pvValueService.AddOverageValueToInMemoryList((int)_setting.Overage); + } return Task.CompletedTask; }; From afc9bb5c7849f2a77a68ab4ba502d4dfca71883f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Sat, 10 Sep 2022 15:05:01 +0200 Subject: [PATCH 09/20] feat(JobManager): do not use charge costs --- TeslaSolarCharger/Server/Scheduling/JobManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TeslaSolarCharger/Server/Scheduling/JobManager.cs b/TeslaSolarCharger/Server/Scheduling/JobManager.cs index fb28914e2..d12a6059d 100644 --- a/TeslaSolarCharger/Server/Scheduling/JobManager.cs +++ b/TeslaSolarCharger/Server/Scheduling/JobManager.cs @@ -66,8 +66,9 @@ public async Task StartJobs() {configJsonUpdateJob, new HashSet {updateJsonTrigger}}, {chargeTimeUpdateJob, new HashSet {chargeTimeUpdateTrigger}}, {pvValueJob, new HashSet {pvValueTrigger}}, - {powerDistributionAddJob, new HashSet {powerDistributionAddTrigger}}, - {handledChargeFinalizingJob, new HashSet {handledChargeFinalizingTrigger}}, + //ToDo: uncomment after merge + //{powerDistributionAddJob, new HashSet {powerDistributionAddTrigger}}, + //{handledChargeFinalizingJob, new HashSet {handledChargeFinalizingTrigger}}, }; await _scheduler.ScheduleJobs(triggersAndJobs, false).ConfigureAwait(false); From 94c5aacb8c512ae8639d30c67f38d25eac30bace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Sun, 11 Sep 2022 23:13:43 +0200 Subject: [PATCH 10/20] feat(ChargingCostService): delete duplicate HAndledCharges --- .../Server/Contracts/IChargingCostService.cs | 1 + TeslaSolarCharger/Server/Program.cs | 3 ++ .../Server/Services/ChargingCostService.cs | 37 ++++++++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/TeslaSolarCharger/Server/Contracts/IChargingCostService.cs b/TeslaSolarCharger/Server/Contracts/IChargingCostService.cs index 3286e927b..0a8dc60d4 100644 --- a/TeslaSolarCharger/Server/Contracts/IChargingCostService.cs +++ b/TeslaSolarCharger/Server/Contracts/IChargingCostService.cs @@ -12,4 +12,5 @@ public interface IChargingCostService Task> GetChargeSummaries(); Task GetChargePriceById(int id); Task DeleteChargePriceById(int id); + Task DeleteDuplicatedHandleCharges(); } diff --git a/TeslaSolarCharger/Server/Program.cs b/TeslaSolarCharger/Server/Program.cs index c7fcf3227..29ceb3e9b 100644 --- a/TeslaSolarCharger/Server/Program.cs +++ b/TeslaSolarCharger/Server/Program.cs @@ -107,6 +107,9 @@ var teslaSolarChargerContext = app.Services.GetRequiredService(); await teslaSolarChargerContext.Database.MigrateAsync().ConfigureAwait(false); +var chargingCostService = app.Services.GetRequiredService(); +await chargingCostService.DeleteDuplicatedHandleCharges().ConfigureAwait(false); + var baseConfigurationConverter = app.Services.GetRequiredService(); await baseConfigurationConverter.ConvertAllEnvironmentVariables().ConfigureAwait(false); await baseConfigurationConverter.ConvertBaseConfigToCurrentVersion().ConfigureAwait(false); diff --git a/TeslaSolarCharger/Server/Services/ChargingCostService.cs b/TeslaSolarCharger/Server/Services/ChargingCostService.cs index 311e7abd9..ef6f1bc5a 100644 --- a/TeslaSolarCharger/Server/Services/ChargingCostService.cs +++ b/TeslaSolarCharger/Server/Services/ChargingCostService.cs @@ -1,6 +1,7 @@ using AutoMapper.QueryableExtensions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; +using System.Collections.Generic; using TeslaSolarCharger.Model.Contracts; using TeslaSolarCharger.Model.Entities.TeslaSolarCharger; using TeslaSolarCharger.Server.Contracts; @@ -127,7 +128,7 @@ private async Task AddPowerDistribution(int carId, int? chargingPower, int? powe if (latestOpenHandledCharge == default || latestOpenHandledCharge.ChargingProcessId != latestOpenChargingProcessId) { - + if (latestOpenChargingProcessId == default) { _logger.LogWarning("Seems like car {carId} is charging but there is no open charging process found in TeslaMate", carId); @@ -153,7 +154,7 @@ private async Task AddPowerDistribution(int carId, int? chargingPower, int? powe } powerDistribution.HandledCharge = latestOpenHandledCharge; - powerDistribution.GridProportion = (float)(powerFromGrid / (float) chargingPower); + powerDistribution.GridProportion = (float)(powerFromGrid / (float)chargingPower); _logger.LogTrace("Calculated grod proportion: {proportion}", powerDistribution.GridProportion); if (powerDistribution.GridProportion < 0) { @@ -177,6 +178,38 @@ private async Task AddPowerDistribution(int carId, int? chargingPower, int? powe return currentChargePrice; } + public async Task DeleteDuplicatedHandleCharges() + { + var handledChargeChargingProcessIDs = await _teslaSolarChargerContext.HandledCharges + .Select(h => h.ChargingProcessId) + .ToListAsync().ConfigureAwait(false); + + if (handledChargeChargingProcessIDs.Count == handledChargeChargingProcessIDs.Distinct().Count()) + { + return; + } + + var handledCharges = await _teslaSolarChargerContext.HandledCharges + .ToListAsync().ConfigureAwait(false); + + var duplicates = handledCharges + .GroupBy(t => new { t.ChargingProcessId }) + .Where(t => t.Count() > 1) + .SelectMany(x => x) + .ToList(); + + foreach (var duplicate in duplicates) + { + var chargeDistributions = await _teslaSolarChargerContext.PowerDistributions + .Where(p => p.HandledChargeId == duplicate.Id) + .ToListAsync().ConfigureAwait(false); + _teslaSolarChargerContext.PowerDistributions.RemoveRange(chargeDistributions); + _teslaSolarChargerContext.HandledCharges.Remove(duplicate); + } + + await _teslaSolarChargerContext.SaveChangesAsync().ConfigureAwait(false); + } + public async Task FinalizeHandledCharges() { _logger.LogTrace("{method}()", nameof(FinalizeHandledCharges)); From 6493c660171f23d6cea13e7e180ed9c4da0626ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 19 Sep 2022 01:54:13 +0200 Subject: [PATCH 11/20] feat(SolarMqttService): allow getting inverter and home battery values over mqtt --- .../Client/Pages/BaseConfiguration.razor | 36 ++++++++- .../Server/Services/SolarMqttService.cs | 78 ++++++++++++++++--- .../Shared/Contracts/IConfigurationWrapper.cs | 3 + .../BaseConfigurationBase.cs | 3 + .../Shared/Wrappers/ConfigurationWrapper.cs | 15 ++++ 5 files changed, 120 insertions(+), 15 deletions(-) diff --git a/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor b/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor index cae8cb378..523584bd0 100644 --- a/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor +++ b/TeslaSolarCharger/Client/Pages/BaseConfiguration.razor @@ -36,12 +36,18 @@ else
- - + + +
+ This is only needed if you get solar values via MQTT +
- - + + +
+ This is only needed if you get solar values via MQTT +
@@ -141,6 +147,13 @@ else
+
+ + +
+ This is only needed if you get solar values via MQTT +
+
@@ -186,10 +199,18 @@ else
+
+
+ + +
+ This is only needed if you get solar values via MQTT +
+
@@ -240,6 +261,13 @@ else
+
+ + +
+ This is only needed if you get solar values via MQTT +
+
diff --git a/TeslaSolarCharger/Server/Services/SolarMqttService.cs b/TeslaSolarCharger/Server/Services/SolarMqttService.cs index a003010d8..4ac19db94 100644 --- a/TeslaSolarCharger/Server/Services/SolarMqttService.cs +++ b/TeslaSolarCharger/Server/Services/SolarMqttService.cs @@ -1,5 +1,6 @@ using MQTTnet.Client; using MQTTnet; +using MQTTnet.Packets; using TeslaSolarCharger.Server.Contracts; using TeslaSolarCharger.Shared.Contracts; using TeslaSolarCharger.Shared.Dtos.Contracts; @@ -45,15 +46,45 @@ public async Task ConnectMqttClient() _mqttClient.ApplicationMessageReceivedAsync += e => { var value = e.ApplicationMessage.ConvertPayloadToString(); - _logger.LogTrace("Payload for topic {topic} is {value}", e.ApplicationMessage.Topic, value); - var gridJsonPattern = _configurationWrapper.CurrentPowerToGridJsonPattern(); - var gridXmlPattern = _configurationWrapper.CurrentPowerToGridXmlPattern(); - var gridCorrectionFactor = (double)_configurationWrapper.CurrentPowerToGridCorrectionFactor(); - _setting.Overage = _pvValueService.GetIntegerValueByString(value, gridJsonPattern, gridXmlPattern, gridCorrectionFactor); - if (_setting.Overage != null) + var topic = e.ApplicationMessage.Topic; + _logger.LogTrace("Payload for topic {topic} is {value}", topic, value); + if (topic == _configurationWrapper.CurrentPowerToGridMqttTopic()) { - _pvValueService.AddOverageValueToInMemoryList((int)_setting.Overage); + var jsonPattern = _configurationWrapper.CurrentPowerToGridJsonPattern(); + var xmlPattern = _configurationWrapper.CurrentPowerToGridXmlPattern(); + var correctionFactor = (double)_configurationWrapper.CurrentPowerToGridCorrectionFactor(); + _setting.Overage = _pvValueService.GetIntegerValueByString(value, jsonPattern, xmlPattern, correctionFactor); + if (_setting.Overage != null) + { + _pvValueService.AddOverageValueToInMemoryList((int)_setting.Overage); + } } + else if (topic == _configurationWrapper.CurrentInverterPowerMqttTopic()) + { + var jsonPattern = _configurationWrapper.CurrentInverterPowerJsonPattern(); + var xmlPattern = _configurationWrapper.CurrentInverterPowerXmlPattern(); + var correctionFactor = (double)_configurationWrapper.CurrentInverterPowerCorrectionFactor(); + _setting.InverterPower = _pvValueService.GetIntegerValueByString(value, jsonPattern, xmlPattern, correctionFactor); + } + else if (topic == _configurationWrapper.HomeBatterySocMqttTopic()) + { + var jsonPattern = _configurationWrapper.HomeBatterySocJsonPattern(); + var xmlPattern = _configurationWrapper.HomeBatterySocXmlPattern(); + var correctionFactor = (double)_configurationWrapper.HomeBatterySocCorrectionFactor(); + _setting.HomeBatterySoc = _pvValueService.GetIntegerValueByString(value, jsonPattern, xmlPattern, correctionFactor); + } + else if (topic == _configurationWrapper.HomeBatteryPowerMqttTopic()) + { + var jsonPattern = _configurationWrapper.HomeBatteryPowerJsonPattern(); + var xmlPattern = _configurationWrapper.HomeBatteryPowerXmlPattern(); + var correctionFactor = (double)_configurationWrapper.HomeBatteryPowerCorrectionFactor(); + _setting.HomeBatterySoc = _pvValueService.GetIntegerValueByString(value, jsonPattern, xmlPattern, correctionFactor); + } + else + { + _logger.LogWarning("Received value does not match a topic"); + } + return Task.CompletedTask; }; @@ -73,15 +104,40 @@ await _mqttClient.DisconnectAsync(MqttClientDisconnectReason.AdministrativeActio } var mqttSubscribeOptions = _mqttFactory.CreateSubscribeOptionsBuilder() - .WithTopicFilter(f => - { - f.WithTopic($"{_configurationWrapper.CurrentPowerToGridMqttTopic()}"); - }) .Build(); + mqttSubscribeOptions.TopicFilters = GetMqttTopicFilters(); + await _mqttClient.SubscribeAsync(mqttSubscribeOptions, CancellationToken.None).ConfigureAwait(false); } + private List GetMqttTopicFilters() + { + var topicFilters = new List(); + var topics = new List() + { + _configurationWrapper.CurrentPowerToGridMqttTopic(), + _configurationWrapper.CurrentInverterPowerMqttTopic(), + _configurationWrapper.HomeBatterySocMqttTopic(), + _configurationWrapper.HomeBatteryPowerMqttTopic(), + }; + foreach (var topic in topics) + { + if (!string.IsNullOrWhiteSpace(topic)) + { + topicFilters.Add(GenerateMqttTopicFilter(topic)); + } + } + return topicFilters; + } + + private MqttTopicFilter GenerateMqttTopicFilter(string topic) + { + var mqttTopicFilterBuilder = new MqttTopicFilterBuilder(); + mqttTopicFilterBuilder.WithTopic(topic); + return mqttTopicFilterBuilder.Build(); + } + internal string? GetMqttServerAndPort(out int? mqttServerPort) { var mqttServerIncludingPort = _configurationWrapper.SolarMqttServer(); diff --git a/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs b/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs index 77235a1fe..26d4a2652 100644 --- a/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs +++ b/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs @@ -65,4 +65,7 @@ public interface IConfigurationWrapper string SqliteFileFullName(); string? SolarMqttServer(); string? CurrentPowerToGridMqttTopic(); + string? HomeBatterySocMqttTopic(); + string? CurrentInverterPowerMqttTopic(); + string? HomeBatteryPowerMqttTopic(); } \ No newline at end of file diff --git a/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs b/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs index 84905e00a..b6da04ecb 100644 --- a/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs +++ b/TeslaSolarCharger/Shared/Dtos/BaseConfiguration/BaseConfigurationBase.cs @@ -9,11 +9,14 @@ public class BaseConfigurationBase public string? CurrentPowerToGridMqttTopic { get; set; } public string? CurrentPowerToGridUrl { get; set; } public Dictionary CurrentPowerToGridHeaders { get; set; } = new(); + public string? HomeBatterySocMqttTopic { get; set; } public string? HomeBatterySocUrl { get; set; } public Dictionary HomeBatterySocHeaders { get; set; } = new(); + public string? HomeBatteryPowerMqttTopic { get; set; } public string? HomeBatteryPowerUrl { get; set; } public Dictionary HomeBatteryPowerHeaders { get; set; } = new(); public bool IsModbusGridUrl { get; set; } + public string? CurrentInverterPowerMqttTopic { get; set; } public string? CurrentInverterPowerUrl { get; set; } public Dictionary CurrentInverterPowerHeaders { get; set; } = new(); public bool IsModbusInverterUrl { get; set; } diff --git a/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs b/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs index a04e1e5bb..1d97bf7a4 100644 --- a/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs +++ b/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs @@ -140,6 +140,11 @@ public Dictionary CurrentPowerToGridHeaders() return GetBaseConfiguration().CurrentPowerToGridHeaders; } + public string? CurrentInverterPowerMqttTopic() + { + return GetBaseConfiguration().CurrentInverterPowerMqttTopic; + } + public string? CurrentInverterPowerUrl() { return GetBaseConfiguration().CurrentInverterPowerUrl; @@ -154,11 +159,21 @@ public Dictionary CurrentInverterPowerHeaders() return GetBaseConfiguration().HomeBatterySocUrl; } + public string? HomeBatterySocMqttTopic() + { + return GetBaseConfiguration().HomeBatterySocMqttTopic; + } + public Dictionary HomeBatterySocHeaders() { return GetBaseConfiguration().HomeBatterySocHeaders; } + public string? HomeBatteryPowerMqttTopic() + { + return GetBaseConfiguration().HomeBatteryPowerMqttTopic; + } + public string? HomeBatteryPowerUrl() { return GetBaseConfiguration().HomeBatteryPowerUrl; From b25f50688be9734a9de867ac5025210b943e34d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 19 Sep 2022 02:26:55 +0200 Subject: [PATCH 12/20] feat(ConfigurationWapper): try autofill urls only once --- TeslaSolarCharger/Server/Program.cs | 3 +++ .../Shared/Contracts/IConfigurationWrapper.cs | 3 ++- .../Shared/Wrappers/ConfigurationWrapper.cs | 14 ++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/TeslaSolarCharger/Server/Program.cs b/TeslaSolarCharger/Server/Program.cs index 29ceb3e9b..6669d06ee 100644 --- a/TeslaSolarCharger/Server/Program.cs +++ b/TeslaSolarCharger/Server/Program.cs @@ -114,6 +114,9 @@ await baseConfigurationConverter.ConvertAllEnvironmentVariables().ConfigureAwait(false); await baseConfigurationConverter.ConvertBaseConfigToCurrentVersion().ConfigureAwait(false); +var configurationWrapper = app.Services.GetRequiredService(); +await configurationWrapper.TryAutoFillUrls() + var telegramService = app.Services.GetRequiredService(); await telegramService.SendMessage("Application starting up").ConfigureAwait(false); diff --git a/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs b/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs index 26d4a2652..0b9637294 100644 --- a/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs +++ b/TeslaSolarCharger/Shared/Contracts/IConfigurationWrapper.cs @@ -68,4 +68,5 @@ public interface IConfigurationWrapper string? HomeBatterySocMqttTopic(); string? CurrentInverterPowerMqttTopic(); string? HomeBatteryPowerMqttTopic(); -} \ No newline at end of file + Task TryAutoFillUrls(); +} diff --git a/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs b/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs index 1d97bf7a4..b837c610e 100644 --- a/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs +++ b/TeslaSolarCharger/Shared/Wrappers/ConfigurationWrapper.cs @@ -425,18 +425,16 @@ public async Task GetBaseConfigurationAsync() { throw new ArgumentException($"Could not deserialize {jsonFileContent} to {nameof(DtoBaseConfiguration)}"); } - - //ToDo: Move to a point where only called once - //if (string.IsNullOrEmpty(dtoBaseConfiguration.CurrentPowerToGridUrl)) - //{ - // await TryGetGridUrl(dtoBaseConfiguration).ConfigureAwait(false); - //} - return dtoBaseConfiguration; } - private async Task TryGetGridUrl(DtoBaseConfiguration dtoBaseConfiguration) + public async Task TryAutoFillUrls() { + var dtoBaseConfiguration = await GetBaseConfigurationAsync().ConfigureAwait(false); + if (!string.IsNullOrEmpty(dtoBaseConfiguration.CurrentPowerToGridUrl) && !string.IsNullOrEmpty(dtoBaseConfiguration.CurrentPowerToGridMqttTopic)) + { + return; + } using var httpClient = new HttpClient(); httpClient.Timeout = TimeSpan.FromMilliseconds(500); //ToDo: as the plugin has to use the host network the pluginname is unknown From a5e767badc00fc2e65cb12de3c398fbdca540573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 19 Sep 2022 02:27:51 +0200 Subject: [PATCH 13/20] feat(BaseConfigurationService): AutoReconnect solarmqttService --- .../Server/Services/BaseConfigurationService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs b/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs index b62ebb587..a56dc744f 100644 --- a/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs +++ b/TeslaSolarCharger/Server/Services/BaseConfigurationService.cs @@ -11,14 +11,16 @@ public class BaseConfigurationService : IBaseConfigurationService private readonly IConfigurationWrapper _configurationWrapper; private readonly JobManager _jobManager; private readonly ITeslaMateMqttService _teslaMateMqttService; + private readonly ISolarMqttService _solarMqttService; public BaseConfigurationService(ILogger logger, IConfigurationWrapper configurationWrapper, - JobManager jobManager, ITeslaMateMqttService teslaMateMqttService) + JobManager jobManager, ITeslaMateMqttService teslaMateMqttService, ISolarMqttService solarMqttService) { _logger = logger; _configurationWrapper = configurationWrapper; _jobManager = jobManager; _teslaMateMqttService = teslaMateMqttService; + _solarMqttService = solarMqttService; } public async Task UpdateBaseConfigurationAsync(DtoBaseConfiguration baseConfiguration) @@ -27,6 +29,7 @@ public async Task UpdateBaseConfigurationAsync(DtoBaseConfiguration baseConfigur await _jobManager.StopJobs().ConfigureAwait(false); await _configurationWrapper.UpdateBaseConfigurationAsync(baseConfiguration).ConfigureAwait(false); await _teslaMateMqttService.ConnectMqttClient().ConfigureAwait(false); + await _solarMqttService.ConnectMqttClient().ConfigureAwait(false); await _jobManager.StartJobs().ConfigureAwait(false); } } From 398d6fbe3dc58b1bf478d9da656c2d3783602e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 19 Sep 2022 02:28:13 +0200 Subject: [PATCH 14/20] feat(JobManager): enable chargePrice jobs --- TeslaSolarCharger/Server/Scheduling/JobManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/TeslaSolarCharger/Server/Scheduling/JobManager.cs b/TeslaSolarCharger/Server/Scheduling/JobManager.cs index d12a6059d..fb28914e2 100644 --- a/TeslaSolarCharger/Server/Scheduling/JobManager.cs +++ b/TeslaSolarCharger/Server/Scheduling/JobManager.cs @@ -66,9 +66,8 @@ public async Task StartJobs() {configJsonUpdateJob, new HashSet {updateJsonTrigger}}, {chargeTimeUpdateJob, new HashSet {chargeTimeUpdateTrigger}}, {pvValueJob, new HashSet {pvValueTrigger}}, - //ToDo: uncomment after merge - //{powerDistributionAddJob, new HashSet {powerDistributionAddTrigger}}, - //{handledChargeFinalizingJob, new HashSet {handledChargeFinalizingTrigger}}, + {powerDistributionAddJob, new HashSet {powerDistributionAddTrigger}}, + {handledChargeFinalizingJob, new HashSet {handledChargeFinalizingTrigger}}, }; await _scheduler.ScheduleJobs(triggersAndJobs, false).ConfigureAwait(false); From 97a3242645e10e0195bfb4cb1dd53e8083d1c6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 19 Sep 2022 02:29:10 +0200 Subject: [PATCH 15/20] fix(program): add missing ; --- TeslaSolarCharger/Server/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Server/Program.cs b/TeslaSolarCharger/Server/Program.cs index 6669d06ee..8a00789b2 100644 --- a/TeslaSolarCharger/Server/Program.cs +++ b/TeslaSolarCharger/Server/Program.cs @@ -115,7 +115,7 @@ await baseConfigurationConverter.ConvertBaseConfigToCurrentVersion().ConfigureAwait(false); var configurationWrapper = app.Services.GetRequiredService(); -await configurationWrapper.TryAutoFillUrls() +await configurationWrapper.TryAutoFillUrls().ConfigureAwait(false); var telegramService = app.Services.GetRequiredService(); await telegramService.SendMessage("Application starting up").ConfigureAwait(false); From 397486a383e98b1a287370577fe599a8a79e76a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 19 Sep 2022 02:34:27 +0200 Subject: [PATCH 16/20] feat(ChargingCostService): remove duplicated charging costs --- TeslaSolarCharger/Server/Services/ChargingCostService.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TeslaSolarCharger/Server/Services/ChargingCostService.cs b/TeslaSolarCharger/Server/Services/ChargingCostService.cs index ef6f1bc5a..0cd8b2317 100644 --- a/TeslaSolarCharger/Server/Services/ChargingCostService.cs +++ b/TeslaSolarCharger/Server/Services/ChargingCostService.cs @@ -203,6 +203,15 @@ public async Task DeleteDuplicatedHandleCharges() var chargeDistributions = await _teslaSolarChargerContext.PowerDistributions .Where(p => p.HandledChargeId == duplicate.Id) .ToListAsync().ConfigureAwait(false); + if (duplicate.ChargePriceId > 1) + { + var chargePrice = await _teslaSolarChargerContext.ChargePrices + .FirstOrDefaultAsync(c => c.Id == duplicate.ChargePriceId).ConfigureAwait(false); + if (chargePrice != default) + { + _teslaSolarChargerContext.ChargePrices.Remove(chargePrice); + } + } _teslaSolarChargerContext.PowerDistributions.RemoveRange(chargeDistributions); _teslaSolarChargerContext.HandledCharges.Remove(duplicate); } From 59cd367d3df80942c100a0ce5c6277b1235e86f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 19 Sep 2022 02:47:13 +0200 Subject: [PATCH 17/20] feat(Index): fix version number for charge prices --- 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 ea5cd8d47..c82a73877 100644 --- a/TeslaSolarCharger/Client/Pages/Index.razor +++ b/TeslaSolarCharger/Client/Pages/Index.razor @@ -69,7 +69,7 @@ else } else { -
Chargeprices will show up nine minutes after the first charge with at least version 1.26.0
+
Chargeprices will show up nine minutes after the first charge with at least version 2.6.0
} } From 8d38f2681e233bde6b8fefb0ebc8e2757ed6f621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Tue, 20 Sep 2022 00:36:42 +0200 Subject: [PATCH 18/20] fix(SolarMqttService): Power values were added to soc --- TeslaSolarCharger/Server/Services/SolarMqttService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaSolarCharger/Server/Services/SolarMqttService.cs b/TeslaSolarCharger/Server/Services/SolarMqttService.cs index 4ac19db94..c49aee376 100644 --- a/TeslaSolarCharger/Server/Services/SolarMqttService.cs +++ b/TeslaSolarCharger/Server/Services/SolarMqttService.cs @@ -78,7 +78,7 @@ public async Task ConnectMqttClient() var jsonPattern = _configurationWrapper.HomeBatteryPowerJsonPattern(); var xmlPattern = _configurationWrapper.HomeBatteryPowerXmlPattern(); var correctionFactor = (double)_configurationWrapper.HomeBatteryPowerCorrectionFactor(); - _setting.HomeBatterySoc = _pvValueService.GetIntegerValueByString(value, jsonPattern, xmlPattern, correctionFactor); + _setting.HomeBatteryPower = _pvValueService.GetIntegerValueByString(value, jsonPattern, xmlPattern, correctionFactor); } else { From 9bfa5c5442de25ef15d531de62827143b96bf11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Tue, 20 Sep 2022 00:53:51 +0200 Subject: [PATCH 19/20] fix(issueValidationService): handle mqtt set values --- .../Server/Services/IssueValidationService.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/TeslaSolarCharger/Server/Services/IssueValidationService.cs b/TeslaSolarCharger/Server/Services/IssueValidationService.cs index 682d566cb..5d1f7d130 100644 --- a/TeslaSolarCharger/Server/Services/IssueValidationService.cs +++ b/TeslaSolarCharger/Server/Services/IssueValidationService.cs @@ -140,27 +140,30 @@ private List PvValueIssues() issues.Add(_possibleIssues.GetIssueByKey(_issueKeys.GridPowerNotAvailable)); } - if (!string.IsNullOrWhiteSpace(_configurationWrapper.CurrentInverterPowerUrl()) && _settings.InverterPower == null) + var isInverterPowerConfigured = !(string.IsNullOrWhiteSpace(_configurationWrapper.CurrentInverterPowerUrl()) && string.IsNullOrWhiteSpace(_configurationWrapper.CurrentInverterPowerMqttTopic())); + if (isInverterPowerConfigured && _settings.InverterPower == null) { issues.Add(_possibleIssues.GetIssueByKey(_issueKeys.InverterPowerNotAvailable)); } - if (!string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatterySocUrl()) && _settings.HomeBatterySoc == null) + var isHomeBatterySocConfigured = !(string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatterySocUrl()) && string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatterySocMqttTopic())); + if (isHomeBatterySocConfigured && _settings.HomeBatterySoc == null) { issues.Add(_possibleIssues.GetIssueByKey(_issueKeys.HomeBatterySocNotAvailable)); } - if (!string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatterySocUrl()) && _settings.HomeBatterySoc != null && (_settings.HomeBatterySoc > 100 || _settings.HomeBatterySoc < 0)) + if (isHomeBatterySocConfigured && _settings.HomeBatterySoc != null && (_settings.HomeBatterySoc > 100 || _settings.HomeBatterySoc < 0)) { issues.Add(_possibleIssues.GetIssueByKey(_issueKeys.HomeBatterySocNotPlausible)); } - if (!string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatteryPowerUrl()) && _settings.HomeBatteryPower == null) + var isHomeBatteryPowerConfigured = !(string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatteryPowerUrl()) && string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatteryPowerMqttTopic())); + if (isHomeBatteryPowerConfigured && _settings.HomeBatteryPower == null) { issues.Add(_possibleIssues.GetIssueByKey(_issueKeys.HomeBatteryPowerNotAvailable)); } - if (string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatteryPowerUrl()) != string.IsNullOrWhiteSpace(_configurationWrapper.HomeBatterySocUrl())) + if (isHomeBatteryPowerConfigured != isHomeBatterySocConfigured) { issues.Add(_possibleIssues.GetIssueByKey(_issueKeys.HomeBatteryHalfConfigured)); } From 85fe7c63f270f4234dc87ba443a7ce4ad50007bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Thu, 8 Sep 2022 21:53:20 +0200 Subject: [PATCH 20/20] Revert "feat(CICD): own tag" This reverts commit 99d7b1e25734f45714fbb8e2863d03eb652b7ed4. --- .github/workflows/alphaRelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/alphaRelease.yml b/.github/workflows/alphaRelease.yml index 13b762ac1..729dc8eae 100644 --- a/.github/workflows/alphaRelease.yml +++ b/.github/workflows/alphaRelease.yml @@ -52,7 +52,7 @@ jobs: file: ./TeslaSolarCharger/Server/Dockerfile platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true - tags: pkuehnel/teslasolarcharger:solarmqtt + tags: pkuehnel/teslasolarcharger:alpha SmaEnergymeterPlugin: name: Building SMAPlugin Image