Apply code formatting cleanup across monitor projects

- Reindent appsettings.json and the MSBuild project files
- Collapse single-statement guard blocks and tidy using and member order
- Normalize XML doc indentation and file endings
- Reorder BatteryMonitor test-data helpers and move the exclusion tests into
  their own region
- Carry the same formatting through the boiler config, control, entity and
  test files
This commit is contained in:
2026-11-30 11:52:06 +02:00
parent cf8c9434c8
commit 24729ee267
165 changed files with 2513 additions and 2470 deletions
+21 -27
View File
@@ -17,19 +17,16 @@ namespace NordPoolManager;
[NetDaemonApp]
public class NordPoolInit
{
private readonly ILogger<NordPoolInit> _logger;
private readonly IHaContext _haContext;
private readonly INordPoolPriceService _priceService;
private readonly INordPoolEntityService _entityService;
private readonly ICheapestIntervalsFinder _cheapestIntervalsFinder;
private readonly INordPoolBoilerConfigProvider _boilerConfigProvider;
private readonly IScheduler _scheduler;
private readonly ICheapestIntervalsFinder _cheapestIntervalsFinder;
private readonly INordPoolEntityService _entityService;
private readonly IHaContext _haContext;
private readonly ILogger<NordPoolInit> _logger;
private readonly NordPoolOptions _options;
private readonly INordPoolPriceService _priceService;
private readonly IScheduler _scheduler;
private readonly TimeProvider _timeProvider;
private string? UnitOfMeasurement { get; }
private IReadOnlyList<CheapestIntervalResult>? CheapestIntervals { get; set; }
public NordPoolInit(
Entities entities,
IHaContext haContext,
@@ -57,22 +54,22 @@ public class NordPoolInit
_ = InitializeAndScheduleAsync();
}
private string? UnitOfMeasurement { get; }
private IReadOnlyList<CheapestIntervalResult>? CheapestIntervals { get; set; }
public async Task InitializeAsync()
{
try
{
await Task.Delay(TimeSpan.FromSeconds(3));
if (_options.CleanupEntitiesOnStartup)
{
await _entityService.CleanupEntitiesAsync();
}
if (_options.CleanupEntitiesOnStartup) await _entityService.CleanupEntitiesAsync();
await _entityService.CreateEntitiesAsync(UnitOfMeasurement);
await _entityService.ResetEntitiesAsync();
await Task.Delay(TimeSpan.FromSeconds(10));
await UpdatePricesAsync();
}
catch (Exception ex)
@@ -81,7 +78,7 @@ public class NordPoolInit
throw;
}
}
private async Task InitializeAndScheduleAsync()
{
try
@@ -118,14 +115,9 @@ public class NordPoolInit
var today = DateOnly.FromDateTime(nowCet);
if (_priceService.LastFetchedDate.HasValue && _priceService.LastFetchedDate.Value < today)
{
_priceService.RollOverPrices(today);
}
if (_priceService.ShouldFetchNewPrices(today))
{
await _priceService.FetchPricesAsync();
}
if (_priceService.ShouldFetchNewPrices(today)) await _priceService.FetchPricesAsync();
_priceService.UpdateCurrentPrice();
@@ -161,11 +153,12 @@ public class NordPoolInit
{
_logger.LogDebug("No today prices available, skipping cheapest intervals calculation");
CheapestIntervals = [];
return;
}
CheapestIntervals = _cheapestIntervalsFinder.FindCheapestIntervals(_priceService.TodayNordPoolPrice, effectiveIntervalCount, effectivePriceCap, config.Deadline);
CheapestIntervals = _cheapestIntervalsFinder.FindCheapestIntervals(_priceService.TodayNordPoolPrice,
effectiveIntervalCount, effectivePriceCap, config.Deadline);
}
catch (Exception ex)
{
@@ -183,8 +176,9 @@ public class NordPoolInit
var configuredHours = (double)boilerConfig.IntervalCount / NordPoolConsts.IntervalsPerHour;
var configuredReadyBy = boilerConfig.Deadline.TimeOfDay.ToString(@"hh\:mm", CultureInfo.InvariantCulture);
var isNowCheap = CheapestIntervals != null && _cheapestIntervalsFinder.IsCurrentIntervalCheap(CheapestIntervals, currentDateTime);
var isNowCheap = CheapestIntervals != null &&
_cheapestIntervalsFinder.IsCurrentIntervalCheap(CheapestIntervals, currentDateTime);
var nextCheapInterval = CheapestIntervals?
.Where(i => i.Start > currentDateTime)
.OrderBy(i => i.Start)
@@ -211,4 +205,4 @@ public class NordPoolInit
await _entityService.UpdateEntitiesAsync(context);
}
}
}