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
+6 -13
View File
@@ -1,10 +1,10 @@
using System.Collections.Concurrent;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NetDaemon.HassModel;
using LeakMonitor.Models;
using LeakMonitorManager.Interface;
using LeakMonitorManager.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NetDaemon.HassModel;
namespace LeakMonitorManager;
@@ -14,19 +14,17 @@ public sealed class LeakNotificationService(
IOptions<LeakMonitorOptions> options,
TimeProvider timeProvider) : ILeakNotificationService
{
private readonly LeakMonitorOptions _options = options.Value;
private readonly ConcurrentDictionary<string, DateTimeOffset> _lastNotificationTimes = new();
private readonly LeakMonitorOptions _options = options.Value;
public void SendLeakAlert(string sensorEntityId)
{
if (IsWithinCooldown(sensorEntityId))
{
if (logger.IsEnabled(LogLevel.Debug))
{
logger.LogDebug(
"Skipping leak notification for {SensorId} -- within cooldown period",
sensorEntityId);
}
return;
}
@@ -52,9 +50,7 @@ public sealed class LeakNotificationService(
data: new { notification_id = notificationId });
if (logger.IsEnabled(LogLevel.Information))
{
logger.LogInformation("Leak alert dismissed for sensor {SensorId}", sensorEntityId);
}
}
private void SendMobilePushNotification(string message)
@@ -95,10 +91,7 @@ public sealed class LeakNotificationService(
private bool IsWithinCooldown(string sensorEntityId)
{
if (!_lastNotificationTimes.TryGetValue(sensorEntityId, out var lastTime))
{
return false;
}
if (!_lastNotificationTimes.TryGetValue(sensorEntityId, out var lastTime)) return false;
var cooldown = TimeSpan.FromMinutes(_options.NotificationCooldownMinutes);
return timeProvider.GetUtcNow() - lastTime < cooldown;
@@ -109,4 +102,4 @@ public sealed class LeakNotificationService(
var sanitized = sensorEntityId.Replace('.', '_');
return $"{LeakMonitorConsts.NotificationIdPrefix}{sanitized}";
}
}
}