Enable PowerMonitor limit enforcement and prune unused boiler/replay code
PowerMonitor now ships enabled with power-limit enforcement settings: watt limit, recovery and cooldown windows, and switch-off plus pause/restore entity lists. Remove the unused BoilerRunTimeTracker, its DI registration and tests, the StatusCleanedUp constant, and the boiler replay runner; simplify BoilerConfigReader, control-service logging and entity parsing. Switch CostAccumulator to System.Threading.Lock, update the Shower exhaust fan service and tests, drop the legacy HistoryReplay/McpServer sources and reporting tooling, and expand AGENTS.md with the current project wiring and DI notes.
This commit is contained in:
@@ -6,26 +6,18 @@ using PowerMonitorManager.Models.Consts;
|
||||
|
||||
namespace PowerMonitorManager;
|
||||
|
||||
public sealed class PowerNotificationService : IPowerNotificationService
|
||||
public sealed class PowerNotificationService(
|
||||
IHaContext haContext,
|
||||
ILogger<PowerNotificationService> logger)
|
||||
: IPowerNotificationService
|
||||
{
|
||||
private readonly IHaContext _haContext;
|
||||
private readonly ILogger<PowerNotificationService> _logger;
|
||||
|
||||
public PowerNotificationService(
|
||||
IHaContext haContext,
|
||||
ILogger<PowerNotificationService> logger)
|
||||
{
|
||||
_haContext = haContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void NotifyHighPowerUsage(double currentPowerWatts, double thresholdWatts)
|
||||
{
|
||||
var currentKw = currentPowerWatts / PowerMonitorConsts.WattsPerKilowatt;
|
||||
var thresholdKw = thresholdWatts / PowerMonitorConsts.WattsPerKilowatt;
|
||||
var message = BuildHighPowerMessage(currentKw, thresholdKw);
|
||||
|
||||
_haContext.CallService(
|
||||
haContext.CallService(
|
||||
PowerMonitorConsts.PersistentNotificationDomain,
|
||||
PowerMonitorConsts.PersistentNotificationCreateService,
|
||||
data: new
|
||||
@@ -35,14 +27,12 @@ public sealed class PowerNotificationService : IPowerNotificationService
|
||||
notification_id = PowerMonitorConsts.HighPowerNotificationId
|
||||
});
|
||||
|
||||
_logger.LogWarning(
|
||||
"High power usage notification sent: {CurrentKw:F2} kW (threshold: {ThresholdKw:F1} kW)",
|
||||
currentKw, thresholdKw);
|
||||
logger.LogWarning("High power usage notification sent: {CurrentKw:F2} kW (threshold: {ThresholdKw:F1} kW)", currentKw, thresholdKw);
|
||||
}
|
||||
|
||||
public void DismissHighPowerNotification()
|
||||
{
|
||||
_haContext.CallService(
|
||||
haContext.CallService(
|
||||
PowerMonitorConsts.PersistentNotificationDomain,
|
||||
PowerMonitorConsts.PersistentNotificationDismissService,
|
||||
data: new
|
||||
@@ -50,10 +40,10 @@ public sealed class PowerNotificationService : IPowerNotificationService
|
||||
notification_id = PowerMonitorConsts.HighPowerNotificationId
|
||||
});
|
||||
|
||||
_logger.LogDebug("Dismissed high power usage notification");
|
||||
logger.LogDebug("Dismissed high power usage notification");
|
||||
}
|
||||
|
||||
internal static string BuildHighPowerMessage(double currentKw, double thresholdKw)
|
||||
private static string BuildHighPowerMessage(double currentKw, double thresholdKw)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
|
||||
Reference in New Issue
Block a user