Apply code formatting cleanup across the monitor projects

- Wrap using directives in `#region` blocks across the Battery, Boiler and NordPool sources and tests
- Expand single-statement guards and loops into braced blocks
- Realign wrapped method arguments, chained calls and continuations
- Replace target-typed `new()` with explicit generic construction and empty string literals with `string.Empty`
- Flatten the boiler config expression and reindent the remaining touched files
This commit is contained in:
2026-12-01 12:33:31 +02:00
parent 77458383d1
commit f919d6b25b
115 changed files with 3115 additions and 1959 deletions
@@ -1,9 +1,13 @@
#region
using System.Text;
using BatteryMonitor.Models;
using BatteryMonitorManager.Interface;
using Microsoft.Extensions.Logging;
using NetDaemon.HassModel;
#endregion
namespace BatteryMonitorManager;
public sealed class BatteryNotificationService(
@@ -12,37 +16,40 @@ public sealed class BatteryNotificationService(
{
public void NotifyLowBattery(IReadOnlyList<BatterySensorInfo> lowBatteryDevices)
{
if (lowBatteryDevices.Count == 0) return;
if (lowBatteryDevices.Count == 0)
{
return;
}
var message = BuildNotificationMessage(lowBatteryDevices);
haContext.CallService(
BatteryMonitorConsts.PersistentNotificationDomain,
BatteryMonitorConsts.PersistentNotificationCreateService,
data: new
{
title = BatteryMonitorConsts.NotificationTitle,
message,
notification_id = BatteryMonitorConsts.NotificationId
});
BatteryMonitorConsts.PersistentNotificationDomain,
BatteryMonitorConsts.PersistentNotificationCreateService,
data: new
{
title = BatteryMonitorConsts.NotificationTitle,
message,
notification_id = BatteryMonitorConsts.NotificationId
});
if (logger.IsEnabled(LogLevel.Information))
{
logger.LogInformation(
"Sent low battery notification for {Count} device(s)",
lowBatteryDevices.Count);
"Sent low battery notification for {Count} device(s)",
lowBatteryDevices.Count);
}
}
public void DismissNotification()
{
haContext.CallService(
BatteryMonitorConsts.PersistentNotificationDomain,
BatteryMonitorConsts.PersistentNotificationDismissService,
data: new
{
notification_id = BatteryMonitorConsts.NotificationId
});
BatteryMonitorConsts.PersistentNotificationDomain,
BatteryMonitorConsts.PersistentNotificationDismissService,
data: new
{
notification_id = BatteryMonitorConsts.NotificationId
});
logger.LogDebug("Dismissed low battery notification");
}
@@ -54,7 +61,9 @@ public sealed class BatteryNotificationService(
sb.AppendLine();
foreach (var device in devices.OrderBy(d => d.BatteryLevel))
{
sb.AppendLine($"- **{device.FriendlyName}**: {device.BatteryLevel:F0}%");
}
return sb.ToString().TrimEnd();
}