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
+10 -18
View File
@@ -1,11 +1,11 @@
using LeakMonitor.Models;
using LeakMonitorManager.Interface;
using LeakMonitorManager.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NetDaemon.AppModel;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
using LeakMonitor.Models;
using LeakMonitorManager.Interface;
using LeakMonitorManager.Models;
namespace LeakMonitorManager;
@@ -13,8 +13,8 @@ namespace LeakMonitorManager;
public sealed class LeakMonitorInit
{
private readonly IHaContext _haContext;
private readonly ILeakNotificationService _notificationService;
private readonly ILogger<LeakMonitorInit> _logger;
private readonly ILeakNotificationService _notificationService;
private readonly LeakMonitorOptions _options;
public LeakMonitorInit(
@@ -38,19 +38,15 @@ public sealed class LeakMonitorInit
if (_options.SensorEntityIds.Length == 0)
{
_logger.LogWarning("LeakMonitor enabled but no sensor entity IDs configured");
return Task.CompletedTask;
}
foreach (var sensorEntityId in _options.SensorEntityIds)
{
SubscribeToLeakSensor(sensorEntityId);
}
foreach (var sensorEntityId in _options.SensorEntityIds) SubscribeToLeakSensor(sensorEntityId);
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("LeakMonitor initialized, monitoring {Count} sensor(s)", _options.SensorEntityIds.Length);
}
_logger.LogInformation("LeakMonitor initialized, monitoring {Count} sensor(s)",
_options.SensorEntityIds.Length);
}
catch (Exception ex)
{
@@ -78,9 +74,7 @@ public sealed class LeakMonitorInit
});
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Subscribed to leak sensor {SensorId}", sensorEntityId);
}
}
internal void HandleStateChange(string sensorEntityId, StateChange change)
@@ -90,17 +84,15 @@ public sealed class LeakMonitorInit
if (string.Equals(newState, LeakMonitorConsts.WaterDetectedState, StringComparison.OrdinalIgnoreCase))
{
_logger.LogWarning("Water leak detected by {SensorId}!", sensorEntityId);
_notificationService.SendLeakAlert(sensorEntityId);
}
else if (string.Equals(newState, LeakMonitorConsts.WaterClearedState, StringComparison.OrdinalIgnoreCase))
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Water leak cleared by {SensorId}", sensorEntityId);
}
_notificationService.DismissLeakAlert(sensorEntityId);
}
}
}
}