This commit is contained in:
2026-06-28 13:58:35 +03:00
parent 8f45028715
commit e6bf8258bb
114 changed files with 4365 additions and 874 deletions
+15
View File
@@ -63,6 +63,13 @@ public sealed class LightMonitorInit : ILightMonitorInit
return;
}
if (IsRecoveryTransition(e.Old?.State))
{
_logger.LogInformation("Sun state recovered from {OldState}, ignoring", e.Old?.State);
return;
}
_logger.LogInformation("Sun went below horizon, checking if anyone is home");
if (_presenceService.IsAnyoneHome())
@@ -92,6 +99,12 @@ public sealed class LightMonitorInit : ILightMonitorInit
return;
}
if (IsRecoveryTransition(e.Old?.State))
{
_logger.LogInformation("Person {EntityId} state recovered from {OldState}, ignoring", personEntityId, e.Old?.State);
return;
}
_logger.LogInformation("Person {EntityId} arrived home, checking if it is dark", personEntityId);
_lightControlService.TurnOnLight();
}
@@ -102,4 +115,6 @@ public sealed class LightMonitorInit : ILightMonitorInit
});
}
}
private static bool IsRecoveryTransition(string? oldState) => oldState is null or LightMonitorConsts.UnavailableState or LightMonitorConsts.UnknownState;
}