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
+28 -38
View File
@@ -8,9 +8,9 @@ public sealed class WaterReadyService(ILogger<WaterReadyService> logger, TimePro
{
private const string SwitchOnState = "on";
private readonly Lock _lock = new();
private DateTimeOffset? _waterReadySince;
private bool _hasObservedHeating;
private int _consecutiveBelowThresholdCount;
private bool _hasObservedHeating;
private DateTimeOffset? _waterReadySince;
public bool IsInCooldown
{
@@ -41,32 +41,24 @@ public sealed class WaterReadyService(ILogger<WaterReadyService> logger, TimePro
if (IsWithinCooldownPeriod())
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.LogDebug("Water ready cooldown active (since {Since}), suppressing turn-on", _waterReadySince);
}
logger.LogDebug("Water ready cooldown active (since {Since}), suppressing turn-on",
_waterReadySince);
return true;
}
}
if (switchState is null || powerWatts is null)
{
return false;
}
if (switchState is null || powerWatts is null) return false;
if (!string.Equals(switchState, SwitchOnState, StringComparison.OrdinalIgnoreCase))
{
return false;
}
if (!string.Equals(switchState, SwitchOnState, StringComparison.OrdinalIgnoreCase)) return false;
lock (_lock)
{
if (!_hasObservedHeating)
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.LogDebug("Ignoring power reading ({PowerWatts}W) — boiler has not been observed heating yet", powerWatts.Value);
}
logger.LogDebug("Ignoring power reading ({PowerWatts}W) — boiler has not been observed heating yet",
powerWatts.Value);
return false;
}
@@ -81,20 +73,20 @@ public sealed class WaterReadyService(ILogger<WaterReadyService> logger, TimePro
if (_consecutiveBelowThresholdCount < BoilerMonitorConsts.ConsecutiveReadingsRequired)
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.LogDebug("Below-threshold reading {Count}/{Required} ({PowerWatts}W), waiting for confirmation",
_consecutiveBelowThresholdCount, BoilerMonitorConsts.ConsecutiveReadingsRequired, powerWatts.Value);
}
logger.LogDebug(
"Below-threshold reading {Count}/{Required} ({PowerWatts}W), waiting for confirmation",
_consecutiveBelowThresholdCount, BoilerMonitorConsts.ConsecutiveReadingsRequired,
powerWatts.Value);
return false;
}
_waterReadySince ??= timeProvider.GetUtcNow();
if (logger.IsEnabled(LogLevel.Information))
{
logger.LogInformation("Water detected as ready after {Count} consecutive readings, cooldown active until shower or midnight reset", _consecutiveBelowThresholdCount);
}
logger.LogInformation(
"Water detected as ready after {Count} consecutive readings, cooldown active until shower or midnight reset",
_consecutiveBelowThresholdCount);
return true;
}
@@ -108,17 +100,15 @@ public sealed class WaterReadyService(ILogger<WaterReadyService> logger, TimePro
_consecutiveBelowThresholdCount = 0;
}
logger.LogDebug("Boiler turn-on recorded, awaiting first heating observation before water ready detection is enabled");
logger.LogDebug(
"Boiler turn-on recorded, awaiting first heating observation before water ready detection is enabled");
}
public void RecordHeatingObserved()
{
lock (_lock)
{
if (_hasObservedHeating)
{
return;
}
if (_hasObservedHeating) return;
_hasObservedHeating = true;
}
@@ -145,20 +135,20 @@ public sealed class WaterReadyService(ILogger<WaterReadyService> logger, TimePro
if (waterReadySince < todayMidnightUtc)
{
if (logger.IsEnabled(LogLevel.Information))
{
logger.LogInformation("Persisted cooldown is from a previous day ({Since}), not restoring", waterReadySince);
}
logger.LogInformation("Persisted cooldown is from a previous day ({Since}), not restoring",
waterReadySince);
return;
}
_waterReadySince = waterReadySince;
if (logger.IsEnabled(LogLevel.Information))
{
logger.LogInformation("Restored water ready cooldown from {Since}", waterReadySince);
}
}
}
private bool IsWithinCooldownPeriod() => _waterReadySince is not null;
}
private bool IsWithinCooldownPeriod()
{
return _waterReadySince is not null;
}
}