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:
@@ -1,3 +1,5 @@
|
||||
#region
|
||||
|
||||
using System.Globalization;
|
||||
using BoilerMonitor.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -5,6 +7,8 @@ using NetDaemon.HassModel;
|
||||
using static BoilerMonitor.Models.BoilerMonitorConsts;
|
||||
using static NordPool.Models.NordPoolConsts;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace BoilerMonitorManager;
|
||||
|
||||
public sealed class BoilerConfigReader(IHaContext haContext, ILogger<BoilerConfigReader> logger) : IBoilerConfigReader
|
||||
@@ -14,15 +18,20 @@ public sealed class BoilerConfigReader(IHaContext haContext, ILogger<BoilerConfi
|
||||
public BoilerConfig ReadConfig()
|
||||
{
|
||||
var dailyHoursState = haContext.GetState(BoilerDailyHoursEntityId)?.State;
|
||||
|
||||
var dailyHours = double.TryParse(dailyHoursState, NumberStyles.Any, CultureInfo.InvariantCulture, out var dh)
|
||||
? dh
|
||||
: DefaultDailyHours;
|
||||
? dh
|
||||
: DefaultDailyHours;
|
||||
|
||||
var intervalCount = (int)(dailyHours * IntervalsPerHour);
|
||||
|
||||
if (intervalCount <= 0) intervalCount = IntervalsPerHour;
|
||||
if (intervalCount <= 0)
|
||||
{
|
||||
intervalCount = IntervalsPerHour;
|
||||
}
|
||||
|
||||
var priceCapState = haContext.GetState(BoilerPriceCapEntityId)?.State;
|
||||
|
||||
var priceCap =
|
||||
double.TryParse(priceCapState, NumberStyles.Any, CultureInfo.InvariantCulture, out var pc) && pc > 0
|
||||
? pc
|
||||
@@ -43,8 +52,8 @@ public sealed class BoilerConfigReader(IHaContext haContext, ILogger<BoilerConfi
|
||||
if (logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.LogDebug(
|
||||
"Boiler config: intervals={Intervals}, priceCap={Cap}, skipPriceCap={Skip}, deadline={Deadline}",
|
||||
intervalCount, priceCap, skipPriceCap, deadline);
|
||||
"Boiler config: intervals={Intervals}, priceCap={Cap}, skipPriceCap={Skip}, deadline={Deadline}",
|
||||
intervalCount, priceCap, skipPriceCap, deadline);
|
||||
}
|
||||
|
||||
var config = new BoilerConfig
|
||||
|
||||
Reference in New Issue
Block a user