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
+20 -29
View File
@@ -1,10 +1,10 @@
using LightMonitor.Models;
using LightMonitorManager.Interface;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NetDaemon.AppModel;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;
using LightMonitor.Models;
using LightMonitorManager.Interface;
namespace LightMonitorManager;
@@ -12,10 +12,10 @@ namespace LightMonitorManager;
public sealed class LightMonitorInit
{
private readonly IHaContext _haContext;
private readonly ILogger<LightMonitorInit> _logger;
private readonly IPresenceService _presenceService;
private readonly ILightControlService _lightControlService;
private readonly ILogger<LightMonitorInit> _logger;
private readonly LightMonitorOptions _options;
private readonly IPresenceService _presenceService;
public LightMonitorInit(
IHaContext haContext,
@@ -41,9 +41,8 @@ public sealed class LightMonitorInit
SubscribeToPersonStateChanges();
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("LightMonitor initialized with {PersonCount} tracked persons", _options.PersonEntityIds.Length);
}
_logger.LogInformation("LightMonitor initialized with {PersonCount} tracked persons",
_options.PersonEntityIds.Length);
}
catch (Exception ex)
{
@@ -61,27 +60,20 @@ public sealed class LightMonitorInit
{
try
{
if (!string.Equals(e.New?.State, LightMonitorConsts.SunBelowHorizon, StringComparison.OrdinalIgnoreCase))
{
return;
}
if (!string.Equals(e.New?.State, LightMonitorConsts.SunBelowHorizon,
StringComparison.OrdinalIgnoreCase)) return;
if (IsRecoveryTransition(e.Old?.State))
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Sun state recovered from {OldState}, ignoring", e.Old?.State);
}
return;
}
_logger.LogInformation("Sun went below horizon, checking if anyone is home");
if (_presenceService.IsAnyoneHome())
{
_lightControlService.TurnOnLight();
}
if (_presenceService.IsAnyoneHome()) _lightControlService.TurnOnLight();
}
catch (Exception ex)
{
@@ -100,25 +92,21 @@ public sealed class LightMonitorInit
{
try
{
if (!string.Equals(e.New?.State, LightMonitorConsts.PersonHomeState, StringComparison.OrdinalIgnoreCase))
{
return;
}
if (!string.Equals(e.New?.State, LightMonitorConsts.PersonHomeState,
StringComparison.OrdinalIgnoreCase)) return;
if (IsRecoveryTransition(e.Old?.State))
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Person {EntityId} state recovered from {OldState}, ignoring", personEntityId, e.Old?.State);
}
_logger.LogInformation("Person {EntityId} state recovered from {OldState}, ignoring",
personEntityId, e.Old?.State);
return;
}
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Person {EntityId} arrived home, checking if it is dark", personEntityId);
}
_logger.LogInformation("Person {EntityId} arrived home, checking if it is dark",
personEntityId);
_lightControlService.TurnOnLight();
}
@@ -130,5 +118,8 @@ public sealed class LightMonitorInit
}
}
private static bool IsRecoveryTransition(string? oldState) => oldState is null or LightMonitorConsts.UnavailableState or LightMonitorConsts.UnknownState;
}
private static bool IsRecoveryTransition(string? oldState)
{
return oldState is null or LightMonitorConsts.UnavailableState or LightMonitorConsts.UnknownState;
}
}