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:
@@ -93,9 +93,6 @@ public sealed class BoilerMonitorEntityService(
|
||||
var formattedRunTime = FormatTimeSpan(ctx.TodayRunTime);
|
||||
var formattedRemaining = FormatTimeSpan(ctx.RemainingTime);
|
||||
|
||||
// logger.LogInformation("Updating BoilerMonitor entities: runtime={RunTime}, remaining={Remaining}, budget={Budget}%, sessions={Sessions}",
|
||||
// formattedRunTime, formattedRemaining, ctx.BudgetPercentage, ctx.SessionCount);
|
||||
|
||||
var updateTasks = new[]
|
||||
{
|
||||
UpdateStatusAsync(StatusConfigured),
|
||||
@@ -116,7 +113,7 @@ public sealed class BoilerMonitorEntityService(
|
||||
|
||||
try
|
||||
{
|
||||
var removeTasks = CleanableEntityIds.Select(entityId => entityManager.RemoveEntity(entityId));
|
||||
var removeTasks = CleanableEntityIds.Select(entityManager.RemoveEntity);
|
||||
await Task.WhenAll(removeTasks).ConfigureAwait(false);
|
||||
|
||||
logger.LogInformation("BoilerMonitor entities cleaned up successfully (cleanup button retained)");
|
||||
@@ -149,8 +146,7 @@ public sealed class BoilerMonitorEntityService(
|
||||
var skipPriceCapState = haContext.GetState(SkipPriceCapEntityId)?.State;
|
||||
var budgetOverrideState = haContext.GetState(BudgetOverrideEntityId)?.State;
|
||||
|
||||
if (!TryParseEntitySeconds(runtimeState, out var runtimeSeconds)
|
||||
|| !TryParseEntityInt(sessionCountState, out var sessionCount))
|
||||
if (!TryParseEntitySeconds(runtimeState, out var runtimeSeconds) || !TryParseEntityInt(sessionCountState, out var sessionCount))
|
||||
{
|
||||
logger.LogInformation("No valid persisted BoilerMonitor state found in HA entities (runtime={Runtime}, sessions={Sessions})",
|
||||
runtimeState, sessionCountState);
|
||||
@@ -185,19 +181,23 @@ public sealed class BoilerMonitorEntityService(
|
||||
private static bool TryParseEntitySeconds(string? state, out double seconds)
|
||||
{
|
||||
seconds = 0;
|
||||
return !string.IsNullOrWhiteSpace(state)
|
||||
&& state is not ("unavailable" or "unknown")
|
||||
&& double.TryParse(state, CultureInfo.InvariantCulture, out seconds)
|
||||
&& seconds >= 0;
|
||||
var tryParseEntitySeconds = !string.IsNullOrWhiteSpace(state)
|
||||
&& state is not ("unavailable" or "unknown")
|
||||
&& double.TryParse(state, CultureInfo.InvariantCulture, out seconds)
|
||||
&& seconds >= 0;
|
||||
|
||||
return tryParseEntitySeconds;
|
||||
}
|
||||
|
||||
private static bool TryParseEntityInt(string? state, out int value)
|
||||
{
|
||||
value = 0;
|
||||
return !string.IsNullOrWhiteSpace(state)
|
||||
&& state is not ("unavailable" or "unknown")
|
||||
&& int.TryParse(state, CultureInfo.InvariantCulture, out value)
|
||||
&& value >= 0;
|
||||
var tryParseEntityInt = !string.IsNullOrWhiteSpace(state)
|
||||
&& state is not ("unavailable" or "unknown")
|
||||
&& int.TryParse(state, CultureInfo.InvariantCulture, out value)
|
||||
&& value >= 0;
|
||||
|
||||
return tryParseEntityInt;
|
||||
}
|
||||
|
||||
private ICollection<BoilerMonitorEntity> GetAllEntities()
|
||||
|
||||
Reference in New Issue
Block a user