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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user