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
@@ -11,8 +11,8 @@ public sealed class ExhaustFanControlService(
IHaContext haContext,
IOptions<ShowerMonitorOptions> options) : IExhaustFanControlService
{
private readonly ShowerMonitorOptions _options = options.Value;
private readonly Lock _lock = new();
private readonly ShowerMonitorOptions _options = options.Value;
private bool _fanTurnedOnByUs;
private DateTimeOffset? _showerEndedAt;
@@ -53,11 +53,9 @@ public sealed class ExhaustFanControlService(
if (_fanTurnedOnByUs)
{
var fanState = haContext.GetState(_options.ExhaustFanEntityId)?.State;
if (string.Equals(fanState, "on", StringComparison.OrdinalIgnoreCase))
{
haContext.CallService("switch", "turn_off", ServiceTarget.FromEntity(_options.ExhaustFanEntityId));
}
}
_fanTurnedOnByUs = false;
@@ -67,16 +65,10 @@ public sealed class ExhaustFanControlService(
private void TurnOnFanIfNeeded()
{
if (_fanTurnedOnByUs)
{
return;
}
if (_fanTurnedOnByUs) return;
var fanState = haContext.GetState(_options.ExhaustFanEntityId)?.State;
if (string.Equals(fanState, "on", StringComparison.OrdinalIgnoreCase))
{
return;
}
if (string.Equals(fanState, "on", StringComparison.OrdinalIgnoreCase)) return;
haContext.CallService("switch", "turn_on", ServiceTarget.FromEntity(_options.ExhaustFanEntityId));
_fanTurnedOnByUs = true;
@@ -84,21 +76,15 @@ public sealed class ExhaustFanControlService(
private void EvaluatePostShowerFanOff(DateTimeOffset timestamp)
{
if (!_fanTurnedOnByUs || !_showerEndedAt.HasValue)
{
return;
}
if (!_fanTurnedOnByUs || !_showerEndedAt.HasValue) return;
var elapsed = timestamp - _showerEndedAt.Value;
var runAfterDuration = TimeSpan.FromMinutes(_options.FanRunAfterShowerMinutes);
if (elapsed < runAfterDuration)
{
return;
}
if (elapsed < runAfterDuration) return;
haContext.CallService("switch", "turn_off", ServiceTarget.FromEntity(_options.ExhaustFanEntityId));
_fanTurnedOnByUs = false;
_showerEndedAt = null;
}
}
}