Files
HomeAssistant/LightMonitor.Manager/PresenceService.cs
T
gitea_admin f0bbd4f10b 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.
2026-11-29 13:58:08 +02:00

40 lines
1.1 KiB
C#

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NetDaemon.HassModel;
using LightMonitor.Models;
using LightMonitorManager.Interface;
using LightMonitorManager.Models;
namespace LightMonitorManager;
public sealed class PresenceService(
IHaContext haContext,
ILogger<PresenceService> logger,
IOptions<LightMonitorOptions> options) : IPresenceService
{
private readonly LightMonitorOptions _options = options.Value;
public bool IsAnyoneHome()
{
foreach (var personEntityId in _options.PersonEntityIds)
{
var state = haContext.GetState(personEntityId);
if (state?.State is null or LightMonitorConsts.UnavailableState or LightMonitorConsts.UnknownState)
{
continue;
}
if (string.Equals(state.State, LightMonitorConsts.PersonHomeState, StringComparison.OrdinalIgnoreCase))
{
logger.LogDebug("Person {EntityId} is home", personEntityId);
return true;
}
}
return false;
}
}