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,9 +1,13 @@
|
||||
#region
|
||||
|
||||
using System.Globalization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetDaemon.HassModel;
|
||||
using PowerMonitorManager.Interface;
|
||||
using PowerMonitorManager.Models.Consts;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace PowerMonitorManager;
|
||||
|
||||
public sealed class PowerNotificationService(
|
||||
@@ -18,28 +22,28 @@ public sealed class PowerNotificationService(
|
||||
var message = BuildHighPowerMessage(currentKw, thresholdKw);
|
||||
|
||||
haContext.CallService(
|
||||
PowerMonitorConsts.PersistentNotificationDomain,
|
||||
PowerMonitorConsts.PersistentNotificationCreateService,
|
||||
data: new
|
||||
{
|
||||
title = PowerMonitorConsts.HighPowerNotificationTitle,
|
||||
message,
|
||||
notification_id = PowerMonitorConsts.HighPowerNotificationId
|
||||
});
|
||||
PowerMonitorConsts.PersistentNotificationDomain,
|
||||
PowerMonitorConsts.PersistentNotificationCreateService,
|
||||
data: new
|
||||
{
|
||||
title = PowerMonitorConsts.HighPowerNotificationTitle,
|
||||
message,
|
||||
notification_id = PowerMonitorConsts.HighPowerNotificationId
|
||||
});
|
||||
|
||||
logger.LogWarning("High power usage notification sent: {CurrentKw:F2} kW (threshold: {ThresholdKw:F1} kW)",
|
||||
currentKw, thresholdKw);
|
||||
currentKw, thresholdKw);
|
||||
}
|
||||
|
||||
public void DismissHighPowerNotification()
|
||||
{
|
||||
haContext.CallService(
|
||||
PowerMonitorConsts.PersistentNotificationDomain,
|
||||
PowerMonitorConsts.PersistentNotificationDismissService,
|
||||
data: new
|
||||
{
|
||||
notification_id = PowerMonitorConsts.HighPowerNotificationId
|
||||
});
|
||||
PowerMonitorConsts.PersistentNotificationDomain,
|
||||
PowerMonitorConsts.PersistentNotificationDismissService,
|
||||
data: new
|
||||
{
|
||||
notification_id = PowerMonitorConsts.HighPowerNotificationId
|
||||
});
|
||||
|
||||
logger.LogDebug("Dismissed high power usage notification");
|
||||
}
|
||||
@@ -47,9 +51,9 @@ public sealed class PowerNotificationService(
|
||||
private static string BuildHighPowerMessage(double currentKw, double thresholdKw)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Total home power usage is **{0:F2} kW**, which exceeds the threshold of **{1:F1} kW**.\n\nConsider turning off high-power appliances to reduce consumption.",
|
||||
currentKw,
|
||||
thresholdKw);
|
||||
CultureInfo.InvariantCulture,
|
||||
"Total home power usage is **{0:F2} kW**, which exceeds the threshold of **{1:F1} kW**.\n\nConsider turning off high-power appliances to reduce consumption.",
|
||||
currentKw,
|
||||
thresholdKw);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user